Skip to content

Commit 25af221

Browse files
authored
Merge pull request #9 from syntax-tree/image
Image
2 parents 85a5b3c + bb18b04 commit 25af221

File tree

8 files changed

+39
-2
lines changed

8 files changed

+39
-2
lines changed

handlers/image.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
module.exports = image;
4+
5+
function image(h, node) {
6+
var props = {
7+
url: node.properties.src || '',
8+
title: node.properties.title || null,
9+
alt: node.properties.alt || null
10+
};
11+
12+
return h(node, 'image', props);
13+
}

handlers/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports.text = require('./text');
77
exports.strong = exports.b = require('./strong');
88
exports.em = exports.i = require('./emphasis');
99
exports.code = exports.kbd = exports.samp = exports.var = require('./inline-code');
10+
exports.img = require('./image');
1011

1112
exports.p = require('./paragraph');
1213

handlers/link.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var all = require('../all');
66

77
function link(h, node) {
88
var props = {
9-
url: node.properties.href,
9+
url: node.properties.href || '',
1010
title: node.properties.title || null
1111
};
1212

tests/fixtures/a/index.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
<p><a href="http://example.com" title="example">example</a></p>
2-
<p><a href="http://example.com">example</a></p>
2+
<p><a href="http://example.com">example</a></p>
3+
<p><a>example</a></p>
4+
<p><a></a></p>

tests/fixtures/a/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[example](http://example.com "example")
22

33
[example](http://example.com)
4+
5+
[example](<>)
6+
7+
[](<>)

tests/fixtures/img/index.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p><img src="http://example.com" title="example" alt="example"></p>
2+
<p><img src="http://example.com" title="example"></p>
3+
<p><img src="http://example.com" alt="example"></p>
4+
<p><img src="http://example.com"></p>
5+
<p><img></p>

tests/fixtures/img/index.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"fragment": true
3+
}

tests/fixtures/img/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
![example](http://example.com "example")
2+
3+
![](http://example.com "example")
4+
5+
![example](http://example.com)
6+
7+
![](http://example.com)
8+
9+
![](<>)

0 commit comments

Comments
 (0)