Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hugr-py/src/hugr/hugr/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def render(self, hugr: Hugr) -> Digraph:
"bgcolor": self.config.palette.background,
}
if name := hugr[hugr.module_root].metadata.get("name", None):
name = html.escape(name)
name = html.escape(str(name))
else:
name = ""

Expand Down Expand Up @@ -218,7 +218,7 @@ def _viz_node(self, node: Node, hugr: Hugr, graph: Digraph) -> None:
meta = hugr[node].metadata
if len(meta) > 0:
data = "<BR/><BR/>" + "<BR/>".join(
html.escape(key) + ": " + html.escape(value)
html.escape(key) + ": " + html.escape(str(value))
for key, value in meta.items()
)
else:
Expand Down
2 changes: 1 addition & 1 deletion hugr-py/tests/__snapshots__/test_hugr_build.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@
<TD>
<TABLE BORDER="0" CELLBORDER="0">
<TR><TD><FONT POINT-SIZE="11.0" FACE="monospace"
COLOR="black"><B><b>[FuncDefn(&lt;jupyter-notebook&gt;)]</b></B><BR/><BR/>label: &lt;b&gt;Bold Label&lt;/b&gt;<BR/>&lt;other-label&gt;: &lt;i&gt;Italic Label&lt;/i&gt;</FONT></TD></TR>
COLOR="black"><B><b>[FuncDefn(&lt;jupyter-notebook&gt;)]</b></B><BR/><BR/>label: &lt;b&gt;Bold Label&lt;/b&gt;<BR/>&lt;other-label&gt;: &lt;i&gt;Italic Label&lt;/i&gt;<BR/>meta_can_be_anything: [42, &#x27;string&#x27;, 3.14, True]</FONT></TD></TR>
</TABLE>
</TD>
</TR>
Expand Down
1 change: 1 addition & 0 deletions hugr-py/tests/test_hugr_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ def test_html_labels(snapshot) -> None:
)
f.metadata["label"] = "<b>Bold Label</b>"
f.metadata["<other-label>"] = "<i>Italic Label</i>"
f.metadata["meta_can_be_anything"] = [42, "string", 3.14, True]

f.hugr[f.hugr.module_root].metadata["name"] = "<i>Module Root</i>"

Expand Down
Loading