Skip to content

Commit

Permalink
Add TODOs about utf-8 encoding/charset (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvid committed Jul 6, 2024
1 parent 7b52adf commit 969cd99
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def create_graph(self) -> Graph:
bgcolor=wv_colors.translate_color(self.options.bgcolor, "HEX"),
nodesep="0.33",
fontname=self.options.fontname,
)
) # TODO: Add graph attribute: charset="utf-8",
dot.attr(
"node",
shape="none",
Expand Down Expand Up @@ -657,7 +657,7 @@ def png(self):
return data.read()

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

Expand Down
4 changes: 2 additions & 2 deletions src/wireviz/svgembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def embed_svg_images_file(
) -> None:
filename_in = Path(filename_in).resolve()
filename_out = filename_in.with_suffix(".b64.svg")
filename_out.write_text(
filename_out.write_text( # TODO?: Verify xml encoding="utf-8" in SVG?
embed_svg_images(filename_in.read_text(), filename_in.parent)
)
) # TODO: Use encoding="utf-8" in both read_text() and write_text()
if overwrite:
filename_out.replace(filename_in)
4 changes: 2 additions & 2 deletions src/wireviz/wv_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def generate_html_output(
# fall back to built-in simple template if no template was provided
templatefile = Path(__file__).parent / "templates/simple.html"

html = file_read_text(templatefile)
html = file_read_text(templatefile) # TODO?: Warn if unexpected meta charset?

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

0 comments on commit 969cd99

Please sign in to comment.