Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

1.2.1

Compare
Choose a tag to compare
@alidcast alidcast released this 25 Dec 00:54
· 157 commits to master since this release
  • fixed incompatibilities with Linux and Windows (closes #124 #128)

  • Merged new parser API to allow more powerful plugin usage. (#119, thanks to @arrkiin for the work and patience)

There are three ways to configure the parser:

  1. extend the default options passed to the parser.
  2. Add plugins to the parser.
  3. customize the parser after it was created.

Example usage:

// nuxtent.config.js
const Prism = require('prismjs')
const externalLinks = require('markdown-it-link-attributes')
const emoji = require('markdown-it-emoji')
const twemoji = require('twemoji')

module.exports = {
  parsers: {
    md: {
        extend(config) {
          config.highlight = (code, lang) => {
            return `<pre class="language-${lang}"><code class="language-${lang}">${Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)}</code></pre>`
          }
        },
        plugins: [
            emoji,
            [ externalLinks, { target: '_blank', rel: 'noopener' } ]
        ],
        customize(parser) {
            parser.linkify.tlds('onion')
            parser.linkify.add(... custom code to recognize and handle twitter handles ...)
            parser.renderer.rules['emoji'] = (token, idx) => {
                return twemoji.parse(token[idx].content);
            }
        }
    }
  },
  ...
  css: [
    'prismjs/themes/prism-coy.css'
  ]
}