I have such a graphviz dot file test.dot
, contains a node with TABLE label:
digraph {
node [shape=none, fontname="Courier New, Courier"]
edge [fontname="Courier New, Courier"]
graph [fontname="Courier New, Courier"]
id2765 [label=<<TABLE CELLBORDER="1" CELLSPACING="0" BORDER="0">
<TR><TD PORT="cell756">literal</TD><TD PORT="cell757" ALIGN="LEFT">"""--- multiple line string literal with unicode ---
here we begin with some comments \\u0020 \\U00000000 \\u1234 \\u20AC \\U00008000:
multiple string literal begins and ends with triple quotes \\"\\"\\",
then newline are enabled in it.
here we test back slask \\r\\n \\' \\" \\? \\a \\b \\f \\n \\r \\t \\v \\\\.
"""</TD></TR>
</TABLE>>]
}
Please notice that I want the node contains multiple line text literal:
"""--- multiple line string literal with unicode ---
here we begin with some comments \\u0020 \\U00000000 \\u1234 \\u20AC \\U00008000:
multiple string literal begins and ends with triple quotes \\"\\"\\",
then newline are enabled in it.
here we test back slask \\r\\n \\' \\" \\? \\a \\b \\f \\n \\r \\t \\v \\\\.
"""
Compile with dot -Tpng test.dot -o test.dot.png
, its output:
You can see that there's no new line in text literal. So I updated test.dot
with ALIGN="LEFT"
and <BR/>
:
digraph {
node [shape=none, fontname="Courier New, Courier"]
edge [fontname="Courier New, Courier"]
graph [fontname="Courier New, Courier"]
id2765 [label=<<TABLE CELLBORDER="1" CELLSPACING="0" BORDER="0">
<TR><TD PORT="cell756">literal</TD><TD PORT="cell757" ALIGN="LEFT">"""--- multiple line string literal with unicode ---<BR/>here we begin with some comments \\u0020 \\U00000000 \\u1234 \\u20AC \\U00008000:<BR/> multiple string literal begins and ends with triple quotes \\"\\"\\",<BR/> then newline are enabled in it.<BR/> here we test back slask \\r\\n \\' \\" \\? \\a \\b \\f \\n \\r \\t \\v \\\\.<BR/> """</TD></TR>
</TABLE>>]
}
Compile again, its output:
There's new linebreak, but the text is center aligned, while I want left aligned.
How to left align multiple line text literal in TABLE label of graphviz dot node ?
add ALIGN="LEFT"
to each <BR/>
and BALIGN="LEFT"
to the <TD ...>
like so:
digraph {
node [shape=none, fontname="Courier New, Courier"]
edge [fontname="Courier New, Courier"]
graph [fontname="Courier New, Courier"]
id2765 [label=<<TABLE CELLBORDER="1" CELLSPACING="0" BORDER="0">
<TR><TD PORT="cell756">literal</TD><TD PORT="cell757" ALIGN="LEFT" BALIGN="LEFT">"""--- multiple line string literal with unicode ---<BR ALIGN="LEFT"/>here we begin with some comments \\u0020 \\U00000000 \\u1234 \\u20AC \\U00008000:<BR ALIGN="LEFT"/> multiple string literal begins and ends with triple quotes \\"\\"\\",<BR ALIGN="LEFT"/> then newline are enabled in it.<BR ALIGN="LEFT"/> here we test back slask \\r\\n \\' \\" \\? \\a \\b \\f \\n \\r \\t \\v \\\\.<BR ALIGN="LEFT"/> """</TD></TR>
</TABLE>>]
}