diff --git a/nbconvert/exporters/templateexporter.py b/nbconvert/exporters/templateexporter.py index 8b619224e..5a1057b71 100644 --- a/nbconvert/exporters/templateexporter.py +++ b/nbconvert/exporters/templateexporter.py @@ -64,6 +64,9 @@ 'get_metadata': filters.get_metadata, 'convert_pandoc': filters.convert_pandoc, 'json_dumps': json.dumps, + # browsers will parse , closing a script tag early + # Since JSON allows escaping forward slash, this will still be parsed by JSON + 'escape_html_script': lambda x: x.replace('', '<\\/script>'), 'strip_trailing_newline': filters.strip_trailing_newline, 'text_base64': filters.text_base64, } diff --git a/share/jupyter/nbconvert/templates/classic/base.html.j2 b/share/jupyter/nbconvert/templates/classic/base.html.j2 index e7b6b6aa0..ad010f016 100644 --- a/share/jupyter/nbconvert/templates/classic/base.html.j2 +++ b/share/jupyter/nbconvert/templates/classic/base.html.j2 @@ -267,7 +267,7 @@ var element = $('#{{ div_id }}'); {% set mimetype = 'application/vnd.jupyter.widget-state+json'%} {% if mimetype in nb.metadata.get("widgets",{})%} {% endif %} {{ super() }} diff --git a/share/jupyter/nbconvert/templates/lab/base.html.j2 b/share/jupyter/nbconvert/templates/lab/base.html.j2 index 684874606..45046c599 100644 --- a/share/jupyter/nbconvert/templates/lab/base.html.j2 +++ b/share/jupyter/nbconvert/templates/lab/base.html.j2 @@ -273,7 +273,7 @@ var element = document.getElementById('{{ div_id }}'); {% set mimetype = 'application/vnd.jupyter.widget-state+json'%} {% if mimetype in nb.metadata.get("widgets",{})%} {% endif %} {{ super() }}