Files
董宏凯andCursor 7c15ca6710 fix: show sandbox flowcharts on Win7 Chrome and repair common Mermaid syntax
Disable HTML labels so nodes use native SVG text, and rewrite bare edge labels plus invalid class statements before render.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-30 09:05:29 +08:00

56 lines
1.9 KiB
TypeScript

import rehypeKatex from "rehype-katex";
import rehypeRaw from "rehype-raw";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import type { StreamdownProps } from "streamdown";
import { rehypeSplitWordsIntoSpans } from "../rehype";
import { SANDBOX_MERMAID_CONFIG } from "../utils/mermaid";
import { remarkSanitizeMermaid } from "./remark-sanitize-mermaid";
export const streamdownPlugins = {
remarkPlugins: [
remarkGfm,
[remarkMath, { singleDollarTextMath: true }],
remarkSanitizeMermaid,
] as StreamdownProps["remarkPlugins"],
rehypePlugins: [
rehypeRaw,
[rehypeKatex, { output: "html" }],
] as StreamdownProps["rehypePlugins"],
mermaidConfig: SANDBOX_MERMAID_CONFIG,
};
export const streamdownPluginsWithWordAnimation = {
remarkPlugins: [
remarkGfm,
[remarkMath, { singleDollarTextMath: true }],
remarkSanitizeMermaid,
] as StreamdownProps["remarkPlugins"],
rehypePlugins: [
[rehypeKatex, { output: "html" }],
rehypeSplitWordsIntoSpans,
] as StreamdownProps["rehypePlugins"],
};
// Plugins for reasoning/thinking content — derived from streamdownPlugins but without rehypeRaw,
// to prevent LLM-hallucinated HTML tags (e.g. <simd>) from being rendered as DOM elements.
export const reasoningPlugins = {
remarkPlugins: streamdownPlugins.remarkPlugins,
rehypePlugins: streamdownPlugins.rehypePlugins?.filter(
(p) => p !== rehypeRaw,
) as StreamdownProps["rehypePlugins"],
};
// Plugins for human messages - no autolink to prevent URL bleeding into adjacent text
export const humanMessagePlugins = {
remarkPlugins: [
// Use remark-gfm without autolink literals by not including it
// Only include math support for human messages
[remarkMath, { singleDollarTextMath: true }],
] as StreamdownProps["remarkPlugins"],
rehypePlugins: [
[rehypeKatex, { output: "html" }],
] as StreamdownProps["rehypePlugins"],
};