From d085dc6a93577bbafbde529c497528965dbfc19b Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Mon, 9 Jun 2025 18:40:54 -0700 Subject: [PATCH] Minor optimization after e976a5ddc7598de49227f600515a7eee72fc1af6 --- js/dark_theme.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/dark_theme.js b/js/dark_theme.js index f61060cd..7136f5bf 100644 --- a/js/dark_theme.js +++ b/js/dark_theme.js @@ -9,8 +9,12 @@ function toggleDarkMode() { // Re-highlight all code blocks once stylesheet loads currentCSS.onload = function() { - document.querySelectorAll("pre code").forEach(block => { - hljs.highlightElement(block); + const messageBodies = document.getElementById("chat").querySelectorAll(".message-body"); + messageBodies.forEach((messageBody) => { + const codeBlocks = messageBody.querySelectorAll("pre code"); + codeBlocks.forEach((codeBlock) => { + hljs.highlightElement(codeBlock); + }); }); }; }