mdast utility to parse comment markers.
npm:
npm install mdast-comment-marker
var marker = require('mdast-comment-marker');
console.log(marker({
type: 'html',
value: '<!--foo-->'
}));
console.log(marker({
type: 'html',
value: '<!--foo bar baz=12.4 qux="test test" quux=\'false\'-->'
}));
console.log(marker({
type: 'html',
value: '<!doctype html>'
}));
// Also supports MDX comment nodes.
console.log(marker({
type: 'comment',
value: 'bar'
}));
Yields:
{ name: 'foo',
attributes: '',
parameters: {},
node: { type: 'html', value: '<!--foo-->' } }
{ 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\'-->' } }
null
{ name: 'bar',
attributes: '',
parameters: {},
node: { type: 'comment', value: 'bar' } }
Parse a comment marker.
Marker?
— Information, when applicable.
A comment marker.
name
(string
) — Name of markerattributes
(string
) — Value after nameparameters
(Object
) — Parsed attributes, tries to convert values to numbers and booleans when possiblenode
(Node
) — Reference to given node
See contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.