Show More
@@ -50,6 +50,9 b' var IPython = (function (IPython) {' | |||||
50 | }); |
|
50 | }); | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
|
53 | // prototype typeset method does nothing, see TextCell typeset | |||
|
54 | Cell.prototype.typeset = function () { | |||
|
55 | }; | |||
53 |
|
56 | |||
54 | Cell.prototype.select = function () { |
|
57 | Cell.prototype.select = function () { | |
55 | this.element.addClass('ui-widget-content ui-corner-all'); |
|
58 | this.element.addClass('ui-widget-content ui-corner-all'); |
@@ -14,7 +14,7 b" IPython.namespace('IPython.mathjaxutils');" | |||||
14 | IPython.mathjaxutils = (function (IPython) { |
|
14 | IPython.mathjaxutils = (function (IPython) { | |
15 |
|
15 | |||
16 | var init = function () { |
|
16 | var init = function () { | |
17 |
if (window.MathJax) { |
|
17 | if (window.MathJax) { | |
18 | // MathJax loaded |
|
18 | // MathJax loaded | |
19 | } else if (window.mathjax_url != "") { |
|
19 | } else if (window.mathjax_url != "") { | |
20 | // Don't have MathJax, but should. Show dialog. |
|
20 | // Don't have MathJax, but should. Show dialog. | |
@@ -76,7 +76,6 b' IPython.mathjaxutils = (function (IPython) {' | |||||
76 | var inline = "$"; // the inline math delimiter |
|
76 | var inline = "$"; // the inline math delimiter | |
77 | var blocks, start, end, last, braces; // used in searching for math |
|
77 | var blocks, start, end, last, braces; // used in searching for math | |
78 | var math; // stores math until pagedown (Markdown parser) is done |
|
78 | var math; // stores math until pagedown (Markdown parser) is done | |
79 | var HUB = MathJax.Hub; |
|
|||
80 |
|
79 | |||
81 | // MATHSPLIT contains the pattern for math delimiters and special symbols |
|
80 | // MATHSPLIT contains the pattern for math delimiters and special symbols | |
82 | // needed for searching for math in the text input. |
|
81 | // needed for searching for math in the text input. | |
@@ -90,6 +89,7 b' IPython.mathjaxutils = (function (IPython) {' | |||||
90 | // math, then push the math string onto the storage array. |
|
89 | // math, then push the math string onto the storage array. | |
91 | // The preProcess function is called on all blocks if it has been passed in |
|
90 | // The preProcess function is called on all blocks if it has been passed in | |
92 | var process_math = function (i, j, pre_process) { |
|
91 | var process_math = function (i, j, pre_process) { | |
|
92 | var HUB = MathJax.Hub; | |||
93 | var block = blocks.slice(i, j + 1).join("").replace(/&/g, "&") // use HTML entity for & |
|
93 | var block = blocks.slice(i, j + 1).join("").replace(/&/g, "&") // use HTML entity for & | |
94 | .replace(/</g, "<") // use HTML entity for < |
|
94 | .replace(/</g, "<") // use HTML entity for < | |
95 | .replace(/>/g, ">") // use HTML entity for > |
|
95 | .replace(/>/g, ">") // use HTML entity for > | |
@@ -115,6 +115,10 b' IPython.mathjaxutils = (function (IPython) {' | |||||
115 | // (which will be a paragraph). |
|
115 | // (which will be a paragraph). | |
116 | // |
|
116 | // | |
117 | var remove_math = function (text) { |
|
117 | var remove_math = function (text) { | |
|
118 | if (!window.MathJax) { | |||
|
119 | return text; | |||
|
120 | } | |||
|
121 | ||||
118 | start = end = last = null; // for tracking math delimiters |
|
122 | start = end = last = null; // for tracking math delimiters | |
119 | math = []; // stores math strings for later |
|
123 | math = []; // stores math strings for later | |
120 |
|
124 | |||
@@ -204,6 +208,10 b' IPython.mathjaxutils = (function (IPython) {' | |||||
204 | // and clear the math array (no need to keep it around). |
|
208 | // and clear the math array (no need to keep it around). | |
205 | // |
|
209 | // | |
206 | var replace_math = function (text) { |
|
210 | var replace_math = function (text) { | |
|
211 | if (!window.MathJax) { | |||
|
212 | return text; | |||
|
213 | } | |||
|
214 | ||||
207 | text = text.replace(/@@(\d+)@@/g, function (match, n) { |
|
215 | text = text.replace(/@@(\d+)@@/g, function (match, n) { | |
208 | return math[n] |
|
216 | return math[n] | |
209 | }); |
|
217 | }); | |
@@ -211,27 +219,11 b' IPython.mathjaxutils = (function (IPython) {' | |||||
211 | return text; |
|
219 | return text; | |
212 | } |
|
220 | } | |
213 |
|
221 | |||
214 | var queue_render = function () { |
|
|||
215 | // see https://groups.google.com/forum/?fromgroups=#!topic/mathjax-users/cpwy5eCH1ZQ |
|
|||
216 | var jax = MathJax.Hub.getAllJax(); |
|
|||
217 |
|
||||
218 | MathJax.Hub.Queue( |
|
|||
219 | function () { |
|
|||
220 | if (MathJax.InputJax.TeX.resetEquationNumbers) { |
|
|||
221 | MathJax.InputJax.TeX.resetEquationNumbers(); |
|
|||
222 | } |
|
|||
223 | }, |
|
|||
224 | ["PreProcess",MathJax.Hub], |
|
|||
225 | ["Reprocess",MathJax.Hub] |
|
|||
226 | ); |
|
|||
227 | } |
|
|||
228 |
|
||||
229 | return { |
|
222 | return { | |
230 | init : init, |
|
223 | init : init, | |
231 | process_math : process_math, |
|
224 | process_math : process_math, | |
232 | remove_math : remove_math, |
|
225 | remove_math : remove_math, | |
233 |
replace_math : replace_math |
|
226 | replace_math : replace_math | |
234 | queue_render : queue_render |
|
|||
235 | }; |
|
227 | }; | |
236 |
|
228 | |||
237 | }(IPython)); No newline at end of file |
|
229 | }(IPython)); |
@@ -39,9 +39,11 b' var IPython = (function (IPython) {' | |||||
39 | extraKeys: {"Tab": "indentMore","Shift-Tab" : "indentLess"}, |
|
39 | extraKeys: {"Tab": "indentMore","Shift-Tab" : "indentLess"}, | |
40 | onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this) |
|
40 | onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this) | |
41 | }); |
|
41 | }); | |
|
42 | this.cell_id = IPython.utils.uuid(); | |||
42 | // The tabindex=-1 makes this div focusable. |
|
43 | // The tabindex=-1 makes this div focusable. | |
|
44 | // id is a unique cell_id necessary for updating MathJax intelligently | |||
43 | var render_area = $('<div/>').addClass('text_cell_render border-box-sizing'). |
|
45 | var render_area = $('<div/>').addClass('text_cell_render border-box-sizing'). | |
44 | addClass('rendered_html').attr('tabindex','-1'); |
|
46 | addClass('rendered_html').attr('tabindex','-1').attr('id',this.cell_id); | |
45 | cell.append(input_area).append(render_area); |
|
47 | cell.append(input_area).append(render_area); | |
46 | this.element = cell; |
|
48 | this.element = cell; | |
47 | }; |
|
49 | }; | |
@@ -77,6 +79,13 b' var IPython = (function (IPython) {' | |||||
77 | return false; |
|
79 | return false; | |
78 | }; |
|
80 | }; | |
79 |
|
81 | |||
|
82 | TextCell.prototype.typeset = function () { | |||
|
83 | if (window.MathJax){ | |||
|
84 | var cell_math = document.getElementById(this.cell_id); | |||
|
85 | MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_math]); | |||
|
86 | } | |||
|
87 | }; | |||
|
88 | ||||
80 |
|
89 | |||
81 | TextCell.prototype.select = function () { |
|
90 | TextCell.prototype.select = function () { | |
82 | IPython.Cell.prototype.select.apply(this); |
|
91 | IPython.Cell.prototype.select.apply(this); | |
@@ -248,8 +257,7 b' var IPython = (function (IPython) {' | |||||
248 |
|
257 | |||
249 | return '<code class="prettyprint">' + code + '</code>'; |
|
258 | return '<code class="prettyprint">' + code + '</code>'; | |
250 | }); |
|
259 | }); | |
251 |
|
260 | this.typeset() | ||
252 | IPython.mathjaxutils.queue_render() |
|
|||
253 | } |
|
261 | } | |
254 | this.rendered = true; |
|
262 | this.rendered = true; | |
255 | } |
|
263 | } |
@@ -4,7 +4,6 b'' | |||||
4 | {% if mathjax_url %} |
|
4 | {% if mathjax_url %} | |
5 | <script type="text/x-mathjax-config"> |
|
5 | <script type="text/x-mathjax-config"> | |
6 | MathJax.Hub.Config({ |
|
6 | MathJax.Hub.Config({ | |
7 | TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true } }, |
|
|||
8 | tex2jax: { |
|
7 | tex2jax: { | |
9 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
8 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
10 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], |
|
9 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
@@ -17,7 +16,7 b'' | |||||
17 | }); |
|
16 | }); | |
18 | </script> |
|
17 | </script> | |
19 |
|
18 | |||
20 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script> |
|
19 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full" charset="utf-8"></script> | |
21 | {% end %} |
|
20 | {% end %} | |
22 | <script type="text/javascript"> |
|
21 | <script type="text/javascript"> | |
23 | // MathJax disabled, set as null to distingish from *missing* MathJax, |
|
22 | // MathJax disabled, set as null to distingish from *missing* MathJax, |
@@ -5,7 +5,6 b'' | |||||
5 | {% if mathjax_url %} |
|
5 | {% if mathjax_url %} | |
6 | <script type="text/x-mathjax-config"> |
|
6 | <script type="text/x-mathjax-config"> | |
7 | MathJax.Hub.Config({ |
|
7 | MathJax.Hub.Config({ | |
8 | TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true } }, |
|
|||
9 | tex2jax: { |
|
8 | tex2jax: { | |
10 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
9 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
11 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], |
|
10 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
@@ -18,7 +17,7 b'' | |||||
18 | }); |
|
17 | }); | |
19 | </script> |
|
18 | </script> | |
20 |
|
19 | |||
21 | <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-full" charset="utf-8"></script> | |
22 | {% end %} |
|
21 | {% end %} | |
23 | <script type="text/javascript"> |
|
22 | <script type="text/javascript"> | |
24 | // MathJax disabled, set as null to distingish from *missing* MathJax, |
|
23 | // MathJax disabled, set as null to distingish from *missing* MathJax, |
@@ -162,87 +162,7 b'' | |||||
162 | "\n", |
|
162 | "\n", | |
163 | "---\n", |
|
163 | "---\n", | |
164 | "\n", |
|
164 | "\n", | |
165 | "These equation reference examples are adapted from an [example page in the MathJax documentation](http://cdn.mathjax.org/mathjax/latest/test/sample-eqrefs.html). Note that it's okay to reference equations across cells. Click inside this cell to see the source.\n", |
|
165 | "Equation numbering and referencing will be available in a future version of IPython." | |
166 | "\n", |
|
|||
167 | "## Labeled equations and references\n", |
|
|||
168 | "\n", |
|
|||
169 | "Here is a labeled equation:\n", |
|
|||
170 | "\\begin{equation}\n", |
|
|||
171 | "x+1\\over\\sqrt{1-x^2}\\label{ref1}\n", |
|
|||
172 | "\\end{equation}\n", |
|
|||
173 | "\n", |
|
|||
174 | "with a reference to ref1: \\ref{ref1},\n", |
|
|||
175 | "and another numbered one with no label:\n", |
|
|||
176 | "\\begin{equation}\n", |
|
|||
177 | "x+1\\over\\sqrt{1-x^2}\n", |
|
|||
178 | "\\end{equation}" |
|
|||
179 | ] |
|
|||
180 | }, |
|
|||
181 | { |
|
|||
182 | "cell_type": "markdown", |
|
|||
183 | "metadata": {}, |
|
|||
184 | "source": [ |
|
|||
185 | "## \\nonumber and equation*\n", |
|
|||
186 | "\n", |
|
|||
187 | "This one uses \\nonumber:\n", |
|
|||
188 | "\\begin{equation}\n", |
|
|||
189 | "x+1\\over\\sqrt{1-x^2}\\nonumber\n", |
|
|||
190 | "\\end{equation}\n", |
|
|||
191 | "\n", |
|
|||
192 | "Here's one with the equation* environment:\n", |
|
|||
193 | "\\begin{equation*}\n", |
|
|||
194 | "x+1\\over\\sqrt{1-x^2}\n", |
|
|||
195 | "\\end{equation*}" |
|
|||
196 | ] |
|
|||
197 | }, |
|
|||
198 | { |
|
|||
199 | "cell_type": "markdown", |
|
|||
200 | "metadata": {}, |
|
|||
201 | "source": [ |
|
|||
202 | "## Forward references\n", |
|
|||
203 | "\n", |
|
|||
204 | "This is a forward reference [\\ref{ref2}] and another \\eqref{ref2} for the \n", |
|
|||
205 | "following equation:\n", |
|
|||
206 | "\n", |
|
|||
207 | "\\begin{equation}\n", |
|
|||
208 | "x+1\\over\\sqrt{1-x^2}\\label{ref2}\n", |
|
|||
209 | "\\end{equation}\n", |
|
|||
210 | "\n", |
|
|||
211 | "More math:\n", |
|
|||
212 | "\\begin{equation}\n", |
|
|||
213 | "x+1\\over\\sqrt{1-x^2}\n", |
|
|||
214 | "\\end{equation}" |
|
|||
215 | ] |
|
|||
216 | }, |
|
|||
217 | { |
|
|||
218 | "cell_type": "markdown", |
|
|||
219 | "metadata": {}, |
|
|||
220 | "source": [ |
|
|||
221 | "### References inline and in environments\n", |
|
|||
222 | "\n", |
|
|||
223 | "Here is a ref inside math: $\\ref{ref2}+1$ and text after it.\n", |
|
|||
224 | "\n", |
|
|||
225 | "\\begin{align} \n", |
|
|||
226 | "x& = y_1-y_2+y_3-y_5+y_8-\\dots \n", |
|
|||
227 | "&& \\text{by \\eqref{ref1}}\\\\ \n", |
|
|||
228 | "& = y'\\circ y^* && \\text{(by \\eqref{ref3})}\\\\ \n", |
|
|||
229 | "& = y(0) y' && \\text {by Axiom 1.} \n", |
|
|||
230 | "\\end{align} \n", |
|
|||
231 | "\n", |
|
|||
232 | "### Missing references\n", |
|
|||
233 | "Here's a bad ref [\\ref{ref4}] to a nonexistent label.\n", |
|
|||
234 | "\n", |
|
|||
235 | "### Numbering align environments\n", |
|
|||
236 | "An alignment:\n", |
|
|||
237 | "\\begin{align}\n", |
|
|||
238 | "a&=b\\label{ref3}\\cr\n", |
|
|||
239 | "&=c+d\n", |
|
|||
240 | "\\end{align}\n", |
|
|||
241 | "and a starred one:\n", |
|
|||
242 | "\\begin{align*}\n", |
|
|||
243 | "a&=b\\cr\n", |
|
|||
244 | "&=c+d\n", |
|
|||
245 | "\\end{align*}" |
|
|||
246 | ] |
|
166 | ] | |
247 | }, |
|
167 | }, | |
248 | { |
|
168 | { |
General Comments 0
You need to be logged in to leave comments.
Login now