From 22bb8959886c5118c92a4e19666f841200297de4 Mon Sep 17 00:00:00 2001 From: johnjbarton Date: Sun, 7 May 2023 14:23:53 -0700 Subject: [PATCH] require marked.min and call it via marked.marked. In v6 jupyter notebook components/marked/lib/marked no longer exists. The extension silently falls over. Hack around puts local copy of marked.min from cdnjs.com into the python-markdown directory. See Issue #1638 --- .../nbextensions/python-markdown/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/python-markdown/main.js b/src/jupyter_contrib_nbextensions/nbextensions/python-markdown/main.js index 84f39fe25..8d1e6ba2d 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/python-markdown/main.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/python-markdown/main.js @@ -13,7 +13,7 @@ define([ 'require', 'notebook/js/cell', 'base/js/security', - 'components/marked/lib/marked', + 'nbextensions/python-markdown/marked.min', 'base/js/events', 'notebook/js/textcell' ], function(IPython, $, requirejs, cell, security, marked, events, textcell) { @@ -60,9 +60,9 @@ define([ var html; if (out_data.msg_type === "error") { var text = "**" + out_data.content.ename + "**: " + out_data.content.evalue; - html = marked(text); + html = marked.marked(text); } else if (out_data.msg_type === "stream") { - html = marked(out_data.content.text); + html = marked.marked(out_data.content.text); var t = html.match(/^\s*

([\s\S]*?)<\/p>\s*$/); //strip

and

that marked (maybe) adds and we don't want html = t !== null ? t[1] : html; var q = html.match(/^'([\s\S]*?)'$/); // strip quotes from strings @@ -84,11 +84,11 @@ define([ var png = ul['image/png']; html = ''; } else if (ul['text/markdown'] != undefined) { - html = marked(ul['text/markdown']); + html = marked.marked(ul['text/markdown']); } else if (ul['text/html'] != undefined) { html = ul['text/html']; } else { - html = marked(ul['text/plain']); + html = marked.marked(ul['text/plain']); // [\s\S] is used to also catch newlines var t = html.match(/^\s*

([\s\S]*?)<\/p>\s*$/); //strip

and

that marked adds and we don't want html = t !== null ? t[1] : html;