Show More
@@ -50,8 +50,11 b' var IPython = (function (IPython) {' | |||
|
50 | 50 | }); |
|
51 | 51 | }; |
|
52 | 52 | |
|
53 | // prototype typeset method does nothing, see TextCell typeset | |
|
54 | 53 | Cell.prototype.typeset = function () { |
|
54 | if (window.MathJax){ | |
|
55 | var cell_math = this.element.get(0); | |
|
56 | MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_math]); | |
|
57 | } | |
|
55 | 58 | }; |
|
56 | 59 | |
|
57 | 60 | Cell.prototype.select = function () { |
@@ -16,6 +16,18 b' IPython.mathjaxutils = (function (IPython) {' | |||
|
16 | 16 | var init = function () { |
|
17 | 17 | if (window.MathJax) { |
|
18 | 18 | // MathJax loaded |
|
19 | MathJax.Hub.Config({ | |
|
20 | tex2jax: { | |
|
21 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
|
22 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
|
23 | processEnvironments: true | |
|
24 | }, | |
|
25 | displayAlign: 'left', // Change this to 'center' to center equations. | |
|
26 | "HTML-CSS": { | |
|
27 | styles: {'.MathJax_Display': {"margin": 0}} | |
|
28 | } | |
|
29 | }); | |
|
30 | MathJax.Hub.Configured(); | |
|
19 | 31 | } else if (window.mathjax_url != "") { |
|
20 | 32 | // Don't have MathJax, but should. Show dialog. |
|
21 | 33 | var dialog = $('<div></div>') |
@@ -89,12 +101,12 b' IPython.mathjaxutils = (function (IPython) {' | |||
|
89 | 101 | // math, then push the math string onto the storage array. |
|
90 | 102 | // The preProcess function is called on all blocks if it has been passed in |
|
91 | 103 | var process_math = function (i, j, pre_process) { |
|
92 |
var |
|
|
104 | var hub = MathJax.Hub; | |
|
93 | 105 | var block = blocks.slice(i, j + 1).join("").replace(/&/g, "&") // use HTML entity for & |
|
94 | 106 | .replace(/</g, "<") // use HTML entity for < |
|
95 | 107 | .replace(/>/g, ">") // use HTML entity for > |
|
96 | 108 | ; |
|
97 |
if ( |
|
|
109 | if (hub.Browser.isMSIE) { | |
|
98 | 110 | block = block.replace(/(%[^\n]*)\n/g, "$1<br/>\n") |
|
99 | 111 | } |
|
100 | 112 | while (j > i) { |
@@ -40,7 +40,6 b' var IPython = (function (IPython) {' | |||
|
40 | 40 | onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this) |
|
41 | 41 | }); |
|
42 | 42 | // The tabindex=-1 makes this div focusable. |
|
43 | // id is a unique cell_id necessary for updating MathJax intelligently | |
|
44 | 43 | var render_area = $('<div/>').addClass('text_cell_render border-box-sizing'). |
|
45 | 44 | addClass('rendered_html').attr('tabindex','-1'); |
|
46 | 45 | cell.append(input_area).append(render_area); |
@@ -78,13 +77,6 b' var IPython = (function (IPython) {' | |||
|
78 | 77 | return false; |
|
79 | 78 | }; |
|
80 | 79 | |
|
81 | TextCell.prototype.typeset = function () { | |
|
82 | if (window.MathJax){ | |
|
83 | var cell_math = this.element.get(0); | |
|
84 | MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_math]); | |
|
85 | } | |
|
86 | }; | |
|
87 | ||
|
88 | 80 | |
|
89 | 81 | TextCell.prototype.select = function () { |
|
90 | 82 | IPython.Cell.prototype.select.apply(this); |
@@ -229,35 +221,33 b' var IPython = (function (IPython) {' | |||
|
229 | 221 | if (this.rendered === false) { |
|
230 | 222 | var text = this.get_text(); |
|
231 | 223 | if (text === "") { text = this.placeholder; } |
|
232 | else { | |
|
233 |
|
|
|
234 | var html = IPython.markdown_converter.makeHtml(text); | |
|
235 | html = IPython.mathjaxutils.replace_math(html) | |
|
236 | try { | |
|
237 | this.set_rendered(html); | |
|
238 | } catch (e) { | |
|
239 | console.log("Error running Javascript in Markdown:"); | |
|
240 | console.log(e); | |
|
241 | this.set_rendered($("<div/>").addClass("js-error").html( | |
|
242 | "Error rendering Markdown!<br/>" + e.toString()) | |
|
243 | ); | |
|
244 | } | |
|
245 | this.element.find('div.text_cell_input').hide(); | |
|
246 | this.element.find("div.text_cell_render").show(); | |
|
247 | var code_snippets = this.element.find("pre > code"); | |
|
248 | code_snippets.replaceWith(function () { | |
|
249 | var code = $(this).html(); | |
|
250 | /* Substitute br for newlines and for spaces | |
|
251 | before highlighting, since prettify doesn't | |
|
252 | preserve those on all browsers */ | |
|
253 | code = code.replace(/(\r\n|\n|\r)/gm, "<br/>"); | |
|
254 | code = code.replace(/ /gm, ' '); | |
|
255 | code = prettyPrintOne(code); | |
|
256 | ||
|
257 | return '<code class="prettyprint">' + code + '</code>'; | |
|
258 | }); | |
|
259 | this.typeset() | |
|
224 | text = IPython.mathjaxutils.remove_math(text) | |
|
225 | var html = IPython.markdown_converter.makeHtml(text); | |
|
226 | html = IPython.mathjaxutils.replace_math(html) | |
|
227 | try { | |
|
228 | this.set_rendered(html); | |
|
229 | } catch (e) { | |
|
230 | console.log("Error running Javascript in Markdown:"); | |
|
231 | console.log(e); | |
|
232 | this.set_rendered($("<div/>").addClass("js-error").html( | |
|
233 | "Error rendering Markdown!<br/>" + e.toString()) | |
|
234 | ); | |
|
260 | 235 | } |
|
236 | this.element.find('div.text_cell_input').hide(); | |
|
237 | this.element.find("div.text_cell_render").show(); | |
|
238 | var code_snippets = this.element.find("pre > code"); | |
|
239 | code_snippets.replaceWith(function () { | |
|
240 | var code = $(this).html(); | |
|
241 | /* Substitute br for newlines and for spaces | |
|
242 | before highlighting, since prettify doesn't | |
|
243 | preserve those on all browsers */ | |
|
244 | code = code.replace(/(\r\n|\n|\r)/gm, "<br/>"); | |
|
245 | code = code.replace(/ /gm, ' '); | |
|
246 | code = prettyPrintOne(code); | |
|
247 | ||
|
248 | return '<code class="prettyprint">' + code + '</code>'; | |
|
249 | }); | |
|
250 | this.typeset() | |
|
261 | 251 | this.rendered = true; |
|
262 | 252 | } |
|
263 | 253 | }; |
@@ -2,21 +2,7 b'' | |||
|
2 | 2 | {% block stylesheet %} |
|
3 | 3 | |
|
4 | 4 | {% if mathjax_url %} |
|
5 | <script type="text/x-mathjax-config"> | |
|
6 | MathJax.Hub.Config({ | |
|
7 | tex2jax: { | |
|
8 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
|
9 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
|
10 | processEnvironments: true | |
|
11 | }, | |
|
12 | displayAlign: 'left', // Change this to 'center' to center equations. | |
|
13 | "HTML-CSS": { | |
|
14 | styles: {'.MathJax_Display': {"margin": 0}} | |
|
15 | } | |
|
16 | }); | |
|
17 | </script> | |
|
18 | ||
|
19 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full" charset="utf-8"></script> | |
|
5 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script> | |
|
20 | 6 | {% end %} |
|
21 | 7 | <script type="text/javascript"> |
|
22 | 8 | // MathJax disabled, set as null to distingish from *missing* MathJax, |
@@ -3,21 +3,7 b'' | |||
|
3 | 3 | {% block stylesheet %} |
|
4 | 4 | |
|
5 | 5 | {% if mathjax_url %} |
|
6 | <script type="text/x-mathjax-config"> | |
|
7 | MathJax.Hub.Config({ | |
|
8 | tex2jax: { | |
|
9 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
|
10 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
|
11 | processEnvironments: true | |
|
12 | }, | |
|
13 | displayAlign: 'left', // Change this to 'center' to center equations. | |
|
14 | "HTML-CSS": { | |
|
15 | styles: {'.MathJax_Display': {"margin": 0}} | |
|
16 | } | |
|
17 | }); | |
|
18 | </script> | |
|
19 | ||
|
20 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full" charset="utf-8"></script> | |
|
6 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script> | |
|
21 | 7 | {% end %} |
|
22 | 8 | <script type="text/javascript"> |
|
23 | 9 | // MathJax disabled, set as null to distingish from *missing* MathJax, |
General Comments 0
You need to be logged in to leave comments.
Login now