From 7e7c2fe9e583ed5f099dc9409792b78c80577ac5 Mon Sep 17 00:00:00 2001 From: MinRK Date: Thu, 26 Jul 2012 13:30:57 -0700 Subject: [PATCH 1/2] catch js errors when rendering markdown cells --- IPython/frontend/html/notebook/static/css/notebook.css | 4 ++++ IPython/frontend/html/notebook/static/js/textcell.js | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index 8a49a19d5..adc5bffbf 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -388,3 +388,7 @@ pre, code, kbd, samp { white-space: pre-wrap; } #fonttest { font-family: monospace; } + +.render-error { + color: darkred; +} \ No newline at end of file diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js index 3d07d3a44..40a395037 100644 --- a/IPython/frontend/html/notebook/static/js/textcell.js +++ b/IPython/frontend/html/notebook/static/js/textcell.js @@ -220,7 +220,15 @@ var IPython = (function (IPython) { var text = this.get_text(); if (text === "") { text = this.placeholder; } var html = IPython.markdown_converter.makeHtml(text); - this.set_rendered(html); + try { + this.set_rendered(html); + } catch (e) { + console.log("Error rendering Markdown:"); + console.log(e); + this.set_rendered($("
").addClass("render-error").html( + "Error rendering Markdown!
" + e.toString()) + ); + } this.typeset() this.element.find('div.text_cell_input').hide(); this.element.find("div.text_cell_render").show(); From 4a3e1f3185f69f9c176e71f3f8c80cae04e20c28 Mon Sep 17 00:00:00 2001 From: MinRK Date: Fri, 27 Jul 2012 19:57:47 -0700 Subject: [PATCH 2/2] make markdown error handling js-specific --- IPython/frontend/html/notebook/static/css/notebook.css | 2 +- IPython/frontend/html/notebook/static/js/textcell.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index adc5bffbf..4fa319656 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -389,6 +389,6 @@ pre, code, kbd, samp { white-space: pre-wrap; } font-family: monospace; } -.render-error { +.js-error { color: darkred; } \ No newline at end of file diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js index 40a395037..2fca68693 100644 --- a/IPython/frontend/html/notebook/static/js/textcell.js +++ b/IPython/frontend/html/notebook/static/js/textcell.js @@ -223,9 +223,9 @@ var IPython = (function (IPython) { try { this.set_rendered(html); } catch (e) { - console.log("Error rendering Markdown:"); + console.log("Error running Javascript in Markdown:"); console.log(e); - this.set_rendered($("
").addClass("render-error").html( + this.set_rendered($("
").addClass("js-error").html( "Error rendering Markdown!
" + e.toString()) ); }