Skip to content

Commit

Permalink
Escape & in SVG diagrams (#6579)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanujkhattar authored Apr 30, 2024
1 parent 2474d47 commit 37e8df9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions cirq-core/cirq/contrib/svg/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def fixup_text(text: str):
# https://github.com/quantumlib/Cirq/issues/2905
text = text.replace('[<virtual>]', '')
text = text.replace('[cirq.VirtualTag()]', '')
text = text.replace('&', '&amp;')
text = text.replace('<', '&lt;').replace('>', '&gt;')
return text

Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/contrib/svg/svg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_empty_moments():
'symbol,svg_symbol',
[
('<a', '&lt;a'),
('<a&', '&lt;a&amp;'),
('<=b', '&lt;=b'),
('>c', '&gt;c'),
('>=d', '&gt;=d'),
Expand Down

0 comments on commit 37e8df9

Please sign in to comment.