Skip to content

Commit 1d7dd7d

Browse files
silverwindzeripath
authored andcommitted
Fix syntax highlight initialization (#7617)
* Fix syntax highlight initialization Previously hljs was initialized via a function that relies on the DOMContentLoaded event, registerd after jQuery's 'ready' event. I assume that with the recent jQuery update, DOMContentLoaded may not be guaranteed to fire after 'ready'. Fixed this via vanilla JS initalization. Fixes: #7559 * semicolon
1 parent 6782a70 commit 1d7dd7d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

public/js/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,10 @@ $(document).ready(function () {
20072007

20082008
// Highlight JS
20092009
if (typeof hljs != 'undefined') {
2010-
hljs.initHighlightingOnLoad();
2010+
const nodes = [].slice.call(document.querySelectorAll('pre code') || []);
2011+
for (let i = 0; i < nodes.length; i++) {
2012+
hljs.highlightBlock(nodes[i]);
2013+
}
20112014
}
20122015

20132016
// Dropzone

0 commit comments

Comments
 (0)