Skip to content

Commit 020a69b

Browse files
committed
Fix issue #1638: support local directory loading marked.js
In v6 jupyter notebook components/marked/lib/marked no longer exists. The extension silently falls over. Add https://cdnjs.com/libraries/marked for local loading into the python-markdown directory. Change required path and calls marked -> marked.marked. Add 6.x to yaml compat setting
1 parent 374defd commit 020a69b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/jupyter_contrib_nbextensions/nbextensions/python-markdown/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ define([
1313
'require',
1414
'notebook/js/cell',
1515
'base/js/security',
16-
'components/marked/lib/marked',
16+
'nbextensions/python-markdown/marked.min',
1717
'base/js/events',
1818
'notebook/js/textcell'
1919
], function(IPython, $, requirejs, cell, security, marked, events, textcell) {
@@ -60,9 +60,9 @@ define([
6060
var html;
6161
if (out_data.msg_type === "error") {
6262
var text = "**" + out_data.content.ename + "**: " + out_data.content.evalue;
63-
html = marked(text);
63+
html = marked.marked(text);
6464
} else if (out_data.msg_type === "stream") {
65-
html = marked(out_data.content.text);
65+
html = marked.marked(out_data.content.text);
6666
var t = html.match(/^\s*<p>([\s\S]*?)<\/p>\s*$/); //strip <p> and </p> that marked (maybe) adds and we don't want
6767
html = t !== null ? t[1] : html;
6868
var q = html.match(/^&#39;([\s\S]*?)&#39;$/); // strip quotes from strings
@@ -84,11 +84,11 @@ define([
8484
var png = ul['image/png'];
8585
html = '<img src="data:image/png;base64,' + png + '"/>';
8686
} else if (ul['text/markdown'] != undefined) {
87-
html = marked(ul['text/markdown']);
87+
html = marked.marked(ul['text/markdown']);
8888
} else if (ul['text/html'] != undefined) {
8989
html = ul['text/html'];
9090
} else {
91-
html = marked(ul['text/plain']);
91+
html = marked.marked(ul['text/plain']);
9292
// [\s\S] is used to also catch newlines
9393
var t = html.match(/^\s*<p>([\s\S]*?)<\/p>\s*$/); //strip <p> and </p> that marked adds and we don't want
9494
html = t !== null ? t[1] : html;

src/jupyter_contrib_nbextensions/nbextensions/python-markdown/marked.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jupyter_contrib_nbextensions/nbextensions/python-markdown/python-markdown.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Link: readme.md
55
Icon: python-markdown.png
66
Main: main.js
77
Preprocessor: pymdpreprocessor.py
8-
Compatibility: 4.x, 5.x
8+
Compatibility: 4.x, 5.x, 6.x

0 commit comments

Comments
 (0)