Skip to content

Commit

Permalink
escape double quotes in graphviz labels
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
  • Loading branch information
quantumsheep committed Dec 28, 2024
1 parent 7e1daf1 commit 3167a02
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion treelib/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,8 @@ def to_graphviz(
sorting=sorting,
):
nid = self[n].identifier
state = '"{0}" [label="{1}", shape={2}]'.format(nid, self[n].tag, shape)
tag = str(self[n].tag).translate(str.maketrans({'"': r"\""}))
state = '"{0}" [label="{1}", shape={2}]'.format(nid, tag, shape)
nodes.append(state)

for c in self.children(nid):
Expand Down

0 comments on commit 3167a02

Please sign in to comment.