Skip to content

Commit

Permalink
require marked.min and call it via marked.marked.
Browse files Browse the repository at this point in the history
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 ipython-contrib#1638
  • Loading branch information
johnjbarton committed May 7, 2023
1 parent 374defd commit 22bb895
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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*<p>([\s\S]*?)<\/p>\s*$/); //strip <p> and </p> that marked (maybe) adds and we don't want
html = t !== null ? t[1] : html;
var q = html.match(/^&#39;([\s\S]*?)&#39;$/); // strip quotes from strings
Expand All @@ -84,11 +84,11 @@ define([
var png = ul['image/png'];
html = '<img src="data:image/png;base64,' + png + '"/>';
} 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*<p>([\s\S]*?)<\/p>\s*$/); //strip <p> and </p> that marked adds and we don't want
html = t !== null ? t[1] : html;
Expand Down

0 comments on commit 22bb895

Please sign in to comment.