Prism.js syntax highlighting on markdown-it

markdown-it has the highlight option. Apply syntax highlighting to fenced code blocks.

In, use highlight.js as highlighting engine, but can also use Prism.

const MarkdownIt = require('markdown-it')
const Prism = require('prismjs')

const md = new MarkdownIt({
  highlight (str, lang) {
    let hl

    try {
      hl = Prism.highlight(str, Prism.languages[lang])
    } catch (error) {
      hl = md.utils.escapeHtml(str)

    return `<pre class="language-${lang}"><code class="language-${lang}">${hl}</code></pre>`

This code works on nodejs.