From 1d7dd7d624bdb8e0a4f0dd26be4a215d6cdbb043 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 26 Jul 2019 00:29:54 +0200 Subject: [PATCH] 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 --- public/js/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/js/index.js b/public/js/index.js index afc894ca3b..90412756f1 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -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