diff options
Diffstat (limited to 'web_src/js/features')
-rw-r--r-- | web_src/js/features/highlight.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/web_src/js/features/highlight.js b/web_src/js/features/highlight.js new file mode 100644 index 0000000000..dcd8a8d21e --- /dev/null +++ b/web_src/js/features/highlight.js @@ -0,0 +1,12 @@ +export default async function initHighlight() { + if (!window.config || !window.config.HighlightJS) return; + + const hljs = await import(/* webpackChunkName: "highlight" */'highlight.js'); + + const nodes = [].slice.call(document.querySelectorAll('pre code') || []); + for (let i = 0; i < nodes.length; i++) { + hljs.highlightBlock(nodes[i]); + } + + return hljs; +} |