Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(frontend): isolate markdown preview renderers
jacentsao398b4b31ef0e
diff --git a/frontend/src/components/doc-content.vue b/frontend/src/components/doc-content.vueindex 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;// 还原被转义的 <br>html = html.replace(/<br\s*\/?>/gi, '<br>');diff --git a/frontend/src/components/document-preview.vue b/frontend/src/components/document-preview.vueindex 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 `<pre><code class="hljs">${highlighted}</code></pre>`;};- 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);}