-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Generated SVG works poorly outside web browsers #58
Comments
Instead of html labels we should try to use text elements with tspan elements inside for this. For instance, the generated code with html labels are:
Instead the text should be represented by something like this:
|
Yes, that seems to be the standard way in SVG. Will look into this when I am finished with the issue #24. |
foreignObject apperantly also breaks functionality of converting SVG -> Canvas -> PNG image |
As another hopefully helpful reference, here is how Thanks so much @knsv for such fine work. We are making it into an |
Thanks @timelyportfolio, that looks cool! However, mermaid builds on dagre-d3 to generate the SVG content, including the text labels. It would be more natural to incorporate this kind of text wrapping support into dagre-d3 instead. The work I have in progress on the labels is to support both label variants of dagre-d3 - HTML version and SVG version. If dagre-d3 is improved, we can then make use of that directly in mermaid. |
This has been included in release 0.3.3 |
@knsv cool! |
It is avaiable using npm/bower or from download (cdn) rihght now. If you are making a tool with user input you might want to take a look at the errorHandling/syntax check api in 0.3.3: Error handlingWhen the parser encounters invalid syntax the mermaid.parseError function is called. It is possible to override this function in order to handle the error in an application specific way. Parsing text without renderingIt is also possible to validate the syntax before rendering in order to streamline the user experience. The function mermaid.parse(txt) takes a text string as an argument and returns true if the text is syntactically correct and false if it is not. The parseError function will be called when the parse function returns false. The code-example below in meta code illustrates how this could work:
|
Played with 0.3.3 Secondly lines reported in parseError are weird. Like in
It reports:
So error on line 9 in file of 5 lines. |
Hello! Are you sure that the actual character are not in fact > that is an escaped code for > and renders to > in the browser? When I copy the text from your email to my test page which is using 0.3.3 it renders fine so the syntax is ok. I hope this gives you some help. Knut Sveidqvist On Wednesday 28 January 2015 at 21:40, wonderwhy-er wrote:
|
Is this issue resolved? With v0.3.3 I observe foreignObject(s) in generated graphs, but not sequence diagrams. Graph layouts seems to be sensitive to css fonts a line heights settings. Some replacements of foreign objects is still going on here. |
For the flowChart graph type, a configuration setting is required to generate SVGs without foreignObject. Set htmlLabels to false in the mermaid config to enable that. Granted this need to get into the wiki. |
I will try out the configuration setting. Thanks a lot for clarification. |
The generated SVG contains text encapsulated inside foreignObject elements. Inside the foreignObjects, there are divs to handle text with linebreaks. However, divs doesn't display in other SVG viewers than web browsers.
A related issue is the <br> tags for linebreaks. Those are invalid in XML. They could be replaced by <br/> to allow the SVG to be opened outside web browsers, but the text will still not be rendered.
The text was updated successfully, but these errors were encountered: