diff options
author | silverwind <me@silverwind.io> | 2019-07-26 00:29:54 +0200 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-07-25 23:29:54 +0100 |
commit | 1d7dd7d624bdb8e0a4f0dd26be4a215d6cdbb043 (patch) | |
tree | 8c74f8f6ea130cdb5503a1c67c744ba69fb34106 /public/js | |
parent | 6782a704ef25f66902f357712218af9d4696fdda (diff) | |
download | gitea-1d7dd7d624bdb8e0a4f0dd26be4a215d6cdbb043.tar.gz gitea-1d7dd7d624bdb8e0a4f0dd26be4a215d6cdbb043.zip |
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
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/index.js | 5 |
1 files changed, 4 insertions, 1 deletions
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 |