Skip to content

Commit 9575afb

Browse files
committed
Add ansi_up for notebook
1 parent cd65edd commit 9575afb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

embed-v2.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,15 @@
364364
promises.push(loadMarkdownStyle);
365365

366366
if (type === 'ipynb') {
367-
const loadNotebookjs = loadMarked.then(() => (typeof nb != "undefined" ? Promise.resolve() : loadScript('https://cdn.jsdelivr.net/gh/jsvine/[email protected]/notebook.min.js')))
368-
.then(() => { nb.markdown = marked.parse; });
367+
const loadAnsiUp = typeof AnsiUp != "undefined" ? Promise.resolve() : loadScript('https://cdn.jsdelivr.net/gh/drudru/[email protected]/ansi_up.min.js');
368+
const loadNotebookjs = Promise.all([loadMarked, loadAnsiUp])
369+
.then(() => (typeof nb != "undefined" ? Promise.resolve() : loadScript('https://cdn.jsdelivr.net/gh/jsvine/[email protected]/notebook.min.js')))
370+
.then(() => {
371+
nb.markdown = marked.parse;
372+
const ansi_up = new AnsiUp();
373+
// bind 'this' to fix 'TypeError: this.append_buffer is not a function'
374+
nb.ansi = ansi_up.ansi_to_html.bind(ansi_up);
375+
});
369376
promises.push(loadNotebookjs);
370377
}
371378
}

0 commit comments

Comments
 (0)