Seems like highlight.js relies on the conventional on the ready()
event
(or something close to that) to trigger … which is obviously broken by
Turbolinks.
$(document).on('page:change', function() {
hljs.initHighlightingOnLoad();
});
$(document).on('page:restore', function() {
hljs.initHighlightingOnLoad();
});
Instead do this …
$(document).on('page:change', function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});
$(document).on('page:restore', function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});