33 lines
725 B
JavaScript
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");
|
|
});
|