One special circumstance related to this, although too long for comment:
A call to the DOM completion event will not be sufficient for new blogger.com/blogspot dynamic viewing templates and, possibly, for other similar sites, since in this case the DOM is loaded, but just consists of a div element prepared for injection, and the contents of the DOM are entered using the JavaScript method, which itself is called in standby mode:
setTimeout(function() { blogger.ui().configure().view(); }, 800);
In order for the syntax shortcut to work then, you need to complete the complex DOM tree. One solution is to run hljs.initHighlightingOnLoad(); or a custom highlightBlock function after a generous wait period.
setTimeout(function() { blogger.ui().configure().view(); setTimeout(function() {$('pre code').each(function(i, e) {hljs.highlightBlock(e)});}, 2000); }, 800);
Lorenz Lo Sauer
source share