Skip to content

Commit 8f0dbe9

Browse files
17o2kvid
andcommitted
Add TODOs about utf-8 encoding/charset (#395)
Co-authored-by: kvid <kvid@users.noreply.github.com>
1 parent 9fbce3b commit 8f0dbe9

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/wireviz/wv_graphviz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def set_dot_basics(dot, options):
551551
bgcolor=options.bgcolor.html,
552552
nodesep="0.33",
553553
fontname=options.fontname,
554-
)
554+
) # TODO: Add graph attribute: charset="utf-8",
555555
dot.attr(
556556
"node",
557557
shape="none",

src/wireviz/wv_harness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def png(self):
391391
return data.read()
392392

393393
@property
394-
def svg(self):
394+
def svg(self): # TODO?: Verify xml encoding="utf-8" in SVG?
395395
graph = self.graph
396396
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
397397

src/wireviz/wv_output.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ def embed_svg_images_file(
6969
) -> None:
7070
filename_in = Path(filename_in).resolve()
7171
filename_out = filename_in.with_suffix(".b64.svg")
72-
filename_out.write_text(
72+
filename_out.write_text( # TODO?: Verify xml encoding="utf-8" in SVG?
7373
embed_svg_images(filename_in.read_text(), filename_in.parent)
74-
)
74+
) # TODO: Use encoding="utf-8" in both read_text() and write_text()
7575
if overwrite:
7676
filename_out.replace(filename_in)
7777

@@ -95,11 +95,11 @@ def generate_html_output(
9595
# fall back to built-in simple template if no template was provided
9696
templatefile = Path(wireviz.__file__).parent / "templates/simple.html"
9797

98-
html = file_read_text(templatefile)
98+
html = file_read_text(templatefile) # TODO?: Warn if unexpected meta charset?
9999

100100
# embed SVG diagram (only if used)
101101
def svgdata() -> str:
102-
return re.sub(
102+
return re.sub( # TODO?: Verify xml encoding="utf-8" in SVG?
103103
"^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>",
104104
"<!-- XML and DOCTYPE declarations from SVG file removed -->",
105105
file_read_text(f"{filename}.tmp.svg"),

0 commit comments

Comments
 (0)