mylloon.fr/static/js/libs/hljs.js
Mylloon c6a1f3efcb
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
add dark/light theme for mermaid and hljs
2023-04-25 02:32:43 +02:00

33 lines
725 B
JavaScript

window.addEventListener("load", () => {
const theme = window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark" // dark
: "default"; // light
hljs.configure({
noHighlightRe: /^$/i,
languageDetectRe: /\blanguage-hljs-([\w-]+)\b/i,
});
hljs.addPlugin(new CopyButtonPlugin());
const aliases = {
bash: ["fish"],
};
for (const lang in aliases) {
hljs.registerAliases(aliases[lang], { languageName: lang });
}
hljs.highlightAll();
hljs.initLineNumbersOnLoad();
document
.getElementById(
`hljs-${
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light"
}-theme`
)
.removeAttribute("disabled");
});