Parse an MDAST comment marker.
Installation
npm:
npm install mdast-comment-marker
mdast-comment-marker is also available as an AMD, CommonJS, and
globals module, uncompressed and compressed.
Usage
var marker = require('mdast-comment-marker');
A simple marker:
var result = marker({
'type': 'html',
'value': '<!--foo-->'
});
Yields:
{
"name": "foo",
"attributes": "",
"parameters": {},
"node": {
"type": "html",
"value": "<!--foo-->"
}
}
Parameters:
result = marker({
'type': 'html',
'value': '<!--foo bar baz=12.4 qux="test test" quux=\'false\'-->'
});
Yields:
{
"name": "foo",
"attributes": "bar baz=12.4 qux=\"test test\" quux='false'",
"parameters": {
"bar": true,
"baz": 12.4,
"qux": "test test",
"quux": false
},
"node": {
"type": "html",
"value": "<!--foo bar baz=12.4 qux=\"test test\" quux='false'-->"
}
}
Non-markers:
result = marker({
'type': 'html',
'value': '<!doctype html>'
});
Yields:
null
API
marker(node)
Parse a comment marker.
Parameters
node
(Node
) — Node to parse
Returns
Marker?
— Information, when applicable.
Marker
A comment marker.
Properties
name
(string
) — Name of marker;attributes
(string
) — Value after name;parameters
(Object
) — Parsed attributes, tries to convert
values to numbers and booleans when possible;node
(Node
) — Reference to given node.
License
MIT © Titus Wormer