From ff316c7e91cf1c51a0c29e2ecec8432cf746f5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=A3=AE?= Date: Sun, 10 May 2026 16:07:25 +0800 Subject: [PATCH] fix: only highlight code blocks within current message --- internal/web/html.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/web/html.go b/internal/web/html.go index 0497a13..921e6f7 100644 --- a/internal/web/html.go +++ b/internal/web/html.go @@ -454,7 +454,9 @@ const indexHTML = ` const content = currentAssistantDiv.querySelector('.message-content'); content.innerHTML = renderMarkdown(currentContent); if (typeof hljs !== 'undefined') { - hljs.highlightAll(); + content.querySelectorAll('pre code').forEach(function(block) { + hljs.highlightElement(block); + }); } chatBox.scrollTop = chatBox.scrollHeight; } @@ -499,7 +501,9 @@ const indexHTML = ` chatBox.scrollTop = chatBox.scrollHeight; if (role !== 'user' && typeof hljs !== 'undefined') { - hljs.highlightAll(); + text.querySelectorAll('pre code').forEach(function(block) { + hljs.highlightElement(block); + }); } return div;