Qiskit / rustworkx

A high performance Python graph library implemented in Rust.
https://www.rustworkx.org
Apache License 2.0
967 stars 140 forks source link

Expose extra options to control string escaping in dot file generation #1230

Open mtreinish opened 1 week ago

mtreinish commented 1 week ago

What is the expected enhancement?

The dot syntax can be a bit particular about character escaping and quotation marks. For example as was previously reported in #750. This was attempted to be fixed in #1203 by escaping special characters in the string and wrapping everything in quotation marks. However, this solution was a bit overeager in it's application as existing users were relying on low level control of inserting quotation marks or not to generate dot files in their usage of the dot file generation, so this was reverted in #1229. However, this is a clear argument for doing that string escaping so users don't have to worry about it. I think we should expand the interface on .to_dot() and graphviz_draw() to expose options to control how we escape strings or autowrap them in quotes. At the very least we should document the current assumptions around how the function behaves.