This repository has been archived on 2024-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
forgejo/web_src/js/features/highlight.js

13 lines
366 B
JavaScript
Raw Normal View History

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;
}