Mermaid diagrams rendered in GitHub UI not recognising <br> tags
#204537
Replies: 3 comments 3 replies
|
I couldn't reproduce this on github.com as of today — your exact edge label renders with the line break — so the cause is likely more specific than "GitHub doesn't recognise What I tested (all of these render the break correctly right now):
Some background on why this works at all, because it explains your symptom: GitHub renders Mermaid inside a sandboxed iframe with Given that github.com currently renders it fine, the likely candidates are:
Independent of the cause, there's a workaround that doesn't rely on HTML tags at all — Mermaid "markdown strings" (double quotes + backticks) support literal newlines, and Test 3 in the file above shows it rendering on GitHub: If you can share which surface you're seeing this on (github.com vs Enterprise Server, and file preview / README / wiki / gist), that should narrow it down quickly. |
|
Great pointer — that let me corner it properly. You're right, and I can now reproduce the difference: the same bytes render differently depending on which page they're on. I copied examples.md verbatim into my test repo (repro-full.md) — there, every So I diffed what the two pages actually ship. GitHub doesn't render mermaid server-side — the page HTML carries the diagram source in a
The current renderer sanitizes raw HTML tags out of label text (tags get deleted, not displayed — which is exactly why you get Why would two pages embed differently? The rendered-markdown HTML is cached per blob. Practical fallout:
And if you want to check any given page in 10 seconds: inspect a diagram, find the |
|
That result is worth sitting with, because it falsifies the per-blob staleness theory as stated: if a fresh commit to the exact line containing The next cheap thing to check, before reaching for a new theory, is whether the server actually re-rendered anything at all. Same method Codebater used earlier: on the freshly committed page, find the One more targeted test that would distinguish those two: instead of editing text near the If my answer was helpful to you, please consider marking it as the correct answer, thanks. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Bug
💬 Feature/Topic Area
Other
Body
When viewing Mermaid diagrams rendered in the GitHub UI (which include excerpts like the below) then I expect it to recognise the
<br>tags.With the above example, I expect the diagram to be rendered with a line break between "1" and "GET /users/{userId}":
Instead, there was no line break (or even a space), resulting in the content being rendered as a continuous line:
The issues does not affect https://mermaid.live, indicating that it is specific to GitHub.
The issue was not present on Fri 07 Aug 2026 but had become present by Mon 10 Aug 2026 (08:32 UTC).
This link https://github.com/mermaid-js/mermaid/blob/develop/docs/syntax/examples.md includes
di{Diamond with <br/> line break}but the resultant diagram does not include the line break.All reactions