gpt4 book ai didi

Graphviz - 如何使标签中的文本左对齐?

转载 作者:行者123 更新时间:2023-12-02 10:43:02 25 4
gpt4 key购买 nike

我正在使用 graphviz 来可视化我正在解析的语言的 AST。我想包括源代码(作为标签),但 graphviz 对齐标签内的文本,这与我的缩进(并且代码对缩进敏感)相混淆。这是问题的一个示例,第二行代码不应缩进:

enter image description here

这是生成的 .dot 文件的相关部分:

graph [fontname=Courier,fontsize=10.0,labeljust=l,nojustify=true];
node [shape=box,width=0.2,height=0.2,fontname=Courier,fontsize=10.0,penwidth=0.5];
edge [weight=1.2,penwidth=0.5,fontname=Courier,fontsize=10.0,labeljust=c];
labelloc="t";
label="\ndef square(a, b) -> a * b\ndef dotProduct(a, b) -> \n a.x * b.x + a.y * b.y\n";

最佳答案

您可以使用 \l而不是 \n为了divide the label into left-justified lines .

graphviz label with left-justifed lines

关于Graphviz - 如何使标签中的文本左对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13103584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com