A remark plugin, make to markdown directives like Zenn.
Find a file
Titus Wormer 9e252ca2e8
1.0.0
2020-10-22 20:11:29 +02:00
test . 2020-10-22 19:09:38 +02:00
types . 2020-10-22 19:09:38 +02:00
.editorconfig . 2020-10-22 19:09:38 +02:00
.gitignore . 2020-10-22 19:09:38 +02:00
.npmrc . 2020-10-22 19:09:38 +02:00
.prettierignore . 2020-10-22 19:09:38 +02:00
.travis.yml . 2020-10-22 19:09:38 +02:00
index.js . 2020-10-22 19:09:38 +02:00
license . 2020-10-22 19:09:38 +02:00
package.json 1.0.0 2020-10-22 20:11:29 +02:00
readme.md . 2020-10-22 19:09:38 +02:00

remark-directive

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to support the generic directives proposal (:cite[smith04], ::youtube[Video of a cat in a box]{v=01ab2cd3efg}, and such).

Important!

This plugin is made for the new parser in remark (micromark, see remarkjs/remark#536). Use this plugin for remark 13+.

Install

npm:

npm install remark-directive

Use

Say we have the following file, example.md:

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var report = require('vfile-reporter')
var unified = require('unified')
var parse = require('remark-parse')
var directive = require('remark-directive')
var stringify = require('rehype-stringify')

unified()
  .use(parse)
  .use(directive)
  .use(remark2rehype)
  .use(stringify)
  .process(vfile.readSync('example.md'), function (err, file) {
    console.error(report(err || file))
    console.log(String(file))
  })

Now, running node example yields:

API

remark().use(directive)

Configures remark so that it can parse and serialize directives. Doesnt handle the directives: create your own plugin to do that. See the micromark extension for the syntax and the mdast utility for the syntax tree.

Security

Use of remark-directive does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.

Contribute

See contributing.md in remarkjs/.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