diff --git a/nbconvert/tests/test_nbconvertapp.py b/nbconvert/tests/test_nbconvertapp.py
index c6b6b5ef4..f01466a34 100644
--- a/nbconvert/tests/test_nbconvertapp.py
+++ b/nbconvert/tests/test_nbconvertapp.py
@@ -374,7 +374,7 @@ def test_no_input(self):
'= '
'symbols'
'('
- ''x y z''
+ '\'x y z\''
')'
) not in text
self.nbconvert("notebook1.ipynb --log-level 0 --to html")
@@ -392,7 +392,7 @@ def test_no_input(self):
'= '
'symbols'
'('
- ''x y z''
+ '\'x y z\''
')'
) in text2
diff --git a/share/jupyter/nbconvert/templates/base/celltags.j2 b/share/jupyter/nbconvert/templates/base/celltags.j2
index 7df02cfc4..622a2c661 100644
--- a/share/jupyter/nbconvert/templates/base/celltags.j2
+++ b/share/jupyter/nbconvert/templates/base/celltags.j2
@@ -1,7 +1,7 @@
{%- macro celltags(cell) -%}
{% if cell.metadata.tags | length > 0 -%}
{% for tag in (cell.metadata.tags) -%}
- {{ (' celltag_' ~ tag) | clean_html -}}
+ {{ (' celltag_' ~ tag) | escape_html -}}
{%- endfor -%}
{%- endif %}
{%- endmacro %}