iocamljs
iocamljs copied to clipboard
stand-alone iocamljs kernels doesn't like `split-lines`
It seems stand-alone kernel.foo.js
doesn't work with split lines in the code. I got the following error message:
[Error] TypeError: undefined is not a function (evaluating 'string.split(/\r\n?|\n/)')
(anonymous function) (codemirror.js, line 5481)
setValue (codemirror.js, line 4689)
(anonymous function) (codemirror.js, line 4888)
set_text (codecell.js, line 366)
fromJSON (codecell.js, line 401)
fromJSON (notebook.js, line 1556)
load_notebook_success (notebook.js, line 1742)
i (jquery.min.js, line 3)
l (jquery.min.js, line 3)
fireWith (jquery.min.js, line 3)
k (jquery.min.js, line 5)
(anonymous function) (jquery.min.js, line 5)
Note: I'm not totally sure how to reproduce this one, I got that errors on some notebooks and sometimes not and I'm not clear what is the real cause.
I confirm, having an array instead of a string in source
or input
seems to cause the problem.
The following patch to static/notebook/codecell.js
seems to fix the issue:
- this.set_text(data.input);
+ if (typeof data.input == "string") { this.set_text(data.input) }
+ else { this.set_text(data.input.join("")) };
See andrewray/iocamlserver#10 for some background to this and the option -no-split-lines for the current solution, also noted here
http://andrewray.github.io/iocamljs/adding_demos.html On 10 Oct 2014 08:56, "Thomas Gazagnaire" [email protected] wrote:
The following patch to static/notebook/codecell.js seems to fix the issue:
this.set_text(data.input);
if (typeof data.input == "string") { this.set_text(data.input) }
else { this.set_text(data.input.join("")) };
— Reply to this email directly or view it on GitHub https://github.com/andrewray/iocamljs/issues/5#issuecomment-58623721.
(note the same fix is needed in textcell.js
and maybe in other places)