diff --git a/frontend/src/components/doc-content.vue b/frontend/src/components/doc-content.vue index 5057229af..3959af6f8 100644 --- a/frontend/src/components/doc-content.vue +++ b/frontend/src/components/doc-content.vue @@ -936,8 +936,10 @@ const processMarkdown = (markdownText) => { const safeMarkdown = safeMarkdownToHTML(mathSafeText); // 使用标记渲染 - marked.use({ renderer }); - let html = marked.parse(safeMarkdown) as string; + // Do not register this renderer globally. DocumentPreview uses the same + // `marked` module; registering here made its later Markdown preview reuse + // this image validator after the user had opened the chunk view. + let html = marked.parse(safeMarkdown, { renderer }) as string; // 还原被转义的
html = html.replace(/<br\s*\/?>/gi, '
'); diff --git a/frontend/src/components/document-preview.vue b/frontend/src/components/document-preview.vue index 7a15bbc60..f83ef2c0d 100644 --- a/frontend/src/components/document-preview.vue +++ b/frontend/src/components/document-preview.vue @@ -239,10 +239,11 @@ async function renderMarkdown(blob: Blob) { } return `
${highlighted}
`; }; - marked.use({ renderer }); const mathSafeText = preprocessMathDelimiters(text); const safeText = safeMarkdownToHTML(mathSafeText); - const rawHtml = marked.parse(safeText) as string; + // Keep this renderer local. `marked.use` mutates a shared singleton and + // would otherwise inherit renderers installed by the chunk-content view. + const rawHtml = marked.parse(safeText, { renderer }) as string; markdownHtml.value = sanitizeHTML(rawHtml); }