diff --git a/nbconvert/exporters/templateexporter.py b/nbconvert/exporters/templateexporter.py index 472549920..fc6a89b67 100644 --- a/nbconvert/exporters/templateexporter.py +++ b/nbconvert/exporters/templateexporter.py @@ -40,6 +40,13 @@ ) +def escape_html(s, quote=True): + if not isinstance(s, str): + return s + else: + return html.escape(s) + + default_filters = { "indent": filters.indent, "markdown2html": filters.markdown2html, @@ -71,7 +78,7 @@ "convert_pandoc": filters.convert_pandoc, "json_dumps": json.dumps, # For removing any HTML - "escape_html": html.escape, + "escape_html": escape_html, # For sanitizing HTML for any XSS "clean_html": clean_html, "strip_trailing_newline": filters.strip_trailing_newline,