##// END OF EJS Templates
nbconvert api tests fixes
Jonathan Frederic -
Show More
@@ -15,6 +15,7 b' before_install:'
15 - time sudo apt-get update
15 - time sudo apt-get update
16 - time sudo apt-get install pandoc casperjs nodejs libzmq3-dev
16 - time sudo apt-get install pandoc casperjs nodejs libzmq3-dev
17 - time pip install -f https://nipy.bic.berkeley.edu/wheelhouse/travis jinja2 sphinx pygments tornado requests mock pyzmq jsonschema jsonpointer
17 - time pip install -f https://nipy.bic.berkeley.edu/wheelhouse/travis jinja2 sphinx pygments tornado requests mock pyzmq jsonschema jsonpointer
18 - time npm install requirejs r.js jquery
18 install:
19 install:
19 - time python setup.py install -q
20 - time python setup.py install -q
20 script:
21 script:
@@ -8,7 +8,8 b' define(['
8 'base/js/security',
8 'base/js/security',
9 'notebook/js/mathjaxutils',
9 'notebook/js/mathjaxutils',
10 'notebook/js/celltoolbar',
10 'notebook/js/celltoolbar',
11 ], function(IPython, $, cell, security, mathjaxutils, celltoolbar) {
11 'components/marked/lib/marked',
12 ], function(IPython, $, cell, security, mathjaxutils, celltoolbar, marked) {
12 "use strict";
13 "use strict";
13 var Cell = cell.Cell;
14 var Cell = cell.Cell;
14
15
@@ -5,50 +5,59 b''
5 // IPython static_path dir relative to here:
5 // IPython static_path dir relative to here:
6 var static_path = __dirname + "/../../html/static/";
6 var static_path = __dirname + "/../../html/static/";
7
7
8 var fs = require('fs');
8 // Excerpt from the example in require.js docs
9 var IPython;
9 // http://requirejs.org/docs/node.html
10 // marked can be loaded with require,
10 var requirejs = require('requirejs');
11 // the others must be execfiled
11 requirejs.config({
12 var marked = require(static_path + 'components/marked/lib/marked.js');
12 //Pass the top-level main.js/index.js require
13
13 //function to requirejs so that node modules
14 eval(fs.readFileSync(static_path + "components/highlight.js/build/highlight.pack.js", 'utf8'));
14 //are loaded relative to the top-level JS file.
15 eval(fs.readFileSync(static_path + "base/js/namespace.js", 'utf8'));
15 nodeRequire: require,
16 baseUrl: static_path,
17 });
16
18
17 eval(fs.readFileSync(static_path + "base/js/utils.js", 'utf8'));
19 requirejs([
18 eval(fs.readFileSync(static_path + "notebook/js/mathjaxutils.js", 'utf8'));
20 'fs',
21 'components/marked/lib/marked',
22 'components/highlight.js/build/highlight.pack',
23 'base/js/utils',
24 'notebook/js/mathjaxutils',
25 ], function(fs, marked, hljs, utils, mathjaxutils) {
19
26
20 // this is copied from notebook.main. Should it be moved somewhere we can reuse it?
27 // this is copied from notebook.main. Should it be moved somewhere we can reuse it?
21 marked.setOptions({
28 marked.setOptions({
22 gfm : true,
29 gfm : true,
23 tables: true,
30 tables: true,
24 langPrefix: "language-",
31 langPrefix: "language-",
25 highlight: function(code, lang) {
32 highlight: function(code, lang) {
26 if (!lang) {
33 if (!lang) {
27 // no language, no highlight
34 // no language, no highlight
28 return code;
35 return code;
29 }
36 }
30 var highlighted;
37 var highlighted;
31 try {
38 try {
32 highlighted = hljs.highlight(lang, code, false);
39 highlighted = hljs.highlight(lang, code, false);
33 } catch(err) {
40 } catch(err) {
34 highlighted = hljs.highlightAuto(code);
41 highlighted = hljs.highlightAuto(code);
42 }
43 return highlighted.value;
35 }
44 }
36 return highlighted.value;
45 });
37 }
38 });
39
46
40 // read the markdown from stdin
47 // read the markdown from stdin
41 var md='';
48 var md='';
42 process.stdin.on("data", function (data) {
49 process.stdin.on("data", function (data) {
43 md += data;
50 md += data;
44 });
51 });
52
53 // perform the md2html transform once stdin is complete
54 process.stdin.on("end", function () {
55 var text_and_math = mathjaxutils.remove_math(md);
56 var text = text_and_math[0];
57 var math = text_and_math[1];
58 var html = marked.parser(marked.lexer(text));
59 html = mathjaxutils.replace_math(html, math);
60 process.stdout.write(html);
61 });
45
62
46 // perform the md2html transform once stdin is complete
47 process.stdin.on("end", function () {
48 var text_and_math = IPython.mathjaxutils.remove_math(md);
49 var text = text_and_math[0];
50 var math = text_and_math[1];
51 var html = marked.parser(marked.lexer(text));
52 html = IPython.mathjaxutils.replace_math(html, math);
53 process.stdout.write(html);
54 });
63 });
General Comments 0
You need to be logged in to leave comments. Login now