From 6998fc188eeba154a0933f7e755dc14dc7c6ff39 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 25 Jul 2019 20:05:52 +0200 Subject: [PATCH 1/2] 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 --- 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 afc894ca3b257..a3e2914d9788d 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 From 54aa5a352baca8c590cf90eacc2c483eef625352 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 25 Jul 2019 20:26:55 +0200 Subject: [PATCH 2/2] semicolon --- public/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/index.js b/public/js/index.js index a3e2914d9788d..90412756f108c 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2007,7 +2007,7 @@ $(document).ready(function () { // Highlight JS if (typeof hljs != 'undefined') { - const nodes = [].slice.call(document.querySelectorAll('pre code') || []) + const nodes = [].slice.call(document.querySelectorAll('pre code') || []); for (let i = 0; i < nodes.length; i++) { hljs.highlightBlock(nodes[i]); }