npm.io
1.2.9 • Published 6 years ago

remark-comments-three

Licence
MIT
Version
1.2.9
Deps
0
Size
9 kB
Vulns
0
Weekly
0

remark-comments-three Build Status Coverage Status

This plugin parses custom Markdown syntax for Markdown source comments.

Syntax

You can insert comments in the Markdown source this way:

Foo<!---I am a comment-->bar

Everything between <!--- and --> will be absent from the HTML output. Compiling to Markdown will preserve all comments.

AST node (see [mdast][mdast] specification)

The plugin will product the following node and add it to the MDAST syntax tree:

interface Comments <: Node {
  type: "comments";
  data: {
    comment: string;
  }
}

Installation

npm:

npm install remark-comments-three

Configuration

Two options can be passed, as a single argument object:

{beginMarker = 'COMMENTS', endMarker = 'COMMENTS'}

Therefore, invoking this plugin this way:

  .use(remarkComments, {
    beginMarker: 'foo',
    endMarker: 'bar'
  })

will make this plugin remove what's put between <!---foo and bar-->.

Usage

Dependencies:

const unified = require('unified')
const remarkParse = require('remark-parse')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')

const remarkComments = require('remark-comments')

Usage:

unified()
  .use(remarkParse)
  .use(remarkComments)
  .use(remark2rehype)
  .use(stringify)

License

MIT Zeste de Savoir

Keywords