Skip to content

Commit 7236724

Browse files
authored
html escape source text for clipboard copy (#248)
1 parent 7f977fd commit 7236724

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/mkdocs_jupyter/nbconvert2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ def custom_highlight_code(source, language=None, metadata=None):
303303
formatter = HtmlFormatter(cssclass=classes)
304304
output = _pygments_highlight(source, formatter, language, metadata)
305305

306-
clipboard_copy_txt = f"""<div id="cell-{cell_id}" class="clipboard-copy-txt">{source}</div>
306+
escaped = mistune.escape(source)
307+
clipboard_copy_txt = f"""<div id="cell-{cell_id}" class="clipboard-copy-txt">{escaped}</div>
307308
"""
308309
return output + clipboard_copy_txt
309310

0 commit comments

Comments
 (0)