Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Error diagram rendering #1288

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/lib/util/mermaid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ export const render = async (
): Promise<RenderResult> => {
// Should be able to call this multiple times without any issues.
mermaid.initialize(config);
return await mermaid.render(id, code);

try {
const result = await mermaid.render(id, code);
return result;
} catch {
const errorDiv = document.querySelector(`#d${id}`);
const svg = errorDiv?.innerHTML ?? '';
errorDiv?.remove();
return {
svg,
bindFunctions: undefined
};
}
};

export const parse = async (code: string): Promise<unknown> => {
Expand Down