Skip to content

Commit ffd4dae

Browse files
committed
fix(parser): support Mermaid v11 subgraph IDs and parse newlines correctly
1 parent 7849b48 commit ffd4dae

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/parser/flowchart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const parseSubGraph = (
200200

201201
// Get position
202202
const el: SVGSVGElement | null = containerEl.querySelector(
203-
`[id='${data.id}']`
203+
`[id*='${data.id}']`
204204
);
205205
if (!el) {
206206
throw new Error("SubGraph element not found");

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export const entityCodesToText = (input: string): string => {
88
// eg #9829; => ♥
99
const inputWithDecimalCode = input
1010
.replace(/#(\d+);/g, "&#$1;")
11-
.replace(/#([a-z]+);/g, "&$1;");
11+
.replace(/#([a-z]+);/g, "&$1;")
12+
.replace(/\\n/g, "\n")
13+
.replace(/<br\s*\/?>/gi, "\n");
1214

1315
// Render the decimal code as html character, eg &#9829; => ♥
1416
const element = document.createElement("textarea");

0 commit comments

Comments
 (0)