dtreeviz icon indicating copy to clipboard operation
dtreeviz copied to clipboard

dtreeviz/utils.py: Fix ID collisions in inline_svg_images output

Open CyberShadow opened this issue 5 years ago • 4 comments

Inlined SVGs may have IDs which are not globally unique. Patch the tree of the inlined images and add a prefix to all IDs, to make collisions much less likely.

Please excuse my Python.

CyberShadow avatar Mar 28 '20 23:03 CyberShadow

Interesting! Can you tell me what problems occurred because of this? In other words how did you know this was a problem? thanks!

parrt avatar Mar 29 '20 17:03 parrt

I found a link to this file in a StackOverflow post and applied it to my toolchain for putting LaTeX formulas in Graphviz SVG renders... sorry if this is not useful to the project as a whole :)

CyberShadow avatar Mar 29 '20 21:03 CyberShadow

I've noticed that jupyter notebooks tend not to show my SVG images except the first time you run it, not when you reload it. You think that could be because of this unique identifier thing? Can you give me a link to the StackOverflow post? I want to understand exactly what's going on. thanks

parrt avatar Mar 30 '20 17:03 parrt

I've noticed that jupyter notebooks tend not to show my SVG images except the first time you run it, not when you reload it. You think that could be because of this unique identifier thing?

Hmm, I don't think so. The symptoms for ID collisions (which I also encountered elsewhere) is things such as styling applied to the wrong element. In this case it manifested as a wrong font in some of the SVGs embedded later in the document.

Can you give me a link to the StackOverflow post? I want to understand exactly what's going on. thanks

Sorry, I misremembered. Though I did run into dtreeviz on StackOverflow while researching my SVG troubles, the actual link to this file I found on this GitHub comment: https://github.com/ellson/MOTHBALLED-graphviz/issues/1294#issuecomment-425730041

CyberShadow avatar Mar 30 '20 22:03 CyberShadow