Marked: How to add .hljs CSS Class for highlight ?

Created on 26 Jun 2016  路  4Comments  路  Source: markedjs/marked

Such like the title .

Native :

<!--
    use    hljs.initHighlightingOnLoad(); 
-->
<pre>
    <code class="lang-php hljs">
        <span class="hljs-keyword">echo</span>
        <span class="hljs-string">"ok"</span>
    </code>
</pre>
<!--
    use  highlight: function (code) {
            return hljs.highlightAuto(code).value;
         }
-->

<pre>
    <code class="lang-php">
        <span class="hljs-keyword">echo</span>
        <span class="hljs-string">"ok"</span>;
    </code>
</pre>

Most helpful comment

Anyway with trying to override the code renderer, I saw that I could simply change the langPrefix for hljs lang-.

    md.setOptions({
      highlight: function (code) {
        console.log()
        return hljs.highlightAuto(code).value
      },
      langPrefix: 'hljs lang-'
    })

All 4 comments

the same issue for me锛侊紒

Issue closed, but it seems to still be happening (even to me). Anyone have an idea how to fix this? Do I need to set an option?

Anyway with trying to override the code renderer, I saw that I could simply change the langPrefix for hljs lang-.

    md.setOptions({
      highlight: function (code) {
        console.log()
        return hljs.highlightAuto(code).value
      },
      langPrefix: 'hljs lang-'
    })

This is still an issue for me too. The above solution resolved it so thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samit4me picture samit4me  路  3Comments

chunhei2008 picture chunhei2008  路  3Comments

FireflyAndStars picture FireflyAndStars  路  3Comments

mjbvz picture mjbvz  路  4Comments

learykara picture learykara  路  3Comments