From 650fdceb5a2d5ab3057a5193467289e15dfa44e8 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 26 Jul 2019 08:12:35 +0200 Subject: [PATCH] Fix syntax highlight initialization (#7617) (#7626) * 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 52ebe2ecb1..23dcd72196 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1974,7 +1974,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