jonschlinkert /remarkable
Markdown parser, done right. Commonmark support, extensions, syntax plugins, high speed - all in one. Gulp and metalsmith plugins available. Used by Facebook, Docusaurus and many others! Use https://github.com/breakdance/breakdance for HTML-to-markdown conversion. Use https://github.com/jonschlinkert/markdown-toc to generate a table of contents.
★ 5,842⑂ 374👁 87⑃ 126● 312▤ 1
+0
Daily
5,842
stars
374
forks
87
watchers
126
prs
312
issues
1
releases
README
remarkable
Markdown parser done right. Fast and easy to extend.
__Live demo__
- Supports the CommonMark spec +
syntax extensions + sugar (URL autolinking, typographer).
- Configurable syntax! You can add new rules and even replace existing ones.
- High speed!
- Community plugins on npm.
Install
node.js:
bash
npm install remarkable --save
browser (CDN):
- jsDeliver CDN
- cdnjs
Usage
js
import { Remarkable } from 'remarkable';
var md = new Remarkable();
console.log(md.render(' Remarkable rulezz!'));
// = Remarkable rulezz!
or with commonjs
js
const { Remarkable } = require('remarkable');
var md = new Remarkable();
console.log(md.render(' Remarkable rulezz!'));
// = Remarkable rulezz!
If installed globally with npm:
sh
cat myfile.md | remarkable
remarkable --file myfile.md
get options
remarkable -h
Documentation
See the docs directory for documentation on the following topics:
- parser
- parsing_block
- parsing_core
- parsing_inline
- plugins
- renderer
Options
By default, remarkable is configured to be similar to GFM, but with HTML disabled.
This is easy to change if you prefer different settings.
There are two ways to define options.
constructor
Define options in the constructor:
js
// Actual default values
var md = new Remarkable({
html: false, // Enable HTML tags in source
xhtmlOut: false, // Use '/' to close single tags ()
breaks: false, // Convert '\n' in paragraphs into
langPrefix: 'language-', // CSS language prefix for fenced blocks
// Enable some language-neutral replacement + quotes beautification
typographer: false,
// Double + single quotes replacement pairs, when typographer enabled,
// and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
quotes: '“”‘’',
// Highlighter function. Should return escaped HTML,
// or '' if the source string is not changed
highlight: function (/str, lang/) { return ''; }
});
console.log(md.render(' Remarkable rulezz!'));
// = Remarkable rulezz!
.set
Or define options via the .set() method:
js
import { Remarkable } from 'remarkable';
var md = new Remarkable();
md.set({
html: true,
breaks: true
});
Note: To achieve the best possible performance, don't modify a Remarkable
instance on the fly. If you need multiple configurations, create
multiple instances and initialize each with a configuration that is ideal for
that instance.
Presets
Remarkable offers some "presets" as a convenience to quickly enable/disable
active syntax rules and options for common use cases.
commonmark
Enable strict CommonMark mode with the commonmark preset:
js
import { Remarkable } from 'remarkable';
var md = new Remarkable('commonmark');
full
Enable all available rules (but still with default options, if not set):
js
import { Remarkable } from 'remarkable';
var md = new Remarkable('full');
// Or with options:
var md = new Remarkable('full', {
html: true,
typographer: trueTop issues
#62Emoji feature design20 comments · 2014-10-26#48Example of Custom Rule, and appropriate renderer.18 comments · 2014-10-21#268Non breaking spaces are breaking9 comments · 2017-05-01#145Cannot nest an image (using reference syntax) inside a link9 comments · 2015-03-18#254DMCA takedown of markdown-it8 comments · 2017-01-27#117Create hooks for autolinks8 comments · 2014-12-09#221Typings for TypeScript7 comments · 2016-07-06#131Is there no option to customize the code block tags?7 comments · 2015-01-23
Latest release
v2.0.0 v2.0.0 2019-08-07This major bump mostly improves and simplifies distribution.
- source code is converted to esm
- lib is not longer published to hide internals and allow us safely change them
- we started to use rollup to provide umd, cjs and esm bundles
- bower support is removed as not relevant these days
- autolinker is upgraded so you should not get old vulnerabilities
To make esm/cjs interop safe we migrated to named exports in public api
diff
- import Remarkable from 'remarkable';
- const utils = Remarkable.utils;
+ import { Remarkable, utils } from 'remarkable';
diff
- const Remark