Skip to content

Commit 37e8df9

Browse files
authored
Escape & in SVG diagrams (#6579)
1 parent 2474d47 commit 37e8df9

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

cirq-core/cirq/contrib/svg/svg.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def fixup_text(text: str):
2121
# https://github.com/quantumlib/Cirq/issues/2905
2222
text = text.replace('[<virtual>]', '')
2323
text = text.replace('[cirq.VirtualTag()]', '')
24+
text = text.replace('&', '&amp;')
2425
text = text.replace('<', '&lt;').replace('>', '&gt;')
2526
return text
2627

cirq-core/cirq/contrib/svg/svg_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def test_empty_moments():
6565
'symbol,svg_symbol',
6666
[
6767
('<a', '&lt;a'),
68+
('<a&', '&lt;a&amp;'),
6869
('<=b', '&lt;=b'),
6970
('>c', '&gt;c'),
7071
('>=d', '&gt;=d'),

0 commit comments

Comments
 (0)