From e976a5ddc7598de49227f600515a7eee72fc1af6 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 8 Jun 2025 17:34:56 -0700 Subject: [PATCH] Re-highlight code blocks when switching light/dark themes --- js/dark_theme.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/dark_theme.js b/js/dark_theme.js index b540fb11..f61060cd 100644 --- a/js/dark_theme.js +++ b/js/dark_theme.js @@ -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); + }); + }; }