Show More
@@ -51,14 +51,6 b' var IPython = (function (IPython) {' | |||
|
51 | 51 | }; |
|
52 | 52 | |
|
53 | 53 | |
|
54 | // typeset with MathJax if MathJax is available | |
|
55 | Cell.prototype.typeset = function () { | |
|
56 | if (window.MathJax){ | |
|
57 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); | |
|
58 | } | |
|
59 | }; | |
|
60 | ||
|
61 | ||
|
62 | 54 | Cell.prototype.select = function () { |
|
63 | 55 | this.element.addClass('ui-widget-content ui-corner-all'); |
|
64 | 56 | this.selected = true; |
@@ -16,18 +16,6 b' IPython.mathjaxutils = (function (IPython) {' | |||
|
16 | 16 | var init = function () { |
|
17 | 17 | if (window.MathJax) { |
|
18 | 18 | // MathJax loaded |
|
19 | MathJax.Hub.Config({ | |
|
20 | TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true } }, | |
|
21 | tex2jax: { | |
|
22 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
|
23 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
|
24 | processEnvironments: true | |
|
25 | }, | |
|
26 | displayAlign: 'left', // Change this to 'center' to center equations. | |
|
27 | "HTML-CSS": { | |
|
28 | styles: {'.MathJax_Display': {"margin": 0}} | |
|
29 | } | |
|
30 | }); | |
|
31 | 19 | } else if (window.mathjax_url != "") { |
|
32 | 20 | // Don't have MathJax, but should. Show dialog. |
|
33 | 21 | var dialog = $('<div></div>') |
@@ -225,8 +213,14 b' IPython.mathjaxutils = (function (IPython) {' | |||
|
225 | 213 | |
|
226 | 214 | var queue_render = function () { |
|
227 | 215 | // see https://groups.google.com/forum/?fromgroups=#!topic/mathjax-users/cpwy5eCH1ZQ |
|
216 | var jax = MathJax.Hub.getAllJax(); | |
|
217 | ||
|
228 | 218 | MathJax.Hub.Queue( |
|
229 | ["resetEquationNumbers",MathJax.InputJax.TeX], | |
|
219 | function () { | |
|
220 | if (MathJax.InputJax.TeX.resetEquationNumbers) { | |
|
221 | MathJax.InputJax.TeX.resetEquationNumbers(); | |
|
222 | } | |
|
223 | }, | |
|
230 | 224 | ["PreProcess",MathJax.Hub], |
|
231 | 225 | ["Reprocess",MathJax.Hub] |
|
232 | 226 | ); |
@@ -221,37 +221,36 b' var IPython = (function (IPython) {' | |||
|
221 | 221 | if (this.rendered === false) { |
|
222 | 222 | var text = this.get_text(); |
|
223 | 223 | if (text === "") { text = this.placeholder; } |
|
224 | ||
|
225 | text = IPython.mathjaxutils.remove_math(text) | |
|
226 | var html = IPython.markdown_converter.makeHtml(text); | |
|
227 | html = IPython.mathjaxutils.replace_math(html) | |
|
228 | ||
|
229 | try { | |
|
230 | this.set_rendered(html); | |
|
231 | } catch (e) { | |
|
232 | console.log("Error running Javascript in Markdown:"); | |
|
233 | console.log(e); | |
|
234 | this.set_rendered($("<div/>").addClass("js-error").html( | |
|
235 | "Error rendering Markdown!<br/>" + e.toString()) | |
|
236 |
|
|
|
224 | else { | |
|
225 | text = IPython.mathjaxutils.remove_math(text) | |
|
226 | var html = IPython.markdown_converter.makeHtml(text); | |
|
227 | html = IPython.mathjaxutils.replace_math(html) | |
|
228 | try { | |
|
229 | this.set_rendered(html); | |
|
230 | } catch (e) { | |
|
231 | console.log("Error running Javascript in Markdown:"); | |
|
232 | console.log(e); | |
|
233 | this.set_rendered($("<div/>").addClass("js-error").html( | |
|
234 | "Error rendering Markdown!<br/>" + e.toString()) | |
|
235 | ); | |
|
236 | } | |
|
237 | this.element.find('div.text_cell_input').hide(); | |
|
238 | this.element.find("div.text_cell_render").show(); | |
|
239 | var code_snippets = this.element.find("pre > code"); | |
|
240 | code_snippets.replaceWith(function () { | |
|
241 | var code = $(this).html(); | |
|
242 | /* Substitute br for newlines and for spaces | |
|
243 | before highlighting, since prettify doesn't | |
|
244 | preserve those on all browsers */ | |
|
245 | code = code.replace(/(\r\n|\n|\r)/gm, "<br/>"); | |
|
246 | code = code.replace(/ /gm, ' '); | |
|
247 | code = prettyPrintOne(code); | |
|
248 | ||
|
249 | return '<code class="prettyprint">' + code + '</code>'; | |
|
250 | }); | |
|
251 | ||
|
252 | IPython.mathjaxutils.queue_render() | |
|
237 | 253 | } |
|
238 | this.typeset() | |
|
239 | this.element.find('div.text_cell_input').hide(); | |
|
240 | this.element.find("div.text_cell_render").show(); | |
|
241 | var code_snippets = this.element.find("pre > code"); | |
|
242 | code_snippets.replaceWith(function () { | |
|
243 | var code = $(this).html(); | |
|
244 | /* Substitute br for newlines and for spaces | |
|
245 | before highlighting, since prettify doesn't | |
|
246 | preserve those on all browsers */ | |
|
247 | code = code.replace(/(\r\n|\n|\r)/gm, "<br/>"); | |
|
248 | code = code.replace(/ /gm, ' '); | |
|
249 | code = prettyPrintOne(code); | |
|
250 | ||
|
251 | return '<code class="prettyprint">' + code + '</code>'; | |
|
252 | }); | |
|
253 | ||
|
254 | IPython.mathjaxutils.queue_render() | |
|
255 | 254 | this.rendered = true; |
|
256 | 255 | } |
|
257 | 256 | }; |
@@ -2,6 +2,21 b'' | |||
|
2 | 2 | {% block stylesheet %} |
|
3 | 3 | |
|
4 | 4 | {% if mathjax_url %} |
|
5 | <script type="text/x-mathjax-config"> | |
|
6 | MathJax.Hub.Config({ | |
|
7 | TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true } }, | |
|
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 | ||
|
5 | 20 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script> |
|
6 | 21 | {% end %} |
|
7 | 22 | <script type="text/javascript"> |
@@ -3,6 +3,21 b'' | |||
|
3 | 3 | {% block stylesheet %} |
|
4 | 4 | |
|
5 | 5 | {% if mathjax_url %} |
|
6 | <script type="text/x-mathjax-config"> | |
|
7 | MathJax.Hub.Config({ | |
|
8 | TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true } }, | |
|
9 | tex2jax: { | |
|
10 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
|
11 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
|
12 | processEnvironments: true | |
|
13 | }, | |
|
14 | displayAlign: 'left', // Change this to 'center' to center equations. | |
|
15 | "HTML-CSS": { | |
|
16 | styles: {'.MathJax_Display': {"margin": 0}} | |
|
17 | } | |
|
18 | }); | |
|
19 | </script> | |
|
20 | ||
|
6 | 21 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script> |
|
7 | 22 | {% end %} |
|
8 | 23 | <script type="text/javascript"> |
General Comments 0
You need to be logged in to leave comments.
Login now