Update chat.js

This commit is contained in:
公明
2025-11-24 00:47:00 +08:00
committed by GitHub
parent 510c1bb2d0
commit 41015573de

View File

@@ -558,7 +558,10 @@ function addMessage(role, content, mcpExecutionIds = null, progressId = null, cr
}
};
if (typeof DOMPurify !== 'undefined') {
// 对于用户消息直接转义HTML不进行Markdown解析以保留所有特殊字符
if (role === 'user') {
formattedContent = escapeHtml(content).replace(/\n/g, '<br>');
} else if (typeof DOMPurify !== 'undefined') {
let parsedContent = parseMarkdown(content);
if (!parsedContent) {
// 如果 Markdown 解析失败或 marked 不可用,则退回原始内容