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: https://github.com/go-gitea/gitea/issues/7559

* semicolon
release/v1.15
silverwind 2019-07-26 00:29:54 +02:00 committed by zeripath
parent 6782a704ef
commit 1d7dd7d624
1 changed files with 4 additions and 1 deletions

View File

@ -2007,7 +2007,10 @@ $(document).ready(function () {
// Highlight JS
if (typeof hljs != 'undefined') {
hljs.initHighlightingOnLoad();
const nodes = [].slice.call(document.querySelectorAll('pre code') || []);
for (let i = 0; i < nodes.length; i++) {
hljs.highlightBlock(nodes[i]);
}
}
// Dropzone