From 2cd1207e730531a13ebed4d1b0393156cf00613c Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 3 Sep 2024 15:39:09 +0200 Subject: [PATCH] fix: mermaid error on rating --- src/lib/components/chat/Messages/CodeBlock.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/Messages/CodeBlock.svelte b/src/lib/components/chat/Messages/CodeBlock.svelte index 35d967b6b..fdd8d3488 100644 --- a/src/lib/components/chat/Messages/CodeBlock.svelte +++ b/src/lib/components/chat/Messages/CodeBlock.svelte @@ -217,8 +217,10 @@ __builtins__.input = input`); const drawMermaidDiagram = async () => { try { - const { svg } = await mermaid.render(`mermaid-${uuidv4()}`, code); - mermaidHtml = svg; + if (await mermaid.parse(code)) { + const { svg } = await mermaid.render(`mermaid-${uuidv4()}`, code); + mermaidHtml = svg; + } } catch (error) { console.log('Error:', error); }