mermaid icon indicating copy to clipboard operation
mermaid copied to clipboard

allow new line when writing mermaid

Open LuisBL opened this issue 3 years ago • 6 comments


flowchart TB
  a["Proin_elementum_magna"] --> b["quis_enim_porta_congue<br>Orci_varius_natoque"] \
  c["penatibus_et_magnis_dis"] -->                                                  \
  e["parturient_montes_<br>                                                         \
     nascetur_ridiculus_mus.<br>                                                    \
     Vivamus eu_eros vitae<br>                                                      \
     risus_fringilla_sagittis."]

Today we have to write


flowchart TB
  a["Proin_elementum_magna"] --> b["quis_enim_porta_congue<br>Orci_varius_natoque"]  c["penatibus_et_magnis_dis"] --> e["parturient_montes_<br> nascetur_ridiculus_mus.<br> Vivamus  eu_eros vitae<br> risus_fringilla_sagittis."]

LuisBL avatar Oct 22 '21 07:10 LuisBL

"\" to continue line could be a good solution

LuisBL avatar Oct 22 '21 07:10 LuisBL

you can use \n instead of <br>

lenicyl avatar Dec 01 '21 08:12 lenicyl

you can use \n instead of <br>

The request here is not to have new lines in mermaid rendering but to allow to have some \ line continue writing the source coden to have a more easy to read code

LuisBL avatar Sep 03 '22 15:09 LuisBL

You could always do something like this:

flowchart TB
  a["
  Proin_elementum_magna"] --> b["
  quis_enim_porta_congue<br>Orci_varius_natoque"]  
  c["
  penatibus_et_magnis_dis"] --> e["
  parturient_montes_<br> nascetur_ridiculus_mus.<br> Vivamus  eu_eros vitae<br> risus_fringilla_sagittis."]

jgreywolf avatar Aug 28 '23 12:08 jgreywolf

Now that I am re-reading this - I am confused. Where are you creating diagrams that you need to do everything on one line? Because this:

flowchart TB
  a["Proin_elementum_magna"] --> b["quis_enim_porta_congue<br>Orci_varius_natoque"]
  c["penatibus_et_magnis_dis"] -->                                                 
  e["parturient_montes_<br>                                                        
     nascetur_ridiculus_mus.<br>                                                   
     Vivamus eu_eros vitae<br>                                                     
     risus_fringilla_sagittis."]

Works fine

https://mermaid.ink/svg/pako:eNqdks9OwkAQxl-lmXMh0GKBxnAwXo0mGg9asxnaaZmkuwv7B0XCuztFfACZ02Zmvt982Zkj1LYhKKHt7We9QReSl7vKJAm-V_DkLBtFPWkyIWqlsTNYwUcyGq2StTTsIntFhrXaWhdQ1dZ0kW7XbvXoalZ7dBy9MhjsLpIIB3Atui1JjtdSo3CmCqZh_4f-bwxYGrBiPzoWs0pbE8irwUpyZQxUCYO-JsEqxw3XsRfTOvrxleQL9JX3KJSEoiJnfbLngHS12QvUsRdzrWPTcd-j8thxCOzH8q-QgiankRvZ9XEQVBA2stgKSnk21GLsQwWVOUkrxmCfD6aGMrhIKcRtg4HuGTuHGsoWey_ZLRooj_AFZVaMs2K-mOTTZTbNF8U8S-EA5TSbjZezeZEvZ8VNnmeT_JTCt7WCmKZADQfrHn7P73yFZ-TbuT7MPf0AbjS1iQ

jgreywolf avatar Oct 04 '23 12:10 jgreywolf

It seems that sequence diagram notes is one place where newlines can't be used within quotations.

What works:

sequenceDiagram
    participant A
    participant B

    Note over A: Required variables: <br/> source id <br/> target id <br/> user <br/> group <br/> origin
    A->>B: make_request()

What I'd actually like to use:

sequenceDiagram
    participant A
    participant B

    Note over A: "
      Required variables: <br/>
      source id <br/>
      target id <br/>
      user <br/>
      group <br/>
      origin"
    A->>B: make_request()

I love the idea of mermaid diagrams - to have easily editable graphical content within markdown documentation. However, not being able to use line breaks in the source code makes any diagram that's a bit more complex very hard to read and manage, which kind of beats the original purpose.

martroben avatar Apr 22 '24 13:04 martroben