##// END OF EJS Templates
Merge pull request #6801 from minrk/runMode...
Thomas Kluyver -
r18874:835269e6 merge
parent child Browse files
Show More
@@ -1,1 +1,1 b''
1 Subproject commit ba94581b824a62ee630dd0b92a5aea8678248a24
1 Subproject commit 563c9e74b153e9509d94fd448353eeda13f0819c
@@ -11,7 +11,8 b' define(['
11 'services/sessions/session',
11 'services/sessions/session',
12 'notebook/js/celltoolbar',
12 'notebook/js/celltoolbar',
13 'components/marked/lib/marked',
13 'components/marked/lib/marked',
14 'highlight',
14 'codemirror/lib/codemirror',
15 'codemirror/addon/runmode/runmode',
15 'notebook/js/mathjaxutils',
16 'notebook/js/mathjaxutils',
16 'base/js/keyboard',
17 'base/js/keyboard',
17 'notebook/js/tooltip',
18 'notebook/js/tooltip',
@@ -29,7 +30,8 b' define(['
29 session,
30 session,
30 celltoolbar,
31 celltoolbar,
31 marked,
32 marked,
32 hljs,
33 CodeMirror,
34 runMode,
33 mathjaxutils,
35 mathjaxutils,
34 keyboard,
36 keyboard,
35 tooltip,
37 tooltip,
@@ -83,19 +85,37 b' define(['
83 marked.setOptions({
85 marked.setOptions({
84 gfm : true,
86 gfm : true,
85 tables: true,
87 tables: true,
86 langPrefix: "language-",
88 // FIXME: probably want central config for CodeMirror theme when we have js config
87 highlight: function(code, lang) {
89 langPrefix: "cm-s-ipython language-",
90 highlight: function(code, lang, callback) {
88 if (!lang) {
91 if (!lang) {
89 // no language, no highlight
92 // no language, no highlight
90 return code;
93 if (callback) {
91 }
94 callback(null, code);
92 var highlighted;
95 return;
93 try {
96 } else {
94 highlighted = hljs.highlight(lang, code, false);
97 return code;
95 } catch(err) {
98 }
96 highlighted = hljs.highlightAuto(code);
97 }
99 }
98 return highlighted.value;
100 utils.requireCodeMirrorMode(lang, function () {
101 var el = document.createElement("div");
102 mode = CodeMirror.getMode({}, lang);
103 if (!mode) {
104 console.log("No CodeMirror mode: " + lang);
105 callback(null, code);
106 return;
107 }
108 try {
109 CodeMirror.runMode(code, mode, el);
110 callback(null, el.innerHTML);
111 } catch (err) {
112 console.log("Failed to highlight " + lang + " code", error);
113 callback(err, code);
114 }
115 }, function (err) {
116 console.log("No CodeMirror mode: " + lang);
117 callback(err, code);
118 });
99 }
119 }
100 });
120 });
101 }
121 }
@@ -552,9 +552,10 b' define(['
552 var text_and_math = mathjaxutils.remove_math(markdown);
552 var text_and_math = mathjaxutils.remove_math(markdown);
553 var text = text_and_math[0];
553 var text = text_and_math[0];
554 var math = text_and_math[1];
554 var math = text_and_math[1];
555 var html = marked.parser(marked.lexer(text));
555 marked(text, function (err, html) {
556 html = mathjaxutils.replace_math(html, math);
556 html = mathjaxutils.replace_math(html, math);
557 toinsert.append(html);
557 toinsert.append(html);
558 });
558 element.append(toinsert);
559 element.append(toinsert);
559 return toinsert;
560 return toinsert;
560 };
561 };
@@ -241,34 +241,35 b' define(['
241 MarkdownCell.prototype.render = function () {
241 MarkdownCell.prototype.render = function () {
242 var cont = TextCell.prototype.render.apply(this);
242 var cont = TextCell.prototype.render.apply(this);
243 if (cont) {
243 if (cont) {
244 var that = this;
244 var text = this.get_text();
245 var text = this.get_text();
245 var math = null;
246 var math = null;
246 if (text === "") { text = this.placeholder; }
247 if (text === "") { text = this.placeholder; }
247 var text_and_math = mathjaxutils.remove_math(text);
248 var text_and_math = mathjaxutils.remove_math(text);
248 text = text_and_math[0];
249 text = text_and_math[0];
249 math = text_and_math[1];
250 math = text_and_math[1];
250 var html = marked.parser(marked.lexer(text));
251 marked(text, function (err, html) {
251 html = mathjaxutils.replace_math(html, math);
252 html = mathjaxutils.replace_math(html, math);
252 html = security.sanitize_html(html);
253 html = security.sanitize_html(html);
253 html = $($.parseHTML(html));
254 html = $($.parseHTML(html));
254 // add anchors to headings
255 // add anchors to headings
255 // console.log(html);
256 html.find(":header").addBack(":header").each(function (i, h) {
256 html.find(":header").addBack(":header").each(function (i, h) {
257 h = $(h);
257 h = $(h);
258 var hash = h.text().replace(/ /g, '-');
258 var hash = h.text().replace(/ /g, '-');
259 h.attr('id', hash);
259 h.attr('id', hash);
260 h.append(
260 h.append(
261 $('<a/>')
261 $('<a/>')
262 .addClass('anchor-link')
262 .addClass('anchor-link')
263 .attr('href', '#' + hash)
263 .attr('href', '#' + hash)
264 .text('¶')
264 .text('¶')
265 );
265 );
266 });
266 })
267 // links in markdown cells should open in new tabs
267 // links in markdown cells should open in new tabs
268 html.find("a[href]").not('[href^="#"]').attr("target", "_blank");
268 html.find("a[href]").not('[href^="#"]').attr("target", "_blank");
269 that.set_rendered(html);
269 this.set_rendered(html);
270 that.typeset();
270 this.typeset();
271 that.events.trigger("rendered.MarkdownCell", {cell: that});
271 this.events.trigger("rendered.MarkdownCell", {cell: this})
272 });
272 }
273 }
273 return cont;
274 return cont;
274 };
275 };
@@ -27,7 +27,6 b''
27 bootstrap: 'components/bootstrap/js/bootstrap.min',
27 bootstrap: 'components/bootstrap/js/bootstrap.min',
28 bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
28 bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
29 jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min',
29 jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min',
30 highlight: 'components/highlight.js/build/highlight.pack',
31 moment: "components/moment/moment",
30 moment: "components/moment/moment",
32 codemirror: 'components/codemirror',
31 codemirror: 'components/codemirror',
33 termjs: "components/term.js/src/term",
32 termjs: "components/term.js/src/term",
@@ -52,10 +51,7 b''
52 jqueryui: {
51 jqueryui: {
53 deps: ["jquery"],
52 deps: ["jquery"],
54 exports: "$"
53 exports: "$"
55 },
54 }
56 highlight: {
57 exports: "hljs"
58 },
59 }
55 }
60 });
56 });
61 </script>
57 </script>
@@ -153,7 +153,6 b' def find_package_data():'
153 pjoin(components, "es6-promise", "*.js"),
153 pjoin(components, "es6-promise", "*.js"),
154 pjoin(components, "font-awesome", "fonts", "*.*"),
154 pjoin(components, "font-awesome", "fonts", "*.*"),
155 pjoin(components, "google-caja", "html-css-sanitizer-minified.js"),
155 pjoin(components, "google-caja", "html-css-sanitizer-minified.js"),
156 pjoin(components, "highlight.js", "build", "highlight.pack.js"),
157 pjoin(components, "jquery", "jquery.min.js"),
156 pjoin(components, "jquery", "jquery.min.js"),
158 pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"),
157 pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"),
159 pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
158 pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
General Comments 0
You need to be logged in to leave comments. Login now