更新数据截止日2025.12.24

This commit is contained in:
lychang
2025-12-26 08:20:45 +08:00
parent 7169b568dd
commit de0842fbe1
17 changed files with 3466 additions and 1977 deletions

View File

@@ -236,14 +236,24 @@ class MarkdownParser {
}
/**
* HTML转义
* HTML转义,支持保留<br>标签
* @param {string} text - 原始文本
* @returns {string} - 转义后的文本
*/
escapeHTML(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
// 首先转义所有HTML特殊字符
const escapedText = text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
// 然后恢复<br>标签的功能
return escapedText
.replace(/&lt;br\s*\/?&gt;/gi, '<br>')
.replace(/&lt;br\s*\/?&gt;/gi, '<br>')
.replace(/\\n/g, '<br>'); // 也支持\n换行符
}
/**