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.3 KiB

markdown-it API

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 usage 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.

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.