Skip to content

Commit 37ca441

Browse files
authored
Escape double quotes in graphviz labels (#235)
* escape double quotes in graphviz labels Signed-off-by: Nathanael DEMACON <[email protected]> * rename the variable label Signed-off-by: Nathanael DEMACON <[email protected]> --------- Signed-off-by: Nathanael DEMACON <[email protected]> Co-authored-by: Nathanael DEMACON <[email protected]>
1 parent a8384bc commit 37ca441

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

treelib/tree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,8 @@ def to_graphviz(
10971097
sorting=sorting,
10981098
):
10991099
nid = self[n].identifier
1100-
state = '"{0}" [label="{1}", shape={2}]'.format(nid, self[n].tag, shape)
1100+
label = str(self[n].tag).translate(str.maketrans({'"': r"\""}))
1101+
state = '"{0}" [label="{1}", shape={2}]'.format(nid, label, shape)
11011102
nodes.append(state)
11021103

11031104
for c in self.children(nid):

0 commit comments

Comments
 (0)