How to use the highlightAllUnder function from prismjs

Find comprehensive JavaScript prismjs.highlightAllUnder code examples handpicked from public code repositorys.

15
16
17
18
19
20
21
22
23
24

function highlight(str, lang) {
        if (lang) loadLanguages([ lang ]);
        let document = dom.window.document;
        document.body.innerHTML = `<pre class="language-${ lang } line-numbers"><code>${ require('escape-html')(str) }</code></pre>`;
        Prism.highlightAllUnder(document);
        return document.body.innerHTML.trim();
}

let md = MarkdownIt({
fork icon12
star icon1
watch icon1