Skip to content

fix(parser): support Mermaid v11 subgraph IDs and parse newlines correctly#98

Open
tamld wants to merge 1 commit intoexcalidraw:masterfrom
tamld:fix/mermaid-v11-subgraphs-newlines
Open

fix(parser): support Mermaid v11 subgraph IDs and parse newlines correctly#98
tamld wants to merge 1 commit intoexcalidraw:masterfrom
tamld:fix/mermaid-v11-subgraphs-newlines

Conversation

@tamld
Copy link
Copy Markdown

@tamld tamld commented Apr 24, 2026

Description

This PR addresses two compatibility bugs when parsing Mermaid v11 flowcharts into Excalidraw:

  1. Subgraph IDs: Mermaid v11 injects a flowchart- prefix into subgraph DOM IDs (e.g., flowchart-sub1-52), which caused the exact match [id='...'] in src/parser/flowchart.ts to fail. This is fixed by using a substring match [id*='...'].
  2. Text Newlines: The parser was not properly interpreting \\n and <br> tags inside Mermaid element labels. entityCodesToText in src/utils.ts has been updated to translate these tags into real newlines, ensuring text wraps correctly inside Excalidraw shapes instead of squashing onto a single line.

Motivation

When working with AAOS and programmatic diagram generation, complex subgraphs and multiline labels are essential. This ensures the output remains as editable native shapes rather than falling back to an uneditable SVG image blob.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

@tamld is attempting to deploy a commit to the Excalidraw Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant