mylloon.fr/static/js/libs/hljs.js

34 lines
725 B
JavaScript
Raw Normal View History

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