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 Line Break doesn't seem to work in Diagram #230

Open
psheehymn opened this issue Jun 1, 2022 · 3 comments
Open

Mermaid Line Break doesn't seem to work in Diagram #230

psheehymn opened this issue Jun 1, 2022 · 3 comments

Comments

@psheehymn
Copy link

psheehymn commented Jun 1, 2022

I have a diagram with several boxes with long text that I would like to break in the middle to create taller, narrower boxes. Several references (https://jojozhuang.github.io/tutorial/mermaid-cheat-sheet/ for one) indicate to use break symbols (<br> and <br/>) to split long lines of text in Mermaid. These also work in the Mermaid Live Editor (https://mermaid.live/).

However, it does not have the desired effect in the Grafana Diagram plugin; the break symbol shortens the box, but the text is not split. Please see the attached images for examples of what occurs both without and with the break symbols. Both forms appears to be recognized, as they both shorten the respective boxes.

We are running Grafana v8.4.7 and Diagram v1.7.3.

NoBreaks
WithBreaks
.

@OscarVanL
Copy link

OscarVanL commented Nov 26, 2022

It looks like it strips out all HTML in the node's text, I have some <img> tags which render fine, but when I then add a metric to the node it gets rid of the image.

@OscarVanL
Copy link

I have a disgusting hack to get this to work!

If you put the escaped symbols for the desired HTML formatting inside the Mermaid diagram definition, then once you apply the metric onto that node, then it'll un-escape the HTML and the HTML will work again.

In your example, you wanted the name to be Post-Initial<br>Page Refresh. If you set this as Post-Initial&ltbr&gtPage Refresh then once you apply the metric it'll render how you wanted.

This falls apart if you have long HTML content, for instance, say you had an image on the node: "&ltimg src='https://www.mywebsite.com/image.png'; width='30';&gtbr NodeName", then Mermaid will end up rendering a reeeeeaally wide node expecting that the HTML tag was actually the text inside the node. So it's only really applicable for cases like yours.

@psheehymn
Copy link
Author

Thanks, I will try this.

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

No branches or pull requests

2 participants