nadavrot / layout

Layout is a rust library and a tool that renders Graphviz dot files.
MIT License
656 stars 39 forks source link

Supporting html labels #19

Open drahnr opened 1 year ago

drahnr commented 1 year ago

Hey, thank you for writing the crate. I am currently working with an svg generation library that makes use of html like labels (https://graphviz.org/doc/info/shapes.html#html) which this crate does not support just yet.

Would you be interested in accepting a PR for support?

nadavrot commented 1 year ago

Thank you for reaching out. This feature is indeed missing. Can you tell me more how you plan to implement this feature?

drahnr commented 1 year ago

My initial idea would be to add < and > as bracket like enclosings, and using the content inbetween as input to either https://crates.io/crates/hard-xml or https://crates.io/crates/xml-rs and defining all supported items manually. Text is natively supported in SVGs: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text

Rendering tables is the most tricky part, so I'd punt on that for now, https://tink.uk/accessible-svg-tables/ outlines a path to get there, but it requires a few more moving parts, i.e. how to size the table elements - I am not yet sure if one can avoid to do text and glyph placement to obtain i.e. the width of a column.