-
@@ -164,20 +163,15 @@ const mentionedItems = computed(() => {
return props.session?.mentioned_items || [];
});
-const markdownTokens = computed(() => {
+// 单次渲染整个 Markdown 内容(替代 token-by-token,修复 KaTeX 公式在 streaming 时闪烁消失的问题)
+const renderedHTML = computed(() => {
const text = props.content || props.session?.content || '';
- if (!text || typeof text !== 'string') {
- return [];
- }
-
+ if (!text || typeof text !== 'string') return '';
const processed = replaceIncompleteImageWithPlaceholder(text);
const safeText = preprocessMathDelimiters(processed);
-
- // 首先对 Markdown 内容进行安全处理
const safeMarkdown = safeMarkdownToHTML(safeText);
-
- // 使用 marked.lexer 分词
- return marked.lexer(safeMarkdown);
+ const html = marked.parse(safeMarkdown, { renderer: customRenderer, breaks: true });
+ return sanitizeHTML(html);
});
// 计算属性:判断是否有实际内容(非空且不只是空白)
@@ -186,27 +180,6 @@ const hasActualContent = computed(() => {
return text && text.trim().length > 0;
});
-// 渲染单个 token 为 HTML
-const renderToken = (token) => {
- try {
- // 创建临时的 marked 配置
- const markedOptions = {
- renderer: customRenderer,
- breaks: true
- };
-
- // 解析单个 token
- // marked.parser 接受 token 数组
- let html = marked.parser([token], markedOptions);
-
- // 使用 DOMPurify 进行最终的安全清理
- return sanitizeHTML(html);
- } catch (e) {
- console.error('Token rendering error:', e);
- return '';
- }
-};
-
// 获取实际内容
const getActualContent = () => {
return (props.content || props.session?.content || '').trim();
diff --git a/frontend/src/views/dev/MarkdownTestPage.vue b/frontend/src/views/dev/MarkdownTestPage.vue
new file mode 100644
index 00000000..82c417aa
--- /dev/null
+++ b/frontend/src/views/dev/MarkdownTestPage.vue
@@ -0,0 +1,479 @@
+
+
+
Markdown Rendering Test
+
+ Dev-only page for visual regression testing of markdown / LaTeX / Mermaid rendering.
+ Add new test cases or paste arbitrary markdown in the editor below.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Lists & Blockquotes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Custom Input
+ Paste any markdown here to test rendering.
+
+
+
+
+
+
+
+
+