##// END OF EJS Templates
refactor to improve cell switching in edit mode...
refactor to improve cell switching in edit mode This code was repeated in both CodeCell and TextCell, both of which are extensions of Cell, so this just unifies the logic in Cell. TextCell had logic here to check if the cell was rendered or not, but I don't believe it is possible to end up triggering such a code path. (Should that be required, I can always just add back these methods to TextCell, performing the .rendered==True check, and calling the Cell prior to this, code mirror at_top would only return true on if the cursor was at the first character of the top line. Now, pressing up arrow on any character on the top line will take you to the cell above. The same applies for the bottom line. Pressing down arrow would only go to the next cell if the cursor was at a location *after* the last character (something that is only possible to achieve in vim mode if the last line is empty, for example). Now, down arrow on any character of the last line will go to the next cell.

File last commit:

r14206:7a0e96e3
r15754:d60e793e
Show More
marked.js
54 lines | 1.7 KiB | application/javascript | JavascriptLexer
MinRK
add marked.js entry point for md2html in nbconvert...
r14206 // Node.js script for markdown to html conversion
// This applies the same math extraction and marked settings
// that we use in the live notebook.
// IPython static_path dir relative to here:
var static_path = __dirname + "/../../html/static/";
var fs = require('fs');
var IPython;
// marked can be loaded with require,
// the others must be execfiled
var marked = require(static_path + 'components/marked/lib/marked.js');
eval(fs.readFileSync(static_path + "components/highlight.js/build/highlight.pack.js", 'utf8'));
eval(fs.readFileSync(static_path + "base/js/namespace.js", 'utf8'));
eval(fs.readFileSync(static_path + "base/js/utils.js", 'utf8'));
eval(fs.readFileSync(static_path + "notebook/js/mathjaxutils.js", 'utf8'));
// this is copied from notebook.main. Should it be moved somewhere we can reuse it?
marked.setOptions({
gfm : true,
tables: true,
langPrefix: "language-",
highlight: function(code, lang) {
if (!lang) {
// no language, no highlight
return code;
}
var highlighted;
try {
highlighted = hljs.highlight(lang, code, false);
} catch(err) {
highlighted = hljs.highlightAuto(code);
}
return highlighted.value;
}
});
// read the markdown from stdin
var md='';
process.stdin.on("data", function (data) {
md += data;
});
// perform the md2html transform once stdin is complete
process.stdin.on("end", function () {
var text_and_math = IPython.mathjaxutils.remove_math(md);
var text = text_and_math[0];
var math = text_and_math[1];
var html = marked.parser(marked.lexer(text));
html = IPython.mathjaxutils.replace_math(html, math);
process.stdout.write(html);
});