##// END OF EJS Templates
allow the notebook to run without MathJax...
MinRK -
Show More
@@ -219,6 +219,7 b' class NewHandler(AuthenticatedHandler):'
219 219 base_project_url=u'/', base_kernel_url=u'/',
220 220 kill_kernel=False,
221 221 read_only=False,
222 enable_mathjax=self.application.ipython_app.enable_mathjax,
222 223 )
223 224
224 225
@@ -237,6 +238,7 b' class NamedNotebookHandler(AuthenticatedHandler):'
237 238 base_project_url=u'/', base_kernel_url=u'/',
238 239 kill_kernel=False,
239 240 read_only=self.read_only,
241 enable_mathjax=self.application.ipython_app.enable_mathjax,
240 242 )
241 243
242 244
@@ -128,6 +128,17 b" flags['no-browser']=("
128 128 {'NotebookApp' : {'open_browser' : False}},
129 129 "Don't open the notebook in a browser after startup."
130 130 )
131 flags['no-mathjax']=(
132 {'NotebookApp' : {'enable_mathjax' : False}},
133 """Disable MathJax
134
135 MathJax is the javascript library IPython uses to render math/LaTeX. It is
136 very large, so you may want to disable it if you have a slow internet
137 connection, or for offline use of the notebook.
138
139 When disabled, equations etc. will appear as their untransformed TeX source.
140 """
141 )
131 142 flags['read-only'] = (
132 143 {'NotebookApp' : {'read_only' : True}},
133 144 """Allow read-only access to notebooks.
@@ -144,7 +155,7 b" flags['read-only'] = ("
144 155 # the flags that are specific to the frontend
145 156 # these must be scrubbed before being passed to the kernel,
146 157 # or it will raise an error on unrecognized flags
147 notebook_flags = ['no-browser', 'read-only']
158 notebook_flags = ['no-browser', 'no-mathjax', 'read-only']
148 159
149 160 aliases = dict(ipkernel_aliases)
150 161
@@ -231,6 +242,17 b' class NotebookApp(BaseIPythonApplication):'
231 242 help="Whether to prevent editing/execution of notebooks."
232 243 )
233 244
245 enable_mathjax = Bool(True, config=True,
246 help="""Whether to enable MathJax for typesetting math/TeX
247
248 MathJax is the javascript library IPython uses to render math/LaTeX. It is
249 very large, so you may want to disable it if you have a slow internet
250 connection, or for offline use of the notebook.
251
252 When disabled, equations etc. will appear as their untransformed TeX source.
253 """
254 )
255
234 256 def parse_command_line(self, argv=None):
235 257 super(NotebookApp, self).parse_command_line(argv)
236 258 if argv is None:
@@ -415,6 +415,18 b' div.text_cell_render {'
415 415 font-family: monospace;
416 416 }
417 417
418 pre.dialog {
419 background-color: #f7f7f7;
420 border: 1px solid #ddd;
421 border-radius: 3px;
422 padding: 0.4em;
423 padding-left: 2em;
424 }
425
426 p.dialog{
427 padding : 0.2em;
428 }
429
418 430 @media print {
419 431 body { overflow: visible !important; }
420 432 .ui-widget-content { border: 0px; }
@@ -88,6 +88,13 b' var IPython = (function (IPython) {'
88 88 // Subclasses must implement create_element.
89 89 Cell.prototype.create_element = function () {};
90 90
91 // typeset with MathJax if MathJax is available
92 Cell.prototype.typeset = function () {
93 if (window.MathJax){
94 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
95 }
96 };
97
91 98 IPython.Cell = Cell;
92 99
93 100 return IPython;
@@ -520,7 +520,7 b' var IPython = (function (IPython) {'
520 520 this.element.find('div.output').append(toinsert);
521 521 // If we just output latex, typeset it.
522 522 if ((json.latex !== undefined) || (json.html !== undefined)) {
523 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
523 this.typeset();
524 524 };
525 525 };
526 526
@@ -572,7 +572,7 b' var IPython = (function (IPython) {'
572 572 this.element.find('div.output').append(toinsert);
573 573 // If we just output latex, typeset it.
574 574 if ( (json.latex !== undefined) || (json.html !== undefined) ) {
575 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
575 this.typeset();
576 576 };
577 577 };
578 578
@@ -12,6 +12,47 b''
12 12
13 13 $(document).ready(function () {
14 14
15 if (window.MathJax == undefined){
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){
15 56 MathJax.Hub.Config({
16 57 tex2jax: {
17 58 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
@@ -22,6 +63,11 b' $(document).ready(function () {'
22 63 styles: {'.MathJax_Display': {"margin": 0}}
23 64 }
24 65 });
66 }else{
67 // window.MathJax == null
68 // --no-mathjax mode
69 }
70
25 71 IPython.markdown_converter = new Markdown.Converter();
26 72 IPython.read_only = $('meta[name=read_only]').attr("content") == 'True';
27 73
@@ -175,7 +175,7 b' var IPython = (function (IPython) {'
175 175 var text = this.get_source();
176 176 if (text === "") { text = this.placeholder; }
177 177 this.set_rendered(text);
178 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
178 this.typeset();
179 179 this.element.find('div.text_cell_input').hide();
180 180 this.element.find("div.text_cell_render").show();
181 181 this.rendered = true;
@@ -201,7 +201,7 b' var IPython = (function (IPython) {'
201 201 if (text === "") { text = this.placeholder; }
202 202 var html = IPython.markdown_converter.makeHtml(text);
203 203 this.set_rendered(html);
204 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
204 this.typeset()
205 205 this.element.find('div.text_cell_input').hide();
206 206 this.element.find("div.text_cell_render").show();
207 207 var code_snippets = this.element.find("pre > code");
@@ -255,7 +255,7 b' var IPython = (function (IPython) {'
255 255
256 256 RSTCell.prototype.handle_render = function (data, status, xhr) {
257 257 this.set_rendered(data);
258 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
258 this.typeset();
259 259 this.rendered = true;
260 260 };
261 261
@@ -6,25 +6,24 b''
6 6
7 7 <title>IPython Notebook</title>
8 8
9 {% if enable_mathjax %}
9 10 <!-- <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> -->
10 11 <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script>
11 12 <script type="text/javascript">
12 function CheckMathJax(){
13 var div=document.getElementById("MathJaxFetchingWarning")
14 if(window.MathJax){
15 document.body.removeChild(div)
16 }
17 else{
18 div.style.display = "block";
19 }
20 }
21 if (typeof MathJax == 'undefined') {
13 if (typeof(MathJax) == 'undefined') {
22 14 console.log("No local MathJax, loading from CDN");
23 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"));
24 16 }else{
25 17 console.log("Using local MathJax");
26 18 }
27 19 </script>
20 {% else %}
21 <script type="text/javascript">
22 // MathJax disabled, set as null to distingish from *missing* MathJax,
23 // where it will be undefined, and should prompt a dialog later.
24 window.MathJax = null;
25 </script>
26 {% end %}
28 27
29 28 <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" />
30 29 <link rel="stylesheet" href="static/codemirror/lib/codemirror.css">
@@ -45,7 +44,7 b''
45 44
46 45 </head>
47 46
48 <body onload='CheckMathJax();'
47 <body
49 48 data-project={{project}} data-notebook-id={{notebook_id}}
50 49 data-base-project-url={{base_project_url}} data-base-kernel-url={{base_kernel_url}}
51 50 >
@@ -71,29 +70,6 b''
71 70 <span id="kernel_status">Idle</span>
72 71 </div>
73 72
74 <div id="MathJaxFetchingWarning"
75 style="width:80%; margin:auto;padding-top:20%;text-align: justify; display:none">
76 <p style="font-size:26px;">There was an issue trying to fetch MathJax.js
77 from the internet.</p>
78
79 <p style="padding:0.2em"> With a working internet connection, you can run
80 the following at a Python or IPython prompt, which will install a local
81 copy of MathJax:</p>
82
83 <pre style="background-color:lightblue;border:thin silver solid;padding:0.4em">
84 from IPython.external import mathjax; mathjax.install_mathjax()
85 </pre>
86 This will try to install MathJax into the directory where you installed
87 IPython. If you installed IPython to a location that requires
88 administrative privileges to write, you will need to make this call as
89 an administrator. On OSX/Linux/Unix, this can be done at the
90 command-line via:
91 <pre style="background-color:lightblue;border:thin silver solid;padding:0.4em">
92 sudo python -c "from IPython.external import mathjax; mathjax.install_mathjax()"
93 </pre>
94 </p>
95 </div>
96
97 73 <div id="main_app">
98 74
99 75 <div id="left_panel">
General Comments 0
You need to be logged in to leave comments. Login now