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

Handle br tag in flowchart the same way as in sequenceDiagram (especially when exporting to SVG) #1111

Closed
etimau opened this issue Dec 3, 2019 · 12 comments
Assignees
Labels

Comments

@etimau
Copy link

etimau commented Dec 3, 2019

When using <br> in a sequenceDiagram, when exported to SVG, it is translated to <text></text> tags.
See this example

Is it possible to have the same behavior in flowcharts?
If you try this and click on "Download SVG", the result has a parse XML error because of the <br> tag.
Idem if the <br> is inside of a node.

@etimau etimau added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Dec 3, 2019
@GDFaber
Copy link
Member

GDFaber commented Dec 14, 2019

I can take a look here, because I'm also interested in #702 which is about line breaks in sequence diagrams.

@klemmchr klemmchr added Area: Development Graph: Flow Status: Approved Is ready to be worked on and removed Status: Triage Needs to be verified, categorized, etc labels Dec 15, 2019
@klemmchr
Copy link
Member

I can take a look here, because I'm also interested in #702 which is about line breaks in sequence diagrams.

Great! Make sure to make two separate prs for these issues.

@GDFaber
Copy link
Member

GDFaber commented Dec 23, 2019

This can be solved by turning <br> into <br/> to have all tags closed in the label text. I will work on this after #1156 has been merged (because it modifies the regex for line breaks in flowRenderer.js and it seems like I need to modify the same code block as well).

@GDFaber
Copy link
Member

GDFaber commented Jan 1, 2020

This can be solved by turning <br> into <br/> to have all tags closed in the label text.

This won't do much because browsers (at least Chrome) tend to turn <br/> back into <br> in order to produce HTML instead of XHTML (if not explicitly set by doctype). I guess that's also why #614 didn't work for all use cases.

I also tried to wrapping the texts in div-Blocks and replacing the line breaks by </div><div>. This works for security level "strict" but has a drawback in case of "loose": If the html text already includes its own div-Blocks, they might get broken by this approach. I think it cannot be done that way either.

@GDFaber
Copy link
Member

GDFaber commented Jan 1, 2020

Turns out, it already works if htmlLabels is set to false in the flowchart configuration. That's because with this setting the text lines get split up into <text> blocks just as @etimau suggested in the first place.

Is that good enough to work with, or do we need more here?

@etimau
Copy link
Author

etimau commented Jan 2, 2020

Hi and thanks for you answer and best wishes for 2020!

Maybe I'm doing it wrong but, when I turn htmlLabels to false, I don't get a line breaks but I see the <br/> tag in the text...

Furthermore, the rendering is a bit messy.
Here is the rendering with htmlLabels set to true:
htmlLabelsTrue
(You can also see it here)

Here is the same graph when htmlLabels is set to false:
htmlLabelsFalse

@GDFaber
Copy link
Member

GDFaber commented Jan 2, 2020

Hi, I also wish you all the best for 2020 :)

Thank you for posting the example, and pardon me, I forgot to say that I tried this on a yet unreleased state of the flowchart renderer which will be included in an upcoming release.

I built from the develop branch of the mermaid repository, which produces the following output for your example graph (used another color theme though):

2020-01-02 16_55_31-Mermaid Quick Test Page

Edit: updated the image

@GDFaber
Copy link
Member

GDFaber commented Jan 2, 2020

The issues with style classes which you mentioned (for example in node ".fic1") may be connected to issue #487 as there is currently no support to change the text color by mermaid style classes, and setting color unfortunately only works with HTML labels activated (which is because there is no color attribute in SVG to style a text node; instead you would have to use fill on the text tag, which is not possible at the moment).

@etimau
Copy link
Author

etimau commented Jan 3, 2020

Thanks for those informations. I will check when the new version will be available.
Just one detail: the text over the links is not centered anymore in the new renderer version. Will there be a way to center it?

@GDFaber
Copy link
Member

GDFaber commented Jan 6, 2020

the text over the links is not centered anymore

At the moment multiline texts are not centered if html labels are disabled. Thanks for pointing that out, I have opened a new issue to get the texts centered for non-html labels as well: #1177

@GDFaber
Copy link
Member

GDFaber commented Feb 4, 2020

Hi @etimau, feel free to ask if you need further information on this topic.
If you feel like your questions have been answered, would you agree to close this issue?

@GDFaber
Copy link
Member

GDFaber commented Feb 16, 2020

I think we can close this issue, feel free to open a new one if you run into problems.

@GDFaber GDFaber closed this as completed Feb 16, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants