Miss any of our Open RFC calls?Watch the recordings here! »

mdast-comment-marker

1.1.2 • Public • Published

mdast-comment-marker

Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to parse comment markers.

Install

npm:

npm install mdast-comment-marker

Use

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' } }

API

marker(node)

Parse a comment marker.

Parameters
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

Security

Use of mdast-comment-marker does not involve hast, user content, or change the tree, so there are no openings for cross-site scripting (XSS) attacks.

Contribute

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, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Install

npm i mdast-comment-marker

DownloadsWeekly Downloads

70,417

Version

1.1.2

License

MIT

Unpacked Size

8.43 kB

Total Files

4

Last publish

Collaborators

  • avatar
  • avatar