Show More
@@ -15,6 +15,7 b' before_install:' | |||
|
15 | 15 | - time sudo apt-get update |
|
16 | 16 | - time sudo apt-get install pandoc casperjs nodejs libzmq3-dev |
|
17 | 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 | 19 | install: |
|
19 | 20 | - time python setup.py install -q |
|
20 | 21 | script: |
@@ -8,7 +8,8 b' define([' | |||
|
8 | 8 | 'base/js/security', |
|
9 | 9 | 'notebook/js/mathjaxutils', |
|
10 | 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 | 13 | "use strict"; |
|
13 | 14 | var Cell = cell.Cell; |
|
14 | 15 |
@@ -5,50 +5,59 b'' | |||
|
5 | 5 | // IPython static_path dir relative to here: |
|
6 | 6 | var static_path = __dirname + "/../../html/static/"; |
|
7 | 7 | |
|
8 | var fs = require('fs'); | |
|
9 | var IPython; | |
|
10 | // marked can be loaded with require, | |
|
11 | // the others must be execfiled | |
|
12 | var marked = require(static_path + 'components/marked/lib/marked.js'); | |
|
13 | ||
|
14 | eval(fs.readFileSync(static_path + "components/highlight.js/build/highlight.pack.js", 'utf8')); | |
|
15 | eval(fs.readFileSync(static_path + "base/js/namespace.js", 'utf8')); | |
|
8 | // Excerpt from the example in require.js docs | |
|
9 | // http://requirejs.org/docs/node.html | |
|
10 | var requirejs = require('requirejs'); | |
|
11 | requirejs.config({ | |
|
12 | //Pass the top-level main.js/index.js require | |
|
13 | //function to requirejs so that node modules | |
|
14 | //are loaded relative to the top-level JS file. | |
|
15 | nodeRequire: require, | |
|
16 | baseUrl: static_path, | |
|
17 | }); | |
|
16 | 18 | |
|
17 | eval(fs.readFileSync(static_path + "base/js/utils.js", 'utf8')); | |
|
18 | eval(fs.readFileSync(static_path + "notebook/js/mathjaxutils.js", 'utf8')); | |
|
19 | requirejs([ | |
|
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? | |
|
21 | marked.setOptions({ | |
|
22 | gfm : true, | |
|
23 | tables: true, | |
|
24 | langPrefix: "language-", | |
|
25 | highlight: function(code, lang) { | |
|
26 | if (!lang) { | |
|
27 | // no language, no highlight | |
|
28 | return code; | |
|
29 | } | |
|
30 | var highlighted; | |
|
31 | try { | |
|
32 | highlighted = hljs.highlight(lang, code, false); | |
|
33 | } catch(err) { | |
|
34 | highlighted = hljs.highlightAuto(code); | |
|
27 | // this is copied from notebook.main. Should it be moved somewhere we can reuse it? | |
|
28 | marked.setOptions({ | |
|
29 | gfm : true, | |
|
30 | tables: true, | |
|
31 | langPrefix: "language-", | |
|
32 | highlight: function(code, lang) { | |
|
33 | if (!lang) { | |
|
34 | // no language, no highlight | |
|
35 | return code; | |
|
36 | } | |
|
37 | var highlighted; | |
|
38 | try { | |
|
39 | highlighted = hljs.highlight(lang, code, false); | |
|
40 | } catch(err) { | |
|
41 | highlighted = hljs.highlightAuto(code); | |
|
42 | } | |
|
43 | return highlighted.value; | |
|
35 | 44 | } |
|
36 | return highlighted.value; | |
|
37 | } | |
|
38 | }); | |
|
45 | }); | |
|
39 | 46 | |
|
40 | // read the markdown from stdin | |
|
41 | var md=''; | |
|
42 | process.stdin.on("data", function (data) { | |
|
43 | md += data; | |
|
44 | }); | |
|
47 | // read the markdown from stdin | |
|
48 | var md=''; | |
|
49 | process.stdin.on("data", function (data) { | |
|
50 | md += data; | |
|
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