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";
We specify the margin-bottom of our <div> element. Then, we set the display of the <label> element to "inline-block" and give a fixed width. After that, set the text-align property to "right", and the labels will be aligned with the inputs on the right side.
Centered headlines should go with centered text. Left aligned headlines should go with left aligned text. Avoid mixing the two together so that your text doesn't look unbalanced. Following these guidelines will help make your text look appealing and easy to read.
You may use \l
instead of \n
in order to divide the label into left-justified lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With