##// END OF EJS Templates
Improved MathJax, missing callback workaround...
Aron Ahmadia -
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 Cell.prototype.select = function () {
54 Cell.prototype.select = function () {
63 this.element.addClass('ui-widget-content ui-corner-all');
55 this.element.addClass('ui-widget-content ui-corner-all');
64 this.selected = true;
56 this.selected = true;
@@ -16,18 +16,6 b' IPython.mathjaxutils = (function (IPython) {'
16 var init = function () {
16 var init = function () {
17 if (window.MathJax) {
17 if (window.MathJax) {
18 // MathJax loaded
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 } else if (window.mathjax_url != "") {
19 } else if (window.mathjax_url != "") {
32 // Don't have MathJax, but should. Show dialog.
20 // Don't have MathJax, but should. Show dialog.
33 var dialog = $('<div></div>')
21 var dialog = $('<div></div>')
@@ -225,8 +213,14 b' IPython.mathjaxutils = (function (IPython) {'
225
213
226 var queue_render = function () {
214 var queue_render = function () {
227 // see https://groups.google.com/forum/?fromgroups=#!topic/mathjax-users/cpwy5eCH1ZQ
215 // see https://groups.google.com/forum/?fromgroups=#!topic/mathjax-users/cpwy5eCH1ZQ
216 var jax = MathJax.Hub.getAllJax();
217
228 MathJax.Hub.Queue(
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 ["PreProcess",MathJax.Hub],
224 ["PreProcess",MathJax.Hub],
231 ["Reprocess",MathJax.Hub]
225 ["Reprocess",MathJax.Hub]
232 );
226 );
@@ -221,37 +221,36 b' var IPython = (function (IPython) {'
221 if (this.rendered === false) {
221 if (this.rendered === false) {
222 var text = this.get_text();
222 var text = this.get_text();
223 if (text === "") { text = this.placeholder; }
223 if (text === "") { text = this.placeholder; }
224
224 else {
225 text = IPython.mathjaxutils.remove_math(text)
225 text = IPython.mathjaxutils.remove_math(text)
226 var html = IPython.markdown_converter.makeHtml(text);
226 var html = IPython.markdown_converter.makeHtml(text);
227 html = IPython.mathjaxutils.replace_math(html)
227 html = IPython.mathjaxutils.replace_math(html)
228
228 try {
229 try {
229 this.set_rendered(html);
230 this.set_rendered(html);
230 } catch (e) {
231 } catch (e) {
231 console.log("Error running Javascript in Markdown:");
232 console.log("Error running Javascript in Markdown:");
232 console.log(e);
233 console.log(e);
233 this.set_rendered($("<div/>").addClass("js-error").html(
234 this.set_rendered($("<div/>").addClass("js-error").html(
234 "Error rendering Markdown!<br/>" + e.toString())
235 "Error rendering Markdown!<br/>" + e.toString())
235 );
236 );
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 &nbsp; 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, '&nbsp;');
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 &nbsp; 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, '&nbsp;');
249 code = prettyPrintOne(code);
250
251 return '<code class="prettyprint">' + code + '</code>';
252 });
253
254 IPython.mathjaxutils.queue_render()
255 this.rendered = true;
254 this.rendered = true;
256 }
255 }
257 };
256 };
@@ -2,6 +2,21 b''
2 {% block stylesheet %}
2 {% block stylesheet %}
3
3
4 {% if mathjax_url %}
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 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
20 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
6 {% end %}
21 {% end %}
7 <script type="text/javascript">
22 <script type="text/javascript">
@@ -3,6 +3,21 b''
3 {% block stylesheet %}
3 {% block stylesheet %}
4
4
5 {% if mathjax_url %}
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 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
21 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
7 {% end %}
22 {% end %}
8 <script type="text/javascript">
23 <script type="text/javascript">
@@ -331,14 +331,6 b''
331 "x=4\n",
331 "x=4\n",
332 "$$"
332 "$$"
333 ]
333 ]
334 },
335 {
336 "cell_type": "code",
337 "collapsed": false,
338 "input": [],
339 "language": "python",
340 "metadata": {},
341 "outputs": []
342 }
334 }
343 ],
335 ],
344 "metadata": {}
336 "metadata": {}
General Comments 0
You need to be logged in to leave comments. Login now