// node.js// can use `require('markdown-it')` for CJSimport markdownit from 'markdown-it'const md = markdownit()const result = md.render('# markdown-it rulezz!');// browser with UMD build, added to "window" on script load// Note, there is no dash in "markdownit".const md = window.markdownit();const result = md.render('# markdown-it rulezz!');
Single line rendering, without paragraph wrap:
import markdownit from 'markdown-it'const md = markdownit()const result = md.renderInline('__markdown-it__ rulezz!');
Init with presets and options
(*) presets define combinations of active rules and options. Can be
"commonmark", "zero" or "default" (if skipped). See
API docs for more details.
import markdownit from 'markdown-it'// commonmark modeconst md = markdownit('commonmark')// default modeconst md = markdownit()// enable everythingconst md = markdownit({ html: true, linkify: true, typographer: true})// full options list (defaults)const md = markdownit({ // Enable HTML tags in source html: false, // Use '/' to close single tags (<br />). // This is only for full CommonMark compatibility.
Here is the result of readme parse at MB Pro Retina 2013 (2.4 GHz):
npm run benchmark-depsbenchmark/benchmark.mjs readmeSelected samples: (1 of 28) > READMESample: README.md (7774 bytes) > commonmark-reference x 1,222 ops/sec ±0.96% (97 runs sampled) > current x 743 ops/sec ±0.84% (97 runs sampled) > current-commonmark x 1,568 ops/sec ±0.84% (98 runs sampled) > marked x 1,587 ops/sec ±4.31% (93 runs sampled)
Note. CommonMark version runs with simplified link normalizers
for more "honest" compare. Difference is ≈1.5×.
As you can see, markdown-it doesn't pay with speed for its flexibility.
Slowdown of "full" version caused by additional features not available in
other implementations.
markdown-it for enterprise
Available as part of the Tidelift Subscription.
The maintainers of markdown-it and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
markdown-it is the result of the decision of the authors who contributed to
99% of the Remarkable code to move to a project with the same authorship but
new leadership (Vitaly and Alex). It's not a fork.
References / Thanks
Big thanks to John MacFarlane for his work on the
CommonMark spec and reference implementations. His work saved us a lot of time
during this project's development.