markdownit-module icon indicating copy to clipboard operation
markdownit-module copied to clipboard

[markdownit] Add documentation how to set plugin options

Open simonhermann opened this issue 7 years ago • 2 comments

After searching for quite some time I finally figured out what the correct syntax is. I'd appreciate if you could add this to the readme:

markdownit: {
  use: [
    'plugin1',
    ['plugin2', {option1:  true}],
  ],
},
This question is available on Nuxt.js community (#c113)

simonhermann avatar Feb 06 '18 20:02 simonhermann

Agreed. I was trying to solve the problem too.

EmmanuelBeziat avatar Feb 12 '18 04:02 EmmanuelBeziat

It still throws an error if you try something like the following, but for some reason only on subsequent hot reloads. It seems to do fine on initial load...

    use: [
      ['markdown-it-attrs', {
        leftDelimiter: '[',
        rightDelimiter: ']'
      }],

I tracked down the error to markdownit-loader/lib/core.js, and this seems to not crash:

    parser = markdown(opts.preset, opts)
    if (plugins) {
      plugins.forEach(function (plugin) {
        if (Array.isArray(plugin)) {
          // plugin[0] = resolvePlugin(plugin[0])
          // parser.use.apply(parser, plugin)
          parser.use(resolvePlugin(plugin[0]), plugin[1])
        } else {
          parser.use(resolvePlugin(plugin))
        }
      })
    }

janzheng avatar Aug 23 '18 13:08 janzheng