Skip to content

Commit 60be73c

Browse files
author
Gorshanov Vadim
committed
Escape "mm" and "deg" to SI
1 parent f5ea42f commit 60be73c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/tikzplotlib/_text.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ def escape_text(text):
3535
The output will be: "The efficiency is \\SI{45}{\\percent} and
3636
the tolerance is \\SI{+-2}{\\degree}, \\SI{\s}"
3737
"""
38-
return re.sub(r"(\d+(\.\d+)?)\s?%", r"\\SI{\1}{\\percent}",
39-
text).replace("+-\\SI{", "\\SI{+-").replace(", s",
40-
", \\SI{\\s}")
38+
res_text = re.sub(r"(\d+(\.\d+)?)\s?%", r"\\SI{\1}{\\percent}", text)
39+
res_text = re.sub(r"(\d+(\.\d+)?)\s?mm", r"\\SI{\1}{\\mm}", res_text)
40+
res_text = re.sub(r"(\d+(\.\d+)?)\s?deg", r"\\SI{\1}{\\degree}", res_text)
41+
return res_text.replace("+-\\SI{", "\\SI{+-").replace(", s", ", \\SI{\\s}")
4142

4243

4344
def draw_text(data, obj):

0 commit comments

Comments
 (0)