如何在 graphviz 点节点的 TABLE 标签中左对齐多行文本文字?
How to left align multiple line text literal in TABLE label of graphviz dot node?
我有这样一个 graphviz 点文件 test.dot
,包含一个带有 TABLE 标签的节点:
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>>]
}
请注意,我希望节点包含多行文本文字:
"""--- 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 \\.
"""
用dot -Tpng test.dot -o test.dot.png
编译,其输出:
您可以看到文本文字中没有新行。所以我用 ALIGN="LEFT"
和 <BR/>
:
更新了 test.dot
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>>]
}
再次编译,输出:
有新的换行符,但文本居中对齐,而我想要左对齐。
如何在 graphviz 点节点的 TABLE 标签中左对齐多行文本文字?
将 ALIGN="LEFT"
添加到每个 <BR/>
并将 BALIGN="LEFT"
添加到 <TD ...>
,如下所示:
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>>]
}
给予:
我有这样一个 graphviz 点文件 test.dot
,包含一个带有 TABLE 标签的节点:
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>>]
}
请注意,我希望节点包含多行文本文字:
"""--- 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 \\.
"""
用dot -Tpng test.dot -o test.dot.png
编译,其输出:
您可以看到文本文字中没有新行。所以我用 ALIGN="LEFT"
和 <BR/>
:
test.dot
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>>]
}
再次编译,输出:
有新的换行符,但文本居中对齐,而我想要左对齐。
如何在 graphviz 点节点的 TABLE 标签中左对齐多行文本文字?
将 ALIGN="LEFT"
添加到每个 <BR/>
并将 BALIGN="LEFT"
添加到 <TD ...>
,如下所示:
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>>]
}
给予: