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(() => {
{ 更多