How to reinitialize highlight.js?

boreq picture boreq · Oct 26, 2012 · Viewed 8.8k times · Source

My website is generating some content dynamically, so I have to somehow launch the highlight.js plugin again after loading it.

This code is used to launch the highlighter:

hljs.initHighlightingOnLoad();

I tried to do something like hljs.initHighlighting(); to do this again but it does not work.

Answer

Serhii Polishchuk picture Serhii Polishchuk · Feb 2, 2014

You must set called to false first:

hljs.initHighlighting.called = false;
hljs.initHighlighting();