Skip to content

Commit bb18b04

Browse files
committed
Add support for img element to image node
1 parent b776a59 commit bb18b04

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

handlers/image.js

Lines changed: 13 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

tests/fixtures/img/index.html

Lines changed: 5 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"fragment": true
3+
}

tests/fixtures/img/index.md

Lines changed: 9 additions & 0 deletions
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)