Commit 006ba3b8 by archer

fix: mermaid

parent 5a534aa6
...@@ -27,7 +27,29 @@ const MermaidBlock = ({ code }: { code: string }) => { ...@@ -27,7 +27,29 @@ const MermaidBlock = ({ code }: { code: string }) => {
useEffect(() => { useEffect(() => {
try { try {
const formatCode = code.replace(/:/g, ':'); const punctuationMap: Record<string, string> = {
',': ',',
';': ';',
'。': '.',
':': ':',
'!': '!',
'?': '?',
'“': '"',
'”': '"',
'‘': "'",
'’': "'",
'【': '[',
'】': ']',
'(': '(',
')': ')',
'《': '<',
'》': '>',
'、': ','
};
const formatCode = code.replace(
/([,;。:!?“”‘’【】()《》、])/g,
(match) => punctuationMap[match]
);
mermaidAPI.render(`mermaid-${Date.now()}`, formatCode, (svgCode: string) => { mermaidAPI.render(`mermaid-${Date.now()}`, formatCode, (svgCode: string) => {
setSvg(svgCode); setSvg(svgCode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment