pgf
pgf copied to clipboard
dvisvgm backend: expose the name of tikz entities in order to assign svg id
Brief outline of the proposed feature
Issue originally reported in dvisvgm
: https://github.com/mgieseki/dvisvgm/issues/270
I'm including the dvisvgm
svg output of tikz in an html page, and I would like to be able to refer to some specific elements to eg restyle them or animate them via javascript.
To this end, it would be extremely useful if dvisvgm
could add a id
attribute matching the named tikz nodes & paths, algonside some class information (for instance, node
, the shape -- circle
, etc).
For instance,
\documentclass[tikz,dvisvgm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[draw] (node1) at (0,0) {Hello world};
\node[draw, shape=circle] (node2) at (1,1) {Hello world 2};
\path (node1) edge[->,name=edge1] (node2);
\end{tikzpicture}
\end{document}
would generate something like:
<?xml version='1.0' encoding='UTF-8'?>
<svg version='1.1'>
<g id='page1'>
<g id='node1' class='node'>
<text class='f0' >...</text>
</g>
<path id='edge1' class='edge' d='M-4.06023 21.59477H60.96571V35.31071H-4.06023Z' fill='none'/>
<g id='node2' class='node circle'>
<text class='f0'>...</text>
</g>
</g>
</svg>
This would require tikz to expose the names to the dvisvgm
backend. Would it be feasible?
Usage example
No response