From 37ca44107dce240f45ccf33e8fb59b5c6702abb9 Mon Sep 17 00:00:00 2001 From: Nathanael Demacon <7271496+quantumsheep@users.noreply.github.com> Date: Sat, 1 Mar 2025 16:26:24 +0100 Subject: [PATCH] Escape double quotes in graphviz labels (#235) * escape double quotes in graphviz labels Signed-off-by: Nathanael DEMACON * rename the variable label Signed-off-by: Nathanael DEMACON --------- Signed-off-by: Nathanael DEMACON Co-authored-by: Nathanael DEMACON --- treelib/tree.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/treelib/tree.py b/treelib/tree.py index 1cc9ac8..7bc4e7e 100644 --- a/treelib/tree.py +++ b/treelib/tree.py @@ -1097,7 +1097,8 @@ class Tree(object): sorting=sorting, ): nid = self[n].identifier - state = '"{0}" [label="{1}", shape={2}]'.format(nid, self[n].tag, shape) + label = str(self[n].tag).translate(str.maketrans({'"': r"\""})) + state = '"{0}" [label="{1}", shape={2}]'.format(nid, label, shape) nodes.append(state) for c in self.children(nid): -- 2.33.0