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>
This commit is contained in:
1 parent
31cfa93408
commit
7c15ca6710
6 files changed
+196
-5
No files matched your search
@@ -5,22 +5,27 @@ 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" }],
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { visit } from "unist-util-visit";
|
||||
|
||||
import { sanitizeMermaidSource } from "../utils/mermaid";
|
||||
|
||||
type MermaidCodeNode = {
|
||||
lang?: string | null;
|
||||
value: string;
|
||||
};
|
||||
|
||||
export function remarkSanitizeMermaid() {
|
||||
return (tree: unknown) => {
|
||||
visit(tree as never, "code", (node: MermaidCodeNode) => {
|
||||
const lang = (node.lang ?? "").toLowerCase();
|
||||
if (lang !== "mermaid" && lang !== "mmd") return;
|
||||
node.value = sanitizeMermaidSource(node.value);
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user