Skip to content

Commit

Permalink
added XML escape function
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDaniel committed Sep 12, 2023
1 parent 5f59d20 commit d5992cb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/ebdtable2graph/graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains logic to convert EbdGraph data to dot code (Graphviz) and further to parse this code to SVG images.
"""
from typing import List, Optional
from xml.sax.saxutils import escape

from ebdtable2graph.add_watermark import add_background as add_background_function
from ebdtable2graph.add_watermark import add_watermark as add_watermark_function
Expand All @@ -26,9 +27,7 @@ def _format_label(label: str) -> str:
Converts the given string e.g. a text for a node to a suitable output for dot. It replaces newlines (`\n`) with
the HTML-tag `<BR>`.
"""
label = label.replace(">", "&gt;")
label = label.replace("<", "&lt;")
return label.replace("\n", '<BR align="left"/>')
return escape(label).replace("\n", '<BR align="left"/>')
# escaped_str = re.sub(r"^(\d+): ", r"<B>\1: </B>", label)
# escaped_str = label.replace("\n", '<BR align="left"/>')
# return f'<{escaped_str}<BR align="left"/>>'
Expand Down

0 comments on commit d5992cb

Please sign in to comment.