Show More
@@ -219,7 +219,7 b' class NewHandler(AuthenticatedHandler):' | |||||
219 | base_project_url=u'/', base_kernel_url=u'/', |
|
219 | base_project_url=u'/', base_kernel_url=u'/', | |
220 | kill_kernel=False, |
|
220 | kill_kernel=False, | |
221 | read_only=False, |
|
221 | read_only=False, | |
222 |
|
|
222 | mathjax_url=self.application.ipython_app.mathjax_url, | |
223 | ) |
|
223 | ) | |
224 |
|
224 | |||
225 |
|
225 | |||
@@ -238,7 +238,7 b' class NamedNotebookHandler(AuthenticatedHandler):' | |||||
238 | base_project_url=u'/', base_kernel_url=u'/', |
|
238 | base_project_url=u'/', base_kernel_url=u'/', | |
239 | kill_kernel=False, |
|
239 | kill_kernel=False, | |
240 | read_only=self.read_only, |
|
240 | read_only=self.read_only, | |
241 |
|
|
241 | mathjax_url=self.application.ipython_app.mathjax_url, | |
242 | ) |
|
242 | ) | |
243 |
|
243 | |||
244 |
|
244 |
@@ -252,6 +252,31 b' class NotebookApp(BaseIPythonApplication):' | |||||
252 | When disabled, equations etc. will appear as their untransformed TeX source. |
|
252 | When disabled, equations etc. will appear as their untransformed TeX source. | |
253 | """ |
|
253 | """ | |
254 | ) |
|
254 | ) | |
|
255 | def _enable_mathjax_changed(self, name, old, new): | |||
|
256 | """set mathjax url to empty if mathjax is disabled""" | |||
|
257 | if not new: | |||
|
258 | self.mathjax_url = u'' | |||
|
259 | ||||
|
260 | mathjax_url = Unicode("", config=True, | |||
|
261 | help="""The url for MathJax.js.""" | |||
|
262 | ) | |||
|
263 | def _mathjax_url_default(self): | |||
|
264 | if not self.enable_mathjax: | |||
|
265 | return u'' | |||
|
266 | static_path = os.path.join(os.path.dirname(__file__), "static") | |||
|
267 | if os.path.exists(os.path.join(static_path, 'mathjax', "MathJax.js")): | |||
|
268 | self.log.info("Using local MathJax") | |||
|
269 | return u"static/mathjax/MathJax.js" | |||
|
270 | else: | |||
|
271 | self.log.info("Using MathJax from CDN") | |||
|
272 | return u"http://cdn.mathjax.org/mathjax/latest/MathJax.js" | |||
|
273 | ||||
|
274 | def _mathjax_url_changed(self, name, old, new): | |||
|
275 | if new and not self.enable_mathjax: | |||
|
276 | # enable_mathjax=False overrides mathjax_url | |||
|
277 | self.mathjax_url = u'' | |||
|
278 | else: | |||
|
279 | self.log.info("Using MathJax: %s", new) | |||
255 |
|
280 | |||
256 | def parse_command_line(self, argv=None): |
|
281 | def parse_command_line(self, argv=None): | |
257 | super(NotebookApp, self).parse_command_line(argv) |
|
282 | super(NotebookApp, self).parse_command_line(argv) |
@@ -11,48 +11,8 b'' | |||||
11 |
|
11 | |||
12 |
|
12 | |||
13 | $(document).ready(function () { |
|
13 | $(document).ready(function () { | |
14 |
|
14 | if (window.MathJax){ | ||
15 | if (window.MathJax == undefined){ |
|
15 | // MathJax loaded | |
16 | // MathJax undefined, but expected. Draw warning. |
|
|||
17 | window.MathJax = null; |
|
|||
18 | var dialog = $('<div></div>').html( |
|
|||
19 | "<p class='dialog'>"+ |
|
|||
20 | "We were unable to retrieve MathJax. Math/LaTeX rendering will be disabled."+ |
|
|||
21 | "</p>"+ |
|
|||
22 | "<p class='dialog'>"+ |
|
|||
23 | "With a working internet connection, you can run the following at a Python"+ |
|
|||
24 | " or IPython prompt, which will install a local copy of MathJax:"+ |
|
|||
25 | "</p>"+ |
|
|||
26 | "<pre class='dialog'>"+ |
|
|||
27 | ">>> from IPython.external import mathjax; mathjax.install_mathjax()"+ |
|
|||
28 | "</pre>"+ |
|
|||
29 | "<p class='dialog'>"+ |
|
|||
30 | "This will try to install MathJax into the directory where you installed"+ |
|
|||
31 | " IPython. If you installed IPython to a location that requires"+ |
|
|||
32 | " administrative privileges to write, you will need to make this call as"+ |
|
|||
33 | " an administrator."+ |
|
|||
34 | "</p>"+ |
|
|||
35 | "<p class='dialog'>"+ |
|
|||
36 | "On OSX/Linux/Unix, this can be done at the command-line via:"+ |
|
|||
37 | "</p>"+ |
|
|||
38 | "<pre class='dialog'>"+ |
|
|||
39 | "$ sudo python -c 'from IPython.external import mathjax; mathjax.install_mathjax()'"+ |
|
|||
40 | "</pre>"+ |
|
|||
41 | "<p class='dialog'>"+ |
|
|||
42 | "Or you can instruct the notebook server to start without MathJax support, with:"+ |
|
|||
43 | "<pre class='dialog'>"+ |
|
|||
44 | "</p>"+ |
|
|||
45 | "$ ipython notebook --no-mathjax"+ |
|
|||
46 | "</pre>"+ |
|
|||
47 | "<p class='dialog'>"+ |
|
|||
48 | "in which case, equations will not be rendered."+ |
|
|||
49 | "</p>" |
|
|||
50 | ).dialog({ |
|
|||
51 | title: 'MathJax disabled', |
|
|||
52 | width: "70%", |
|
|||
53 | modal: true, |
|
|||
54 | }) |
|
|||
55 | }else if (window.MathJax){ |
|
|||
56 | MathJax.Hub.Config({ |
|
16 | MathJax.Hub.Config({ | |
57 | tex2jax: { |
|
17 | tex2jax: { | |
58 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
18 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
@@ -63,9 +23,49 b' $(document).ready(function () {' | |||||
63 | styles: {'.MathJax_Display': {"margin": 0}} |
|
23 | styles: {'.MathJax_Display': {"margin": 0}} | |
64 | } |
|
24 | } | |
65 | }); |
|
25 | }); | |
|
26 | }else if (window.mathjax_url != ""){ | |||
|
27 | // Don't have MathJax, but should. Show dialog. | |||
|
28 | var dialog = $('<div></div>') | |||
|
29 | .append( | |||
|
30 | $("<p></p>").addClass('dialog').html( | |||
|
31 | "Math/LaTeX equation rendering will be disabled." | |||
|
32 | ) | |||
|
33 | ).append( | |||
|
34 | $("<p></p>").addClass('dialog').html( | |||
|
35 | "With a working internet connection, you can install a local copy" + | |||
|
36 | " of MathJax for offline use with the following command at a Python" + | |||
|
37 | " or IPython prompt:" | |||
|
38 | ) | |||
|
39 | ).append( | |||
|
40 | $("<pre></pre>").addClass('dialog').html( | |||
|
41 | ">>> from IPython.external import mathjax; mathjax.install_mathjax()" | |||
|
42 | ) | |||
|
43 | ).append( | |||
|
44 | $("<p></p>").addClass('dialog').html( | |||
|
45 | "This will try to install MathJax into the directory where you installed"+ | |||
|
46 | " IPython. If you installed IPython to a location that requires"+ | |||
|
47 | " administrative privileges to write, you will need to make this call as"+ | |||
|
48 | " an administrator, via 'sudo'." | |||
|
49 | ) | |||
|
50 | ).append( | |||
|
51 | $("<p></p>").addClass('dialog').html( | |||
|
52 | "Or you can instruct the notebook server to disable MathJax support altogether:" | |||
|
53 | ) | |||
|
54 | ).append( | |||
|
55 | $("<pre></pre>").addClass('dialog').html( | |||
|
56 | "$ ipython notebook --no-mathjax" | |||
|
57 | ) | |||
|
58 | ).append( | |||
|
59 | $("<p></p>").addClass('dialog').html( | |||
|
60 | "which will prevent this dialog from appearing." | |||
|
61 | ) | |||
|
62 | ).dialog({ | |||
|
63 | title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'", | |||
|
64 | width: "70%", | |||
|
65 | modal: true, | |||
|
66 | }) | |||
66 | }else{ |
|
67 | }else{ | |
67 | // window.MathJax == null |
|
68 | // No MathJax, but none expected. No dialog. | |
68 | // --no-mathjax mode |
|
|||
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | IPython.markdown_converter = new Markdown.Converter(); |
|
71 | IPython.markdown_converter = new Markdown.Converter(); |
@@ -6,24 +6,14 b'' | |||||
6 |
|
6 | |||
7 | <title>IPython Notebook</title> |
|
7 | <title>IPython Notebook</title> | |
8 |
|
8 | |||
9 |
{% if |
|
9 | {% if mathjax_url %} | |
10 |
|
|
10 | <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script> | |
11 | <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> |
|
11 | {% end %} | |
12 | <script type="text/javascript"> |
|
|||
13 | if (typeof(MathJax) == 'undefined') { |
|
|||
14 | console.log("No local MathJax, loading from CDN"); |
|
|||
15 | document.write(unescape("%3Cscript type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E")); |
|
|||
16 | }else{ |
|
|||
17 | console.log("Using local MathJax"); |
|
|||
18 | } |
|
|||
19 | </script> |
|
|||
20 | {% else %} |
|
|||
21 | <script type="text/javascript"> |
|
12 | <script type="text/javascript"> | |
22 | // MathJax disabled, set as null to distingish from *missing* MathJax, |
|
13 | // MathJax disabled, set as null to distingish from *missing* MathJax, | |
23 | // where it will be undefined, and should prompt a dialog later. |
|
14 | // where it will be undefined, and should prompt a dialog later. | |
24 |
window. |
|
15 | window.mathjax_url = "{{mathjax_url}}"; | |
25 | </script> |
|
16 | </script> | |
26 | {% end %} |
|
|||
27 |
|
17 | |||
28 | <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" /> |
|
18 | <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" /> | |
29 | <link rel="stylesheet" href="static/codemirror/lib/codemirror.css"> |
|
19 | <link rel="stylesheet" href="static/codemirror/lib/codemirror.css"> |
General Comments 0
You need to be logged in to leave comments.
Login now