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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mermaid diagram rendering issue with new line characters (\n , <br>..etc) #1632

Closed
thomasmebin opened this issue Aug 30, 2023 · 3 comments · Fixed by #1646
Closed

Mermaid diagram rendering issue with new line characters (\n , <br>..etc) #1632

thomasmebin opened this issue Aug 30, 2023 · 3 comments · Fixed by #1646
Labels
🐞 bug Something isn't working 🙃 upstream

Comments

@thomasmebin
Copy link

thomasmebin commented Aug 30, 2023

I have a mermaid diagram, it was rendering fine till now, seems to be after the latest upgrade, my diagram is broken or not rendering properly.

Diagram code below,

flowchart LR
phase_1([App 1])-->|App event|phase_2(App2 )-->|App event|phase_3(App 2 \n App 3 \n App 4)-->|App event|phase_4[(App 5)]-->|App event|phase_5([Final app])

Seems to be the "\n , < br>..etc" causing issues here.

Error while trying the url,

image

Same time when I try my code in the kroki site Try section, diagram is rendering as expected.

image

But the url generated in the same page showing issue,

https://kroki.io/mermaid/svg/eNpLy8kvT85ILCpR8AniKshILE6NN9SIdiwoUDCM1dTVtasBMVPLUvNKaiCyRhpAESMFrHLGIDkFI4WYmDwFEMtYwSapyA7MNMGqwSQarMNUMxabrKlGtFtmXmKOQmJBQawmFxAAAKfbOGk=

@ggrossetie
Copy link
Member

We had a similar issue with <br> and Mermaid had/has some issues with it: mermaid-js/mermaid#1766
Since I can reproduce this issue, I will try to find a workaround/fix.

@ggrossetie ggrossetie added the 🐞 bug Something isn't working label Sep 1, 2023
@mgzob
Copy link

mgzob commented Sep 20, 2023

I also experience this when rendering svg files, but if I change the format to png then at least the image generates. Ref your modified link with png:

https://kroki.io/mermaid/png/eNpLy8kvT85ILCpR8AniKshILE6NN9SIdiwoUDCM1dTVtasBMVPLUvNKaiCyRhpAESMFrHLGIDkFI4WYmDwFEMtYwSapyA7MNMGqwSQarMNUMxabrKlGtFtmXmKOQmJBQawmFxAAAKfbOGk=

Note this does result in a manifestation of issue #1641 where the intermediary arrow text does not receive a bounding box.

@ggrossetie
Copy link
Member

This is indeed an upstream issue where SVG is using XHTML but Mermaid produces HTML (i.e., using <br> instead of <br/>). As a workaround, you can use the following option: flowchart.htmlLabels=false:

https://kroki.io/mermaid/svg/eNpLy8kvT85ILCpR8AniKshILE6NN9SIdiwoUDCM1dTVtasBMVPLUvNKaiCyRhpAESMFrHLGIDkFI4WYPAUQwxjGMMGq2iQarNxUMxabrKlGtFtmXmKOQmJBQawmACcjN2E=?flowchart_html-labels=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🙃 upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants