Add TODOs about utf-8 encoding/charset (#395)
Co-authored-by: kvid <kvid@users.noreply.github.com>
This commit is contained in:
parent
9fbce3bbf7
commit
8f0dbe9e7f
@ -551,7 +551,7 @@ def set_dot_basics(dot, options):
|
|||||||
bgcolor=options.bgcolor.html,
|
bgcolor=options.bgcolor.html,
|
||||||
nodesep="0.33",
|
nodesep="0.33",
|
||||||
fontname=options.fontname,
|
fontname=options.fontname,
|
||||||
)
|
) # TODO: Add graph attribute: charset="utf-8",
|
||||||
dot.attr(
|
dot.attr(
|
||||||
"node",
|
"node",
|
||||||
shape="none",
|
shape="none",
|
||||||
|
|||||||
@ -391,7 +391,7 @@ class Harness:
|
|||||||
return data.read()
|
return data.read()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def svg(self):
|
def svg(self): # TODO?: Verify xml encoding="utf-8" in SVG?
|
||||||
graph = self.graph
|
graph = self.graph
|
||||||
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
|
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
|
||||||
|
|
||||||
|
|||||||
@ -69,9 +69,9 @@ def embed_svg_images_file(
|
|||||||
) -> None:
|
) -> None:
|
||||||
filename_in = Path(filename_in).resolve()
|
filename_in = Path(filename_in).resolve()
|
||||||
filename_out = filename_in.with_suffix(".b64.svg")
|
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)
|
embed_svg_images(filename_in.read_text(), filename_in.parent)
|
||||||
)
|
) # TODO: Use encoding="utf-8" in both read_text() and write_text()
|
||||||
if overwrite:
|
if overwrite:
|
||||||
filename_out.replace(filename_in)
|
filename_out.replace(filename_in)
|
||||||
|
|
||||||
@ -95,11 +95,11 @@ def generate_html_output(
|
|||||||
# fall back to built-in simple template if no template was provided
|
# fall back to built-in simple template if no template was provided
|
||||||
templatefile = Path(wireviz.__file__).parent / "templates/simple.html"
|
templatefile = Path(wireviz.__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)
|
# embed SVG diagram (only if used)
|
||||||
def svgdata() -> str:
|
def svgdata() -> str:
|
||||||
return re.sub(
|
return re.sub( # TODO?: Verify xml encoding="utf-8" in SVG?
|
||||||
"^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>",
|
"^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>",
|
||||||
"<!-- XML and DOCTYPE declarations from SVG file removed -->",
|
"<!-- XML and DOCTYPE declarations from SVG file removed -->",
|
||||||
file_read_text(f"{filename}.tmp.svg"),
|
file_read_text(f"{filename}.tmp.svg"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user