plugin

Source:

Methods

(inner) marpitPlugin(plugin) → {function}

Create Marpit plugin.

Generate Marpit plugin from passed markdown-it plugin. Marpit plugin needs markdown-it instance with marpit member.

Source:
Parameters:
Name Type Description
plugin function

Base plugin for markdown-it.

Returns:
Type:
function

Generated Marpit plugin.

Example
import { marpitPlugin } from '@marp-team/marpit/plugin'

export default marpitPlugin((md) => {
  // Compatible with markdown-it plugin
  md.renderer.rules.your_rule = (tokens, idx, options, env, self) => {
    // ...
  }

  // And accessible to Marpit instance as `md.marpit`
  const { marpit } = md

  marpit.customDirectives.local.yourDirective = (value) => {
    return { yourDirective: value }
  }
})