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.
You must set called to false first:
hljs.initHighlighting.called = false;
hljs.initHighlighting();
You can reinitialize all of the codeblocks like this.
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});
or if you have a div with an ID of myBlock, you can do this.
$(document).ready(function() {
$('#myBlock').each(function(i, e) {hljs.highlightBlock(e)});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With