From 31e9e57572ca608a892a38cacaa7bfead4b6fd1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=A2=A6?= Date: Tue, 19 May 2026 18:10:41 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=95=E5=8D=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=8C=89=E9=92=AE=E6=8C=AA=E5=88=B0=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E9=87=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/src/components/latex-text/index.vue | 15 +++++++++++++-- .../src/views/question-bank/paper-mgr/home.vue | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/playground/src/components/latex-text/index.vue b/playground/src/components/latex-text/index.vue index d49b7bf..3165021 100644 --- a/playground/src/components/latex-text/index.vue +++ b/playground/src/components/latex-text/index.vue @@ -17,7 +17,16 @@ const props = defineProps<{ const regex_dollar = /(\$[^$]+\$)/g const regex_tag = /(<\/span>)/g -const regex_html = /(<\/?[a-zA-Z][^>]*>)/g +// 仅匹配合法 HTML 标签,避免将 $a]*)?\s*>)/g + +function escapeHtml(text: string) { + return text + .replaceAll('&', '&') + .replaceAll('<', '<') + .replaceAll('>', '>') + .replaceAll('"', '"') +} function addLatexText(list: any[], text: string) { list.push({ @@ -40,7 +49,9 @@ function parseLatexDollar(list: any[], text: string) { if (part.startsWith('$') && part.endsWith('$') && part.length > 2) { addLatexText(list, part.substring(1, part.length - 1)) } else if (part) { - list.push({ content: part.replace(/\\([{}])/g, '$1') }) + list.push({ + content: escapeHtml(part.replace(/\\([{}])/g, '$1')), + }) } } } diff --git a/playground/src/views/question-bank/paper-mgr/home.vue b/playground/src/views/question-bank/paper-mgr/home.vue index dc955ec..c061f03 100644 --- a/playground/src/views/question-bank/paper-mgr/home.vue +++ b/playground/src/views/question-bank/paper-mgr/home.vue @@ -438,6 +438,7 @@ onMounted(() => {
{ 更多