Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed https://markdown-it.github.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1.5 KiB

markdown-it API

Simple use

In most cases you will use markdown-it in very simple way:

var md = require('markdown-it')();

var result = md.render(your_markdown_string);

// Or for inline (without paragraths & blocks)
var resultInline = md.renderInline(your_markdown_inline_string);

Advanced use

Advanced use consist of this steps:

  1. Create instance with desired preset & options.
  2. Add plugins.
  3. Enable/Disable additional rules.
  4. Rewrite renderer functions.
  5. Use result to call .render() or .renderInline() method.

Of cause, you can skip not needed steps, or change sequense.

Example 1. Minimalistic mode with bold, italic and line breaks:

var md = require('markdown-it')('zero', { breaks: true })
            .enable([ 'newline', 'emphasis' ]);

var result = md.renderInline(...);

Example 2. Load plugin and disable tables:

var md = require('markdown-it')()
            .use(require('markdown-it-emoji'))
            .disable('table');

var result = md.render(...);

Example 3. Replace <strong> with <b> in rendered result:

var md = require('markdown-it')();

md.renderer.rules.strong_open  = function () { return '<b>'; };
md.renderer.rules.strong_close = function () { return '</b>'; };

var result = md.renderInline(...);

See classes doc for all available features and more examples.