I'm using graphviz to visualize the AST of a language I'm parsing. I want to include the source code (as a label) but graphviz aligns the text inside the label, which messes with my indentation (and code is indentation-sensitive). Here's an example of the problem, the second line of code should not be indented:
This is the relevant part of the generated .dot file:
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";
You may use \l
instead of \n
in order to divide the label into left-justified lines.