35

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

1 Answer 1

47

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

3
  • 2
    On the nail! I couldn't find this in the instructions. thnx
    – Scientist
    Jul 16, 2018 at 17:19
  • 2
    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
  • @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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