Skip to content

Commit c2ce95c

Browse files
izumin5210wooorm
izumin5210
authored andcommitted
Fix to support spaces inside marker if it has no attributes
Closes GH-2.
1 parent 0611558 commit c2ce95c

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ module.exports = marker;
66
/* HTML type. */
77
var T_HTML = 'html';
88

9+
/* Expression for eliminating extra spaces */
10+
var SPACES = /\s+/g;
11+
912
/* Expression for parsing parameters. */
1013
var PARAMETERS = new RegExp(
1114
'\\s+' +
@@ -112,5 +115,5 @@ function parameters(value) {
112115
return '';
113116
});
114117

115-
return rest ? null : attributes;
118+
return rest.replace(SPACES, '') ? null : attributes;
116119
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"bugs": "https://github.com/syntax-tree/mdast-comment-marker/issues",
1414
"author": "Titus Wormer <[email protected]> (http://wooorm.com)",
1515
"contributors": [
16-
"Titus Wormer <[email protected]> (http://wooorm.com)"
16+
"Titus Wormer <[email protected]> (http://wooorm.com)",
17+
"Masayuki Izumi <[email protected]> (http://izumin.info)"
1718
],
1819
"files": [
1920
"index.js"

test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ test('normalize(value, allowApostrophes)', function (t) {
6262
'marker without attributes'
6363
);
6464

65+
node = {
66+
type: 'html',
67+
value: '<!-- foo -->'
68+
};
69+
70+
t.deepEqual(
71+
marker(node),
72+
{
73+
name: 'foo',
74+
attributes: '',
75+
parameters: {},
76+
node: node
77+
},
78+
'marker without attributes ignoring spaces'
79+
);
80+
6581
node = {
6682
type: 'html',
6783
value: '<!--foo bar-->'

0 commit comments

Comments
 (0)