catch errors in markdown javascript #2212

Merged
merged 2 commits into from Jul 28, 2012

Projects

None yet

2 participants

@minrk
Owner
minrk commented Jul 27, 2012

Javascript errors in markdown cells can no longer break the notebook.

Owner
minrk commented Jul 27, 2012

I believe this supersedes #2199, but it actually does different things.

@Carreau Carreau and 1 other commented on an outdated diff Jul 27, 2012
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($("<div/>").addClass("render-error").html(
+ "Error rendering Markdown!<br/>" + e.toString())
Carreau
Carreau Jul 27, 2012 Owner

Can a error be thrown with something else than bad JS in a script tag ?

minrk
minrk Jul 27, 2012 Owner

I don't think so, at least not unless there is a bug in IPython or pagedown's code.

Carreau
Carreau Jul 27, 2012 Owner

So do you want be more explicit that it is the embeded Javascritpt that causes an error ?

Owner
Carreau commented Jul 27, 2012

+1

Owner
Carreau commented Jul 28, 2012

i'll merge this one.

@Carreau Carreau merged commit bb65f3d into ipython:master Jul 28, 2012
@minrk minrk added a commit that referenced this pull request Jul 28, 2012
@minrk minrk Backport PR #2212: catch errors in markdown javascript
Javascript errors in markdown cells can no longer break the notebook.
c7de115
@minrk minrk deleted the minrk:protectjs branch Mar 31, 2014
@yarikoptic yarikoptic added a commit to yarikoptic/ipython that referenced this pull request May 2, 2014
@yarikoptic yarikoptic Merge commit 'rel-0.13-33-gcfc5692' into debian-01X
* commit 'rel-0.13-33-gcfc5692': (33 commits)
  Backport PR #2347: adjust division error message checking to account for Python 3
  Backport PR #2305: RemoteError._render_traceback_ calls self.render_traceback
  Backport PR #2280: fix SSH passwordless check for OpenSSH
  Backport PR #2270: SSHLauncher tweaks
  Backport PR #2261: Fix: longest_substr([]) -> ''
  Backport PR #2250: fix html in notebook example
  Backport PR #2235: remove spurious print statement from setupbase.py
  fixup
  Backport PR #2223: Custom tracebacks
  Backport PR #2214: use KernelApp.exec_lines/files in IPEngineApp
  Backport PR #2212: catch errors in markdown javascript
  Backport PR #2194: clean nan/inf in json_clean
  Backport PR #2177: remove numpy install from travis/tox scripts
  Backport PR #2169: ipdb: pdef, pdoc, pinfo magics all broken
  Backport PR #2186: removed references to h5py dependence in octave magic documentation
  Backport PR #2185: added test for %store, fixed storemagic
  Backport PR #2170: Fix tab completion with IPython.embed_kernel().
  Backport PR #2163: fix 'remote_profie_dir' typo in SSH launchers
  Backport PR #2117: use explicit url in notebook example
  Backport PR #2126: ipcluster broken with any batch (PBS/LSF/SGE)
  ...
fc7c7f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment