A chaining API like webpack-chain but for markdown-it.

Downloads in past


31131.3.05 years ago6 years agoMinified + gzip package size for markdown-it-chain in KB


A chaining API like webpack-chain but for markdown-it.

NPM version


yarn add -dev markdown-it-chain

npm install --save-dev markdown-it-chain

Getting Started

// Require the markdown-it-chain module. This module exports a single
// constructor function for creating a configuration API.
const Config = require('markdown-it-chain')

// Instantiate the configuration with a new API
const config = new Config()

// Make configuration changes using the chain API.
// Every API call tracks a change to the stored configuration.
  // Interact with 'options' in new MarkdownIt
  // Ref:
    .html(true) // equal to .set('html', true)

  // Interact with 'plugins'
    // The first parameter is the plugin module, which may be a function
    // while the second parameter is an array of parameters accepted by the plugin.
    .use(require('markdown-it-table-of-contents'), [{
      includeLevel: [2, 3]
    // Move up one level, like .end() in jQuery.

    .use(require('markdown-it-anchor'), [{
      permalink: true,
      permalinkBefore: true,
      permalinkSymbol: '$'
    // Apply this plugin before toc.

// Create a markdown-it instance using the above configuration
const md = config.toMd()
md.render('[[TOC]] \n # h1 \n ## h2 \n ## h3 ')

Worth Reading

In order to ensure the consistency of the chained API world, webpack-it-chain is developed directly on the basis of webpack-chain and ensures that the usage is completely consistent.
Here are some things worth reading that come from webpack-chain:


markdown-it-chain © ULIVZ, Released under the MIT License.
Authored and maintained by ULIVZ with help from contributors (list). · GitHub @ULIVZ · Twitter @ulivz