71

I cannot find how to insert a line break in long titles inside nodes. For example:

library(DiagrammeR) 
mermaid("
graph TB
     A[GE Solution]-->C{ }
     B[GA Solution]-->C{ } 
     C{ }-->D[Stir 10 mins at 500 r/min]
     D[Stir 10 mins at 500 r/min]-->E[Homogenisation at 10000 r/min]
     E[Homogenisation at 10000 r/min]-->F(Stir 10 min 450 r/min Complex coacervation)
      ")

Note node F is too long. How to I make it into sth like..?

|Stir 10 min 450 r/min|
|Complex coacervation |

Note \n doesn't work.

0

2 Answers 2

117

It appears you can use <br> instead:

mermaid("
graph TB
        A[GE Solution]-->C{ }
        B[GA Solution]-->C{ } 
        C{ }-->D[Stir 10 mins at 500 r/min]
        D[Stir 10 mins at 500 r/min]-->E[Homogenisation at 10000 r/min]
        E[Homogenisation at 10000 r/min]-->F(Stir 10 min 450 r/min <br> Complex  coacervation)
        ")

enter image description here

4
  • 2
    On the nail! I couldn't find this in the instructions. thnx
    – Scientist
    Jul 16, 2018 at 17:19
  • 3
    Also when saving SVG and opening in a browser it is complaining about missing <br> close tag, <br/> looks to be more appropriate but it's saved as <br> anyways maybe it's a mermaid bug
    – Aleksei
    Jan 3, 2020 at 19:27
  • 1
    @Aleksei Good call out, see: stackoverflow.com/questions/1946426/html-5-is-it-br-br-or-br
    – Hack-R
    Nov 12, 2021 at 21:16
  • 1
    how about mermaid's ER diagrams' comment Sep 28, 2022 at 15:00
5

Another answer that appears to work just fine is to use \n rather than <br>.

3
  • 4
    It doesn't work. Either present an example as how you are using it or share a link explaining your answer in detail. Dec 28, 2022 at 10:57
  • 1
    \n does not work at participant in flowcharts. <br> works though.
    – koppor
    Feb 16 at 8:52
  • I am using Mermaid via Markdown Viewer (a Chrome Extension), neither work to produce line break. But it works when I push it to GitHub. Perhaps in my case is implementation in the extension.
    – dudung
    Mar 26 at 12:00

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.