remark
remark is a markdown processor powered by plugins part of the unified collective.
- API by
unified
- Parses markdown to the tree with
remark-parse
- mdast syntax tree
- Plugins transform the tree
- Compiles the tree to markdown using
remark-stringify
Don’t need the parser? Or the compiler? That’s OK.
Announcing the unified collective!
Sponsors
|
|
|
Holloway |
You? |
Installation
npm:
npm install remark
Usage
Common example
This example lints markdown and turns it into HTML.
var remark = require('remark')
var recommended = require('remark-preset-lint-recommended')
var html = require('remark-html')
var report = require('vfile-reporter')
remark()
.use(recommended)
.use(html)
.process('## Hello world!', function(err, file) {
console.error(report(err || file))
console.log(String(file))
})
Yields:
1:1 warning Missing newline character at end of file final-newline remark-lint
⚠ 1 warning
<h2>Hello world!</h2>
Settings through data
This example prettifies markdown and configures remark-parse
and
remark-stringify
through data.
var remark = require('remark')
remark()
.data('settings', {commonmark: true, emphasis: '*', strong: '*'})
.process('_Emphasis_ and __importance__', function(err, file) {
if (err) throw err
console.log(String(file))
})
Yields:
*Emphasis* and **importance**
Settings through a preset
This example prettifies markdown and configures remark-parse
and
remark-stringify
through a preset.
var remark = require('remark')
remark()
.use({
settings: {commonmark: true, emphasis: '*', strong: '*'}
})
.process('_Emphasis_ and __importance__', function(err, file) {
if (err) throw err
console.log(String(file))
})
Yields:
*Emphasis* and **importance**