Skip to content

Commit

Permalink
Attempt to disable weird Mermaid errorRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Sep 14, 2023
1 parent b0d2d98 commit 13d5b70
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/docusaurus-theme-mermaid/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ async function renderMermaid({
*/
mermaid.mermaidAPI.initialize(config);

return mermaid.render(id, text);
try {
return await mermaid.render(id, text);
} catch (e) {
// Because Mermaid add a weird SVG/Message to the DOM on error
// https://github.com/mermaid-js/mermaid/issues/3205#issuecomment-1719620183
document.querySelector(`#d${id}`)?.remove();
throw e;
}
}

export function useMermaidRenderResult({
Expand Down

0 comments on commit 13d5b70

Please sign in to comment.