Search code examples
visualizationgraphviz

graphviz MRecord spanning multiple lines - cannot reproduce?


So, I've seen Records spanning over multiple lines in graphviz and I tried to come up with a simpler test - which ended up being this:

graph G{
A11[ shape = Mrecord, label="A.11 Access Control|"+
"aa"];
}

So, I tried to test this online - ironically, the plotter recommended by https://graphviz.org themselves, which is http://magjac.com/graphviz-visual-editor/, fails on this example with Expected ",", ";", "<", "\"", "]", NUMBER or UNICODE_STRING but "+" found.:

magjac graphviz

... however, if I plot using Kroki https://kroki.io/#try - then it works?!

kroki graphviz

So, my questions are:

  • Is this way of "splitting lines" in graphviz supported for some versions, and not for others? Or what other mistake could I have made?
  • If versioning is the problem, how do I get to know which graphviz versions support this kind of "line splitting" - and how do I get to know, if this or that online plotter, supports this kind of line splitting (aside from pasting the example and letting it pass or fail)?

Solution

  • The bug is in "Graphviz Visual Editor" (provided by a Graphviz developer, but not part of the Graphviz package).
    Using the command line dot, both versions of the concatenation syntax work.

    From the language spec (https://graphviz.org/doc/info/lang.html):

    As another aid for readability, dot allows double-quoted strings to span  
    multiple physical lines using the standard C convention of a backslash  
    immediately preceding a newline character². In addition, double-quoted  
    strings can be concatenated using a '+' operator. 
    

    If you want/need to use the "Graphviz Visual Editor", this works:

    graph G{
    //  use backslash (\) at end-of-line
    //    note, no internal double-quotes (")
    B11[ shape = Mrecord, label="B.11 Access Control|\
    BBB"];
    }
    

    Giving:
    enter image description here