Merge pull request #2212 from minrk/protectjs

catch errors in markdown javascript
This commit is contained in:
Bussonnier Matthias 2012-07-28 03:59:03 -07:00
commit 5c394dab71
2 changed files with 13 additions and 1 deletions

View File

@ -388,3 +388,7 @@ pre, code, kbd, samp { white-space: pre-wrap; }
#fonttest {
font-family: monospace;
}
.js-error {
color: darkred;
}

View File

@ -221,7 +221,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 running Javascript in Markdown:");
console.log(e);
this.set_rendered($("<div/>").addClass("js-error").html(
"Error rendering Markdown!<br/>" + e.toString())
);
}
this.typeset()
this.element.find('div.text_cell_input').hide();
this.element.find("div.text_cell_render").show();