Skip to content

Commit 5752f45

Browse files
gsmlgGSMLG-BOT
andauthored
fix: Change output to textContent. (#84)
Change output to textContent Co-authored-by: Jonathan Gao <[email protected]>
1 parent 24f3d8c commit 5752f45

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web/llm_chat.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,13 @@ class LLMChatInstance {
537537
const msgText = msg.getElementsByClassName("msg-text");
538538
if (msgText.length != 1) throw Error("Expect msg-text");
539539
if (msgText[0].innerHTML == text) return;
540-
text = text.replaceAll("\n", "<br>");
541-
msgText[0].innerHTML = text;
540+
const list = text.split('\n').map((t) => {
541+
const item = document.createElement('div');
542+
item.textContent = t;
543+
return item;
544+
});
545+
msgText[0].innerHTML = '';
546+
list.forEach((item) => msgText[0].append(item));
542547
this.uiChat.scrollTo(0, this.uiChat.scrollHeight);
543548
}
544549

0 commit comments

Comments
 (0)