Re-highlight code blocks when switching light/dark themes

This commit is contained in:
oobabooga 2025-06-08 17:34:56 -07:00
parent 7ed1926ce7
commit e976a5ddc7

View file

@ -6,4 +6,11 @@ function toggleDarkMode() {
} else {
currentCSS.setAttribute("href", "file/css/highlightjs/github-dark.min.css");
}
// Re-highlight all code blocks once stylesheet loads
currentCSS.onload = function() {
document.querySelectorAll("pre code").forEach(block => {
hljs.highlightElement(block);
});
};
}