##// END OF EJS Templates
Finalizing fixes to MathJax enhancements...
Aron Ahmadia -
Show More
@@ -1,215 +1,218 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // Cell
9 // Cell
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 var utils = IPython.utils;
14 var utils = IPython.utils;
15
15
16
16
17 var Cell = function () {
17 var Cell = function () {
18 this.placeholder = this.placeholder || '';
18 this.placeholder = this.placeholder || '';
19 this.read_only = false;
19 this.read_only = false;
20 this.selected = false;
20 this.selected = false;
21 this.element = null;
21 this.element = null;
22 this.metadata = {};
22 this.metadata = {};
23 // load this from metadata later ?
23 // load this from metadata later ?
24 this.user_highlight == 'auto';
24 this.user_highlight == 'auto';
25 this.create_element();
25 this.create_element();
26 if (this.element !== null) {
26 if (this.element !== null) {
27 this.element.data("cell", this);
27 this.element.data("cell", this);
28 this.bind_events();
28 this.bind_events();
29 }
29 }
30 this.cell_id = utils.uuid();
30 this.cell_id = utils.uuid();
31 };
31 };
32
32
33
33
34 // Subclasses must implement create_element.
34 // Subclasses must implement create_element.
35 Cell.prototype.create_element = function () {};
35 Cell.prototype.create_element = function () {};
36
36
37
37
38 Cell.prototype.bind_events = function () {
38 Cell.prototype.bind_events = function () {
39 var that = this;
39 var that = this;
40 // We trigger events so that Cell doesn't have to depend on Notebook.
40 // We trigger events so that Cell doesn't have to depend on Notebook.
41 that.element.click(function (event) {
41 that.element.click(function (event) {
42 if (that.selected === false) {
42 if (that.selected === false) {
43 $([IPython.events]).trigger('select.Cell', {'cell':that});
43 $([IPython.events]).trigger('select.Cell', {'cell':that});
44 }
44 }
45 });
45 });
46 that.element.focusin(function (event) {
46 that.element.focusin(function (event) {
47 if (that.selected === false) {
47 if (that.selected === false) {
48 $([IPython.events]).trigger('select.Cell', {'cell':that});
48 $([IPython.events]).trigger('select.Cell', {'cell':that});
49 }
49 }
50 });
50 });
51 };
51 };
52
52
53 // prototype typeset method does nothing, see TextCell typeset
54 Cell.prototype.typeset = function () {
53 Cell.prototype.typeset = function () {
54 if (window.MathJax){
55 var cell_math = this.element.get(0);
56 MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_math]);
57 }
55 };
58 };
56
59
57 Cell.prototype.select = function () {
60 Cell.prototype.select = function () {
58 this.element.addClass('ui-widget-content ui-corner-all');
61 this.element.addClass('ui-widget-content ui-corner-all');
59 this.selected = true;
62 this.selected = true;
60 };
63 };
61
64
62
65
63 Cell.prototype.unselect = function () {
66 Cell.prototype.unselect = function () {
64 this.element.removeClass('ui-widget-content ui-corner-all');
67 this.element.removeClass('ui-widget-content ui-corner-all');
65 this.selected = false;
68 this.selected = false;
66 };
69 };
67
70
68
71
69 Cell.prototype.get_text = function () {
72 Cell.prototype.get_text = function () {
70 };
73 };
71
74
72
75
73 Cell.prototype.set_text = function (text) {
76 Cell.prototype.set_text = function (text) {
74 };
77 };
75
78
76
79
77 Cell.prototype.refresh = function () {
80 Cell.prototype.refresh = function () {
78 this.code_mirror.refresh();
81 this.code_mirror.refresh();
79 };
82 };
80
83
81
84
82 Cell.prototype.edit = function () {
85 Cell.prototype.edit = function () {
83 };
86 };
84
87
85
88
86 Cell.prototype.render = function () {
89 Cell.prototype.render = function () {
87 };
90 };
88
91
89
92
90 Cell.prototype.toJSON = function () {
93 Cell.prototype.toJSON = function () {
91 var data = {};
94 var data = {};
92 data.metadata = this.metadata;
95 data.metadata = this.metadata;
93 return data;
96 return data;
94 };
97 };
95
98
96
99
97 Cell.prototype.fromJSON = function (data) {
100 Cell.prototype.fromJSON = function (data) {
98 if (data.metadata !== undefined) {
101 if (data.metadata !== undefined) {
99 this.metadata = data.metadata;
102 this.metadata = data.metadata;
100 }
103 }
101 };
104 };
102
105
103
106
104 Cell.prototype.is_splittable = function () {
107 Cell.prototype.is_splittable = function () {
105 return true;
108 return true;
106 };
109 };
107
110
108
111
109 Cell.prototype.get_pre_cursor = function () {
112 Cell.prototype.get_pre_cursor = function () {
110 var cursor = this.code_mirror.getCursor();
113 var cursor = this.code_mirror.getCursor();
111 var text = this.code_mirror.getRange({line:0,ch:0}, cursor);
114 var text = this.code_mirror.getRange({line:0,ch:0}, cursor);
112 text = text.replace(/^\n+/, '').replace(/\n+$/, '');
115 text = text.replace(/^\n+/, '').replace(/\n+$/, '');
113 return text;
116 return text;
114 }
117 }
115
118
116
119
117 Cell.prototype.get_post_cursor = function () {
120 Cell.prototype.get_post_cursor = function () {
118 var cursor = this.code_mirror.getCursor();
121 var cursor = this.code_mirror.getCursor();
119 var last_line_num = this.code_mirror.lineCount()-1;
122 var last_line_num = this.code_mirror.lineCount()-1;
120 var last_line_len = this.code_mirror.getLine(last_line_num).length;
123 var last_line_len = this.code_mirror.getLine(last_line_num).length;
121 var end = {line:last_line_num, ch:last_line_len}
124 var end = {line:last_line_num, ch:last_line_len}
122 var text = this.code_mirror.getRange(cursor, end);
125 var text = this.code_mirror.getRange(cursor, end);
123 text = text.replace(/^\n+/, '').replace(/\n+$/, '');
126 text = text.replace(/^\n+/, '').replace(/\n+$/, '');
124 return text;
127 return text;
125 };
128 };
126
129
127
130
128 Cell.prototype.grow = function(element) {
131 Cell.prototype.grow = function(element) {
129 // Grow the cell by hand. This is used upon reloading from JSON, when the
132 // Grow the cell by hand. This is used upon reloading from JSON, when the
130 // autogrow handler is not called.
133 // autogrow handler is not called.
131 var dom = element.get(0);
134 var dom = element.get(0);
132 var lines_count = 0;
135 var lines_count = 0;
133 // modified split rule from
136 // modified split rule from
134 // http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424
137 // http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424
135 var lines = dom.value.split(/\r|\r\n|\n/);
138 var lines = dom.value.split(/\r|\r\n|\n/);
136 lines_count = lines.length;
139 lines_count = lines.length;
137 if (lines_count >= 1) {
140 if (lines_count >= 1) {
138 dom.rows = lines_count;
141 dom.rows = lines_count;
139 } else {
142 } else {
140 dom.rows = 1;
143 dom.rows = 1;
141 }
144 }
142 };
145 };
143
146
144
147
145 Cell.prototype.toggle_line_numbers = function () {
148 Cell.prototype.toggle_line_numbers = function () {
146 if (this.code_mirror.getOption('lineNumbers') == false) {
149 if (this.code_mirror.getOption('lineNumbers') == false) {
147 this.code_mirror.setOption('lineNumbers', true);
150 this.code_mirror.setOption('lineNumbers', true);
148 } else {
151 } else {
149 this.code_mirror.setOption('lineNumbers', false);
152 this.code_mirror.setOption('lineNumbers', false);
150 }
153 }
151 this.code_mirror.refresh();
154 this.code_mirror.refresh();
152 };
155 };
153
156
154 Cell.prototype.force_highlight = function(mode) {
157 Cell.prototype.force_highlight = function(mode) {
155 this.user_highlight = mode;
158 this.user_highlight = mode;
156 this.auto_highlight();
159 this.auto_highlight();
157 };
160 };
158
161
159 Cell.prototype._auto_highlight = function (modes) {
162 Cell.prototype._auto_highlight = function (modes) {
160 //Here we handle manually selected modes
163 //Here we handle manually selected modes
161 if( this.user_highlight != undefined && this.user_highlight != 'auto' )
164 if( this.user_highlight != undefined && this.user_highlight != 'auto' )
162 {
165 {
163 var mode = this.user_highlight;
166 var mode = this.user_highlight;
164 CodeMirror.autoLoadMode(this.code_mirror, mode);
167 CodeMirror.autoLoadMode(this.code_mirror, mode);
165 this.code_mirror.setOption('mode', mode);
168 this.code_mirror.setOption('mode', mode);
166 return;
169 return;
167 }
170 }
168 var first_line = this.code_mirror.getLine(0);
171 var first_line = this.code_mirror.getLine(0);
169 // loop on every pairs
172 // loop on every pairs
170 for( var mode in modes) {
173 for( var mode in modes) {
171 var regs = modes[mode]['reg'];
174 var regs = modes[mode]['reg'];
172 // only one key every time but regexp can't be keys...
175 // only one key every time but regexp can't be keys...
173 for(var reg in regs ) {
176 for(var reg in regs ) {
174 // here we handle non magic_modes
177 // here we handle non magic_modes
175 if(first_line.match(regs[reg]) != null) {
178 if(first_line.match(regs[reg]) != null) {
176 if (mode.search('magic_') != 0) {
179 if (mode.search('magic_') != 0) {
177 this.code_mirror.setOption('mode',mode);
180 this.code_mirror.setOption('mode',mode);
178 CodeMirror.autoLoadMode(this.code_mirror, mode);
181 CodeMirror.autoLoadMode(this.code_mirror, mode);
179 return;
182 return;
180 }
183 }
181 var open = modes[mode]['open']|| "%%";
184 var open = modes[mode]['open']|| "%%";
182 var close = modes[mode]['close']|| "%%end";
185 var close = modes[mode]['close']|| "%%end";
183 var mmode = mode;
186 var mmode = mode;
184 mode = mmode.substr(6);
187 mode = mmode.substr(6);
185 CodeMirror.autoLoadMode(this.code_mirror, mode);
188 CodeMirror.autoLoadMode(this.code_mirror, mode);
186 // create on the fly a mode that swhitch between
189 // create on the fly a mode that swhitch between
187 // plain/text and smth else otherwise `%%` is
190 // plain/text and smth else otherwise `%%` is
188 // source of some highlight issues.
191 // source of some highlight issues.
189 // we use patchedGetMode to circumvent a bug in CM
192 // we use patchedGetMode to circumvent a bug in CM
190 CodeMirror.defineMode(mmode , function(config) {
193 CodeMirror.defineMode(mmode , function(config) {
191 return CodeMirror.multiplexingMode(
194 return CodeMirror.multiplexingMode(
192 CodeMirror.patchedGetMode(config, 'text/plain'),
195 CodeMirror.patchedGetMode(config, 'text/plain'),
193 // always set someting on close
196 // always set someting on close
194 {open: open, close: close,
197 {open: open, close: close,
195 mode: CodeMirror.patchedGetMode(config, mode),
198 mode: CodeMirror.patchedGetMode(config, mode),
196 delimStyle: "delimit"
199 delimStyle: "delimit"
197 }
200 }
198 );
201 );
199 });
202 });
200 this.code_mirror.setOption('mode', mmode);
203 this.code_mirror.setOption('mode', mmode);
201 return;
204 return;
202 }
205 }
203 }
206 }
204 }
207 }
205 // fallback on default (python)
208 // fallback on default (python)
206 var default_mode = this.default_mode || 'text/plain';
209 var default_mode = this.default_mode || 'text/plain';
207 this.code_mirror.setOption('mode', default_mode);
210 this.code_mirror.setOption('mode', default_mode);
208 };
211 };
209
212
210 IPython.Cell = Cell;
213 IPython.Cell = Cell;
211
214
212 return IPython;
215 return IPython;
213
216
214 }(IPython));
217 }(IPython));
215
218
@@ -1,229 +1,241 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2012 The IPython Development Team
2 // Copyright (C) 2008-2012 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // MathJax utility functions
9 // MathJax utility functions
10 //============================================================================
10 //============================================================================
11
11
12 IPython.namespace('IPython.mathjaxutils');
12 IPython.namespace('IPython.mathjaxutils');
13
13
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 MathJax.Hub.Config({
20 tex2jax: {
21 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
22 displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
23 processEnvironments: true
24 },
25 displayAlign: 'left', // Change this to 'center' to center equations.
26 "HTML-CSS": {
27 styles: {'.MathJax_Display': {"margin": 0}}
28 }
29 });
30 MathJax.Hub.Configured();
19 } else if (window.mathjax_url != "") {
31 } else if (window.mathjax_url != "") {
20 // Don't have MathJax, but should. Show dialog.
32 // Don't have MathJax, but should. Show dialog.
21 var dialog = $('<div></div>')
33 var dialog = $('<div></div>')
22 .append(
34 .append(
23 $("<p></p>").addClass('dialog').html(
35 $("<p></p>").addClass('dialog').html(
24 "Math/LaTeX rendering will be disabled."
36 "Math/LaTeX rendering will be disabled."
25 )
37 )
26 ).append(
38 ).append(
27 $("<p></p>").addClass('dialog').html(
39 $("<p></p>").addClass('dialog').html(
28 "If you have administrative access to the notebook server and" +
40 "If you have administrative access to the notebook server and" +
29 " a working internet connection, you can install a local copy" +
41 " a working internet connection, you can install a local copy" +
30 " of MathJax for offline use with the following command on the server" +
42 " of MathJax for offline use with the following command on the server" +
31 " at a Python or IPython prompt:"
43 " at a Python or IPython prompt:"
32 )
44 )
33 ).append(
45 ).append(
34 $("<pre></pre>").addClass('dialog').html(
46 $("<pre></pre>").addClass('dialog').html(
35 ">>> from IPython.external import mathjax; mathjax.install_mathjax()"
47 ">>> from IPython.external import mathjax; mathjax.install_mathjax()"
36 )
48 )
37 ).append(
49 ).append(
38 $("<p></p>").addClass('dialog').html(
50 $("<p></p>").addClass('dialog').html(
39 "This will try to install MathJax into the IPython source directory."
51 "This will try to install MathJax into the IPython source directory."
40 )
52 )
41 ).append(
53 ).append(
42 $("<p></p>").addClass('dialog').html(
54 $("<p></p>").addClass('dialog').html(
43 "If IPython is installed to a location that requires" +
55 "If IPython is installed to a location that requires" +
44 " administrative privileges to write, you will need to make this call as" +
56 " administrative privileges to write, you will need to make this call as" +
45 " an administrator, via 'sudo'."
57 " an administrator, via 'sudo'."
46 )
58 )
47 ).append(
59 ).append(
48 $("<p></p>").addClass('dialog').html(
60 $("<p></p>").addClass('dialog').html(
49 "When you start the notebook server, you can instruct it to disable MathJax support altogether:"
61 "When you start the notebook server, you can instruct it to disable MathJax support altogether:"
50 )
62 )
51 ).append(
63 ).append(
52 $("<pre></pre>").addClass('dialog').html(
64 $("<pre></pre>").addClass('dialog').html(
53 "$ ipython notebook --no-mathjax"
65 "$ ipython notebook --no-mathjax"
54 )
66 )
55 ).append(
67 ).append(
56 $("<p></p>").addClass('dialog').html(
68 $("<p></p>").addClass('dialog').html(
57 "which will prevent this dialog from appearing."
69 "which will prevent this dialog from appearing."
58 )
70 )
59 ).dialog({
71 ).dialog({
60 title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
72 title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
61 width: "70%",
73 width: "70%",
62 modal: true,
74 modal: true,
63 })
75 })
64 } else {
76 } else {
65 // No MathJax, but none expected. No dialog.
77 // No MathJax, but none expected. No dialog.
66 };
78 };
67 };
79 };
68
80
69 // Some magic for deferring mathematical expressions to MathJax
81 // Some magic for deferring mathematical expressions to MathJax
70 // by hiding them from the Markdown parser.
82 // by hiding them from the Markdown parser.
71 // Some of the code here is adapted with permission from Davide Cervone
83 // Some of the code here is adapted with permission from Davide Cervone
72 // under the terms of the Apache2 license governing the MathJax project.
84 // under the terms of the Apache2 license governing the MathJax project.
73 // Other minor modifications are also due to StackExchange and are used with
85 // Other minor modifications are also due to StackExchange and are used with
74 // permission.
86 // permission.
75
87
76 var inline = "$"; // the inline math delimiter
88 var inline = "$"; // the inline math delimiter
77 var blocks, start, end, last, braces; // used in searching for math
89 var blocks, start, end, last, braces; // used in searching for math
78 var math; // stores math until pagedown (Markdown parser) is done
90 var math; // stores math until pagedown (Markdown parser) is done
79
91
80 // MATHSPLIT contains the pattern for math delimiters and special symbols
92 // MATHSPLIT contains the pattern for math delimiters and special symbols
81 // needed for searching for math in the text input.
93 // needed for searching for math in the text input.
82 var MATHSPLIT = /(\$\$?|\\(?:begin|end)\{[a-z]*\*?\}|\\[\\{}$]|[{}]|(?:\n\s*)+|@@\d+@@)/i;
94 var MATHSPLIT = /(\$\$?|\\(?:begin|end)\{[a-z]*\*?\}|\\[\\{}$]|[{}]|(?:\n\s*)+|@@\d+@@)/i;
83
95
84 // The math is in blocks i through j, so
96 // The math is in blocks i through j, so
85 // collect it into one block and clear the others.
97 // collect it into one block and clear the others.
86 // Replace &, <, and > by named entities.
98 // Replace &, <, and > by named entities.
87 // For IE, put <br> at the ends of comments since IE removes \n.
99 // For IE, put <br> at the ends of comments since IE removes \n.
88 // Clear the current math positions and store the index of the
100 // Clear the current math positions and store the index of the
89 // math, then push the math string onto the storage array.
101 // math, then push the math string onto the storage array.
90 // The preProcess function is called on all blocks if it has been passed in
102 // The preProcess function is called on all blocks if it has been passed in
91 var process_math = function (i, j, pre_process) {
103 var process_math = function (i, j, pre_process) {
92 var HUB = MathJax.Hub;
104 var hub = MathJax.Hub;
93 var block = blocks.slice(i, j + 1).join("").replace(/&/g, "&amp;") // use HTML entity for &
105 var block = blocks.slice(i, j + 1).join("").replace(/&/g, "&amp;") // use HTML entity for &
94 .replace(/</g, "&lt;") // use HTML entity for <
106 .replace(/</g, "&lt;") // use HTML entity for <
95 .replace(/>/g, "&gt;") // use HTML entity for >
107 .replace(/>/g, "&gt;") // use HTML entity for >
96 ;
108 ;
97 if (HUB.Browser.isMSIE) {
109 if (hub.Browser.isMSIE) {
98 block = block.replace(/(%[^\n]*)\n/g, "$1<br/>\n")
110 block = block.replace(/(%[^\n]*)\n/g, "$1<br/>\n")
99 }
111 }
100 while (j > i) {
112 while (j > i) {
101 blocks[j] = "";
113 blocks[j] = "";
102 j--;
114 j--;
103 }
115 }
104 blocks[i] = "@@" + math.length + "@@"; // replace the current block text with a unique tag to find later
116 blocks[i] = "@@" + math.length + "@@"; // replace the current block text with a unique tag to find later
105 if (pre_process)
117 if (pre_process)
106 block = pre_process(block);
118 block = pre_process(block);
107 math.push(block);
119 math.push(block);
108 start = end = last = null;
120 start = end = last = null;
109 }
121 }
110
122
111 // Break up the text into its component parts and search
123 // Break up the text into its component parts and search
112 // through them for math delimiters, braces, linebreaks, etc.
124 // through them for math delimiters, braces, linebreaks, etc.
113 // Math delimiters must match and braces must balance.
125 // Math delimiters must match and braces must balance.
114 // Don't allow math to pass through a double linebreak
126 // Don't allow math to pass through a double linebreak
115 // (which will be a paragraph).
127 // (which will be a paragraph).
116 //
128 //
117 var remove_math = function (text) {
129 var remove_math = function (text) {
118 if (!window.MathJax) {
130 if (!window.MathJax) {
119 return text;
131 return text;
120 }
132 }
121
133
122 start = end = last = null; // for tracking math delimiters
134 start = end = last = null; // for tracking math delimiters
123 math = []; // stores math strings for later
135 math = []; // stores math strings for later
124
136
125 // Except for extreme edge cases, this should catch precisely those pieces of the markdown
137 // Except for extreme edge cases, this should catch precisely those pieces of the markdown
126 // source that will later be turned into code spans. While MathJax will not TeXify code spans,
138 // source that will later be turned into code spans. While MathJax will not TeXify code spans,
127 // we still have to consider them at this point; the following issue has happened several times:
139 // we still have to consider them at this point; the following issue has happened several times:
128 //
140 //
129 // `$foo` and `$bar` are varibales. --> <code>$foo ` and `$bar</code> are variables.
141 // `$foo` and `$bar` are varibales. --> <code>$foo ` and `$bar</code> are variables.
130
142
131 var hasCodeSpans = /`/.test(text),
143 var hasCodeSpans = /`/.test(text),
132 de_tilde;
144 de_tilde;
133 if (hasCodeSpans) {
145 if (hasCodeSpans) {
134 text = text.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function (wholematch) {
146 text = text.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function (wholematch) {
135 return wholematch.replace(/\$/g, "~D");
147 return wholematch.replace(/\$/g, "~D");
136 });
148 });
137 de_tilde = function (text) { return text.replace(/~([TD])/g, function (wholematch, character) { return { T: "~", D: "$" }[character]; }) };
149 de_tilde = function (text) { return text.replace(/~([TD])/g, function (wholematch, character) { return { T: "~", D: "$" }[character]; }) };
138 } else {
150 } else {
139 de_tilde = function (text) { return text; };
151 de_tilde = function (text) { return text; };
140 }
152 }
141
153
142 blocks = IPython.utils.regex_split(text.replace(/\r\n?/g, "\n"),MATHSPLIT);
154 blocks = IPython.utils.regex_split(text.replace(/\r\n?/g, "\n"),MATHSPLIT);
143
155
144 for (var i = 1, m = blocks.length; i < m; i += 2) {
156 for (var i = 1, m = blocks.length; i < m; i += 2) {
145 var block = blocks[i];
157 var block = blocks[i];
146 if (block.charAt(0) === "@") {
158 if (block.charAt(0) === "@") {
147 //
159 //
148 // Things that look like our math markers will get
160 // Things that look like our math markers will get
149 // stored and then retrieved along with the math.
161 // stored and then retrieved along with the math.
150 //
162 //
151 blocks[i] = "@@" + math.length + "@@";
163 blocks[i] = "@@" + math.length + "@@";
152 math.push(block);
164 math.push(block);
153 }
165 }
154 else if (start) {
166 else if (start) {
155 //
167 //
156 // If we are in math, look for the end delimiter,
168 // If we are in math, look for the end delimiter,
157 // but don't go past double line breaks, and
169 // but don't go past double line breaks, and
158 // and balance braces within the math.
170 // and balance braces within the math.
159 //
171 //
160 if (block === end) {
172 if (block === end) {
161 if (braces) {
173 if (braces) {
162 last = i
174 last = i
163 }
175 }
164 else {
176 else {
165 process_math(start, i, de_tilde)
177 process_math(start, i, de_tilde)
166 }
178 }
167 }
179 }
168 else if (block.match(/\n.*\n/)) {
180 else if (block.match(/\n.*\n/)) {
169 if (last) {
181 if (last) {
170 i = last;
182 i = last;
171 process_math(start, i, de_tilde)
183 process_math(start, i, de_tilde)
172 }
184 }
173 start = end = last = null;
185 start = end = last = null;
174 braces = 0;
186 braces = 0;
175 }
187 }
176 else if (block === "{") {
188 else if (block === "{") {
177 braces++
189 braces++
178 }
190 }
179 else if (block === "}" && braces) {
191 else if (block === "}" && braces) {
180 braces--
192 braces--
181 }
193 }
182 }
194 }
183 else {
195 else {
184 //
196 //
185 // Look for math start delimiters and when
197 // Look for math start delimiters and when
186 // found, set up the end delimiter.
198 // found, set up the end delimiter.
187 //
199 //
188 if (block === inline || block === "$$") {
200 if (block === inline || block === "$$") {
189 start = i;
201 start = i;
190 end = block;
202 end = block;
191 braces = 0;
203 braces = 0;
192 }
204 }
193 else if (block.substr(1, 5) === "begin") {
205 else if (block.substr(1, 5) === "begin") {
194 start = i;
206 start = i;
195 end = "\\end" + block.substr(6);
207 end = "\\end" + block.substr(6);
196 braces = 0;
208 braces = 0;
197 }
209 }
198 }
210 }
199 }
211 }
200 if (last) {
212 if (last) {
201 process_math(start, last, de_tilde)
213 process_math(start, last, de_tilde)
202 }
214 }
203 return de_tilde(blocks.join(""));
215 return de_tilde(blocks.join(""));
204 }
216 }
205
217
206 //
218 //
207 // Put back the math strings that were saved,
219 // Put back the math strings that were saved,
208 // and clear the math array (no need to keep it around).
220 // and clear the math array (no need to keep it around).
209 //
221 //
210 var replace_math = function (text) {
222 var replace_math = function (text) {
211 if (!window.MathJax) {
223 if (!window.MathJax) {
212 return text;
224 return text;
213 }
225 }
214
226
215 text = text.replace(/@@(\d+)@@/g, function (match, n) {
227 text = text.replace(/@@(\d+)@@/g, function (match, n) {
216 return math[n]
228 return math[n]
217 });
229 });
218 math = null;
230 math = null;
219 return text;
231 return text;
220 }
232 }
221
233
222 return {
234 return {
223 init : init,
235 init : init,
224 process_math : process_math,
236 process_math : process_math,
225 remove_math : remove_math,
237 remove_math : remove_math,
226 replace_math : replace_math
238 replace_math : replace_math
227 };
239 };
228
240
229 }(IPython)); No newline at end of file
241 }(IPython));
@@ -1,427 +1,417 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2012 The IPython Development Team
2 // Copyright (C) 2008-2012 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // TextCell
9 // TextCell
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 // TextCell base class
14 // TextCell base class
15 var key = IPython.utils.keycodes;
15 var key = IPython.utils.keycodes;
16
16
17 var TextCell = function () {
17 var TextCell = function () {
18 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
18 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
19 IPython.Cell.apply(this, arguments);
19 IPython.Cell.apply(this, arguments);
20 this.rendered = false;
20 this.rendered = false;
21 this.cell_type = this.cell_type || 'text';
21 this.cell_type = this.cell_type || 'text';
22 };
22 };
23
23
24
24
25 TextCell.prototype = new IPython.Cell();
25 TextCell.prototype = new IPython.Cell();
26
26
27
27
28 TextCell.prototype.create_element = function () {
28 TextCell.prototype.create_element = function () {
29 var cell = $("<div>").addClass('cell text_cell border-box-sizing');
29 var cell = $("<div>").addClass('cell text_cell border-box-sizing');
30 cell.attr('tabindex','2');
30 cell.attr('tabindex','2');
31 var input_area = $('<div/>').addClass('text_cell_input border-box-sizing');
31 var input_area = $('<div/>').addClass('text_cell_input border-box-sizing');
32 this.code_mirror = CodeMirror(input_area.get(0), {
32 this.code_mirror = CodeMirror(input_area.get(0), {
33 indentUnit : 4,
33 indentUnit : 4,
34 mode: this.code_mirror_mode,
34 mode: this.code_mirror_mode,
35 theme: 'default',
35 theme: 'default',
36 value: this.placeholder,
36 value: this.placeholder,
37 readOnly: this.read_only,
37 readOnly: this.read_only,
38 lineWrapping : true,
38 lineWrapping : true,
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 // The tabindex=-1 makes this div focusable.
42 // The tabindex=-1 makes this div focusable.
43 // id is a unique cell_id necessary for updating MathJax intelligently
44 var render_area = $('<div/>').addClass('text_cell_render border-box-sizing').
43 var render_area = $('<div/>').addClass('text_cell_render border-box-sizing').
45 addClass('rendered_html').attr('tabindex','-1');
44 addClass('rendered_html').attr('tabindex','-1');
46 cell.append(input_area).append(render_area);
45 cell.append(input_area).append(render_area);
47 this.element = cell;
46 this.element = cell;
48 };
47 };
49
48
50
49
51 TextCell.prototype.bind_events = function () {
50 TextCell.prototype.bind_events = function () {
52 IPython.Cell.prototype.bind_events.apply(this);
51 IPython.Cell.prototype.bind_events.apply(this);
53 var that = this;
52 var that = this;
54 this.element.keydown(function (event) {
53 this.element.keydown(function (event) {
55 if (event.which === 13 && !event.shiftKey) {
54 if (event.which === 13 && !event.shiftKey) {
56 if (that.rendered) {
55 if (that.rendered) {
57 that.edit();
56 that.edit();
58 return false;
57 return false;
59 };
58 };
60 };
59 };
61 });
60 });
62 this.element.dblclick(function () {
61 this.element.dblclick(function () {
63 that.edit();
62 that.edit();
64 });
63 });
65 };
64 };
66
65
67
66
68 TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {
67 TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {
69 // This method gets called in CodeMirror's onKeyDown/onKeyPress
68 // This method gets called in CodeMirror's onKeyDown/onKeyPress
70 // handlers and is used to provide custom key handling. Its return
69 // handlers and is used to provide custom key handling. Its return
71 // value is used to determine if CodeMirror should ignore the event:
70 // value is used to determine if CodeMirror should ignore the event:
72 // true = ignore, false = don't ignore.
71 // true = ignore, false = don't ignore.
73
72
74 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
73 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
75 // Always ignore shift-enter in CodeMirror as we handle it.
74 // Always ignore shift-enter in CodeMirror as we handle it.
76 return true;
75 return true;
77 }
76 }
78 return false;
77 return false;
79 };
78 };
80
79
81 TextCell.prototype.typeset = function () {
82 if (window.MathJax){
83 var cell_math = this.element.get(0);
84 MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_math]);
85 }
86 };
87
88
80
89 TextCell.prototype.select = function () {
81 TextCell.prototype.select = function () {
90 IPython.Cell.prototype.select.apply(this);
82 IPython.Cell.prototype.select.apply(this);
91 var output = this.element.find("div.text_cell_render");
83 var output = this.element.find("div.text_cell_render");
92 output.trigger('focus');
84 output.trigger('focus');
93 };
85 };
94
86
95
87
96 TextCell.prototype.unselect = function() {
88 TextCell.prototype.unselect = function() {
97 // render on selection of another cell
89 // render on selection of another cell
98 this.render();
90 this.render();
99 IPython.Cell.prototype.unselect.apply(this);
91 IPython.Cell.prototype.unselect.apply(this);
100 };
92 };
101
93
102
94
103 TextCell.prototype.edit = function () {
95 TextCell.prototype.edit = function () {
104 if ( this.read_only ) return;
96 if ( this.read_only ) return;
105 if (this.rendered === true) {
97 if (this.rendered === true) {
106 var text_cell = this.element;
98 var text_cell = this.element;
107 var output = text_cell.find("div.text_cell_render");
99 var output = text_cell.find("div.text_cell_render");
108 output.hide();
100 output.hide();
109 text_cell.find('div.text_cell_input').show();
101 text_cell.find('div.text_cell_input').show();
110 this.code_mirror.refresh();
102 this.code_mirror.refresh();
111 this.code_mirror.focus();
103 this.code_mirror.focus();
112 // We used to need an additional refresh() after the focus, but
104 // We used to need an additional refresh() after the focus, but
113 // it appears that this has been fixed in CM. This bug would show
105 // it appears that this has been fixed in CM. This bug would show
114 // up on FF when a newly loaded markdown cell was edited.
106 // up on FF when a newly loaded markdown cell was edited.
115 this.rendered = false;
107 this.rendered = false;
116 if (this.get_text() === this.placeholder) {
108 if (this.get_text() === this.placeholder) {
117 this.set_text('');
109 this.set_text('');
118 this.refresh();
110 this.refresh();
119 }
111 }
120 }
112 }
121 };
113 };
122
114
123
115
124 // Subclasses must define render.
116 // Subclasses must define render.
125 TextCell.prototype.render = function () {};
117 TextCell.prototype.render = function () {};
126
118
127
119
128 TextCell.prototype.get_text = function() {
120 TextCell.prototype.get_text = function() {
129 return this.code_mirror.getValue();
121 return this.code_mirror.getValue();
130 };
122 };
131
123
132
124
133 TextCell.prototype.set_text = function(text) {
125 TextCell.prototype.set_text = function(text) {
134 this.code_mirror.setValue(text);
126 this.code_mirror.setValue(text);
135 this.code_mirror.refresh();
127 this.code_mirror.refresh();
136 };
128 };
137
129
138
130
139 TextCell.prototype.get_rendered = function() {
131 TextCell.prototype.get_rendered = function() {
140 return this.element.find('div.text_cell_render').html();
132 return this.element.find('div.text_cell_render').html();
141 };
133 };
142
134
143
135
144 TextCell.prototype.set_rendered = function(text) {
136 TextCell.prototype.set_rendered = function(text) {
145 this.element.find('div.text_cell_render').html(text);
137 this.element.find('div.text_cell_render').html(text);
146 };
138 };
147
139
148
140
149 TextCell.prototype.at_top = function () {
141 TextCell.prototype.at_top = function () {
150 if (this.rendered) {
142 if (this.rendered) {
151 return true;
143 return true;
152 } else {
144 } else {
153 return false;
145 return false;
154 }
146 }
155 };
147 };
156
148
157
149
158 TextCell.prototype.at_bottom = function () {
150 TextCell.prototype.at_bottom = function () {
159 if (this.rendered) {
151 if (this.rendered) {
160 return true;
152 return true;
161 } else {
153 } else {
162 return false;
154 return false;
163 }
155 }
164 };
156 };
165
157
166
158
167 TextCell.prototype.fromJSON = function (data) {
159 TextCell.prototype.fromJSON = function (data) {
168 IPython.Cell.prototype.fromJSON.apply(this, arguments);
160 IPython.Cell.prototype.fromJSON.apply(this, arguments);
169 if (data.cell_type === this.cell_type) {
161 if (data.cell_type === this.cell_type) {
170 if (data.source !== undefined) {
162 if (data.source !== undefined) {
171 this.set_text(data.source);
163 this.set_text(data.source);
172 // make this value the starting point, so that we can only undo
164 // make this value the starting point, so that we can only undo
173 // to this state, instead of a blank cell
165 // to this state, instead of a blank cell
174 this.code_mirror.clearHistory();
166 this.code_mirror.clearHistory();
175 this.set_rendered(data.rendered || '');
167 this.set_rendered(data.rendered || '');
176 this.rendered = false;
168 this.rendered = false;
177 this.render();
169 this.render();
178 }
170 }
179 }
171 }
180 };
172 };
181
173
182
174
183 TextCell.prototype.toJSON = function () {
175 TextCell.prototype.toJSON = function () {
184 var data = IPython.Cell.prototype.toJSON.apply(this);
176 var data = IPython.Cell.prototype.toJSON.apply(this);
185 data.cell_type = this.cell_type;
177 data.cell_type = this.cell_type;
186 data.source = this.get_text();
178 data.source = this.get_text();
187 return data;
179 return data;
188 };
180 };
189
181
190
182
191 // HTMLCell
183 // HTMLCell
192
184
193 var HTMLCell = function () {
185 var HTMLCell = function () {
194 this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$";
186 this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$";
195 IPython.TextCell.apply(this, arguments);
187 IPython.TextCell.apply(this, arguments);
196 this.cell_type = 'html';
188 this.cell_type = 'html';
197 };
189 };
198
190
199
191
200 HTMLCell.prototype = new TextCell();
192 HTMLCell.prototype = new TextCell();
201
193
202
194
203 HTMLCell.prototype.render = function () {
195 HTMLCell.prototype.render = function () {
204 if (this.rendered === false) {
196 if (this.rendered === false) {
205 var text = this.get_text();
197 var text = this.get_text();
206 if (text === "") { text = this.placeholder; }
198 if (text === "") { text = this.placeholder; }
207 this.set_rendered(text);
199 this.set_rendered(text);
208 this.typeset();
200 this.typeset();
209 this.element.find('div.text_cell_input').hide();
201 this.element.find('div.text_cell_input').hide();
210 this.element.find("div.text_cell_render").show();
202 this.element.find("div.text_cell_render").show();
211 this.rendered = true;
203 this.rendered = true;
212 }
204 }
213 };
205 };
214
206
215
207
216 // MarkdownCell
208 // MarkdownCell
217
209
218 var MarkdownCell = function () {
210 var MarkdownCell = function () {
219 this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
211 this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
220 IPython.TextCell.apply(this, arguments);
212 IPython.TextCell.apply(this, arguments);
221 this.cell_type = 'markdown';
213 this.cell_type = 'markdown';
222 };
214 };
223
215
224
216
225 MarkdownCell.prototype = new TextCell();
217 MarkdownCell.prototype = new TextCell();
226
218
227
219
228 MarkdownCell.prototype.render = function () {
220 MarkdownCell.prototype.render = function () {
229 if (this.rendered === false) {
221 if (this.rendered === false) {
230 var text = this.get_text();
222 var text = this.get_text();
231 if (text === "") { text = this.placeholder; }
223 if (text === "") { text = this.placeholder; }
232 else {
224 text = IPython.mathjaxutils.remove_math(text)
233 text = IPython.mathjaxutils.remove_math(text)
225 var html = IPython.markdown_converter.makeHtml(text);
234 var html = IPython.markdown_converter.makeHtml(text);
226 html = IPython.mathjaxutils.replace_math(html)
235 html = IPython.mathjaxutils.replace_math(html)
227 try {
236 try {
228 this.set_rendered(html);
237 this.set_rendered(html);
229 } catch (e) {
238 } catch (e) {
230 console.log("Error running Javascript in Markdown:");
239 console.log("Error running Javascript in Markdown:");
231 console.log(e);
240 console.log(e);
232 this.set_rendered($("<div/>").addClass("js-error").html(
241 this.set_rendered($("<div/>").addClass("js-error").html(
233 "Error rendering Markdown!<br/>" + e.toString())
242 "Error rendering Markdown!<br/>" + e.toString())
234 );
243 );
244 }
245 this.element.find('div.text_cell_input').hide();
246 this.element.find("div.text_cell_render").show();
247 var code_snippets = this.element.find("pre > code");
248 code_snippets.replaceWith(function () {
249 var code = $(this).html();
250 /* Substitute br for newlines and &nbsp; for spaces
251 before highlighting, since prettify doesn't
252 preserve those on all browsers */
253 code = code.replace(/(\r\n|\n|\r)/gm, "<br/>");
254 code = code.replace(/ /gm, '&nbsp;');
255 code = prettyPrintOne(code);
256
257 return '<code class="prettyprint">' + code + '</code>';
258 });
259 this.typeset()
260 }
235 }
236 this.element.find('div.text_cell_input').hide();
237 this.element.find("div.text_cell_render").show();
238 var code_snippets = this.element.find("pre > code");
239 code_snippets.replaceWith(function () {
240 var code = $(this).html();
241 /* Substitute br for newlines and &nbsp; for spaces
242 before highlighting, since prettify doesn't
243 preserve those on all browsers */
244 code = code.replace(/(\r\n|\n|\r)/gm, "<br/>");
245 code = code.replace(/ /gm, '&nbsp;');
246 code = prettyPrintOne(code);
247
248 return '<code class="prettyprint">' + code + '</code>';
249 });
250 this.typeset()
261 this.rendered = true;
251 this.rendered = true;
262 }
252 }
263 };
253 };
264
254
265
255
266 // RawCell
256 // RawCell
267
257
268 var RawCell = function () {
258 var RawCell = function () {
269 this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
259 this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
270 this.code_mirror_mode = 'rst';
260 this.code_mirror_mode = 'rst';
271 IPython.TextCell.apply(this, arguments);
261 IPython.TextCell.apply(this, arguments);
272 this.cell_type = 'raw';
262 this.cell_type = 'raw';
273 var that = this
263 var that = this
274
264
275 this.element.focusout(
265 this.element.focusout(
276 function() { that.auto_highlight(); }
266 function() { that.auto_highlight(); }
277 );
267 );
278 };
268 };
279
269
280
270
281 RawCell.prototype = new TextCell();
271 RawCell.prototype = new TextCell();
282
272
283 RawCell.prototype.auto_highlight = function () {
273 RawCell.prototype.auto_highlight = function () {
284 this._auto_highlight(IPython.config.raw_cell_highlight);
274 this._auto_highlight(IPython.config.raw_cell_highlight);
285 };
275 };
286
276
287 RawCell.prototype.render = function () {
277 RawCell.prototype.render = function () {
288 this.rendered = true;
278 this.rendered = true;
289 this.edit();
279 this.edit();
290 };
280 };
291
281
292
282
293 RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {
283 RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {
294 // This method gets called in CodeMirror's onKeyDown/onKeyPress
284 // This method gets called in CodeMirror's onKeyDown/onKeyPress
295 // handlers and is used to provide custom key handling. Its return
285 // handlers and is used to provide custom key handling. Its return
296 // value is used to determine if CodeMirror should ignore the event:
286 // value is used to determine if CodeMirror should ignore the event:
297 // true = ignore, false = don't ignore.
287 // true = ignore, false = don't ignore.
298
288
299 var that = this;
289 var that = this;
300 if (event.which === key.UPARROW && event.type === 'keydown') {
290 if (event.which === key.UPARROW && event.type === 'keydown') {
301 // If we are not at the top, let CM handle the up arrow and
291 // If we are not at the top, let CM handle the up arrow and
302 // prevent the global keydown handler from handling it.
292 // prevent the global keydown handler from handling it.
303 if (!that.at_top()) {
293 if (!that.at_top()) {
304 event.stop();
294 event.stop();
305 return false;
295 return false;
306 } else {
296 } else {
307 return true;
297 return true;
308 };
298 };
309 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
299 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
310 // If we are not at the bottom, let CM handle the down arrow and
300 // If we are not at the bottom, let CM handle the down arrow and
311 // prevent the global keydown handler from handling it.
301 // prevent the global keydown handler from handling it.
312 if (!that.at_bottom()) {
302 if (!that.at_bottom()) {
313 event.stop();
303 event.stop();
314 return false;
304 return false;
315 } else {
305 } else {
316 return true;
306 return true;
317 };
307 };
318 };
308 };
319 return false;
309 return false;
320 };
310 };
321
311
322
312
323 RawCell.prototype.select = function () {
313 RawCell.prototype.select = function () {
324 IPython.Cell.prototype.select.apply(this);
314 IPython.Cell.prototype.select.apply(this);
325 this.code_mirror.refresh();
315 this.code_mirror.refresh();
326 this.code_mirror.focus();
316 this.code_mirror.focus();
327 };
317 };
328
318
329
319
330 RawCell.prototype.at_top = function () {
320 RawCell.prototype.at_top = function () {
331 var cursor = this.code_mirror.getCursor();
321 var cursor = this.code_mirror.getCursor();
332 if (cursor.line === 0 && cursor.ch === 0) {
322 if (cursor.line === 0 && cursor.ch === 0) {
333 return true;
323 return true;
334 } else {
324 } else {
335 return false;
325 return false;
336 }
326 }
337 };
327 };
338
328
339
329
340 RawCell.prototype.at_bottom = function () {
330 RawCell.prototype.at_bottom = function () {
341 var cursor = this.code_mirror.getCursor();
331 var cursor = this.code_mirror.getCursor();
342 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
332 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
343 return true;
333 return true;
344 } else {
334 } else {
345 return false;
335 return false;
346 }
336 }
347 };
337 };
348
338
349
339
350 // HTMLCell
340 // HTMLCell
351
341
352 var HeadingCell = function () {
342 var HeadingCell = function () {
353 this.placeholder = "Type Heading Here";
343 this.placeholder = "Type Heading Here";
354 IPython.TextCell.apply(this, arguments);
344 IPython.TextCell.apply(this, arguments);
355 this.cell_type = 'heading';
345 this.cell_type = 'heading';
356 this.level = 1;
346 this.level = 1;
357 };
347 };
358
348
359
349
360 HeadingCell.prototype = new TextCell();
350 HeadingCell.prototype = new TextCell();
361
351
362
352
363 HeadingCell.prototype.fromJSON = function (data) {
353 HeadingCell.prototype.fromJSON = function (data) {
364 if (data.level != undefined){
354 if (data.level != undefined){
365 this.level = data.level;
355 this.level = data.level;
366 }
356 }
367 IPython.TextCell.prototype.fromJSON.apply(this, arguments);
357 IPython.TextCell.prototype.fromJSON.apply(this, arguments);
368 };
358 };
369
359
370
360
371 HeadingCell.prototype.toJSON = function () {
361 HeadingCell.prototype.toJSON = function () {
372 var data = IPython.TextCell.prototype.toJSON.apply(this);
362 var data = IPython.TextCell.prototype.toJSON.apply(this);
373 data.level = this.get_level();
363 data.level = this.get_level();
374 return data;
364 return data;
375 };
365 };
376
366
377
367
378 HeadingCell.prototype.set_level = function (level) {
368 HeadingCell.prototype.set_level = function (level) {
379 this.level = level;
369 this.level = level;
380 if (this.rendered) {
370 if (this.rendered) {
381 this.rendered = false;
371 this.rendered = false;
382 this.render();
372 this.render();
383 };
373 };
384 };
374 };
385
375
386
376
387 HeadingCell.prototype.get_level = function () {
377 HeadingCell.prototype.get_level = function () {
388 return this.level;
378 return this.level;
389 };
379 };
390
380
391
381
392 HeadingCell.prototype.set_rendered = function (text) {
382 HeadingCell.prototype.set_rendered = function (text) {
393 var r = this.element.find("div.text_cell_render");
383 var r = this.element.find("div.text_cell_render");
394 r.empty();
384 r.empty();
395 r.append($('<h'+this.level+'/>').html(text));
385 r.append($('<h'+this.level+'/>').html(text));
396 };
386 };
397
387
398
388
399 HeadingCell.prototype.get_rendered = function () {
389 HeadingCell.prototype.get_rendered = function () {
400 var r = this.element.find("div.text_cell_render");
390 var r = this.element.find("div.text_cell_render");
401 return r.children().first().html();
391 return r.children().first().html();
402 };
392 };
403
393
404
394
405 HeadingCell.prototype.render = function () {
395 HeadingCell.prototype.render = function () {
406 if (this.rendered === false) {
396 if (this.rendered === false) {
407 var text = this.get_text();
397 var text = this.get_text();
408 if (text === "") { text = this.placeholder; }
398 if (text === "") { text = this.placeholder; }
409 this.set_rendered(text);
399 this.set_rendered(text);
410 this.typeset();
400 this.typeset();
411 this.element.find('div.text_cell_input').hide();
401 this.element.find('div.text_cell_input').hide();
412 this.element.find("div.text_cell_render").show();
402 this.element.find("div.text_cell_render").show();
413 this.rendered = true;
403 this.rendered = true;
414 };
404 };
415 };
405 };
416
406
417 IPython.TextCell = TextCell;
407 IPython.TextCell = TextCell;
418 IPython.HTMLCell = HTMLCell;
408 IPython.HTMLCell = HTMLCell;
419 IPython.MarkdownCell = MarkdownCell;
409 IPython.MarkdownCell = MarkdownCell;
420 IPython.RawCell = RawCell;
410 IPython.RawCell = RawCell;
421 IPython.HeadingCell = HeadingCell;
411 IPython.HeadingCell = HeadingCell;
422
412
423
413
424 return IPython;
414 return IPython;
425
415
426 }(IPython));
416 }(IPython));
427
417
@@ -1,240 +1,226 b''
1 {% extends page.html %}
1 {% extends page.html %}
2 {% block stylesheet %}
2 {% block stylesheet %}
3
3
4 {% if mathjax_url %}
4 {% if mathjax_url %}
5 <script type="text/x-mathjax-config">
5 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script>
6 MathJax.Hub.Config({
7 tex2jax: {
8 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
9 displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
10 processEnvironments: true
11 },
12 displayAlign: 'left', // Change this to 'center' to center equations.
13 "HTML-CSS": {
14 styles: {'.MathJax_Display': {"margin": 0}}
15 }
16 });
17 </script>
18
19 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full" charset="utf-8"></script>
20 {% end %}
6 {% end %}
21 <script type="text/javascript">
7 <script type="text/javascript">
22 // MathJax disabled, set as null to distingish from *missing* MathJax,
8 // MathJax disabled, set as null to distingish from *missing* MathJax,
23 // where it will be undefined, and should prompt a dialog later.
9 // where it will be undefined, and should prompt a dialog later.
24 window.mathjax_url = "{{mathjax_url}}";
10 window.mathjax_url = "{{mathjax_url}}";
25 </script>
11 </script>
26
12
27 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
13 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
28 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
14 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
29
15
30 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
16 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
31
17
32 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
18 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
33 <link rel="stylesheet" href="{{ static_url("css/tooltip.css") }}" type="text/css" />
19 <link rel="stylesheet" href="{{ static_url("css/tooltip.css") }}" type="text/css" />
34 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
20 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
35
21
36 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" media="print"/>
22 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" media="print"/>
37
23
38 {% end %}
24 {% end %}
39
25
40
26
41 {% block params %}
27 {% block params %}
42
28
43 data-project={{project}}
29 data-project={{project}}
44 data-base-project-url={{base_project_url}}
30 data-base-project-url={{base_project_url}}
45 data-base-kernel-url={{base_kernel_url}}
31 data-base-kernel-url={{base_kernel_url}}
46 data-read-only={{read_only and not logged_in}}
32 data-read-only={{read_only and not logged_in}}
47 data-notebook-id={{notebook_id}}
33 data-notebook-id={{notebook_id}}
48
34
49 {% end %}
35 {% end %}
50
36
51
37
52 {% block header %}
38 {% block header %}
53
39
54 <span id="save_widget">
40 <span id="save_widget">
55 <span id="notebook_name"></span>
41 <span id="notebook_name"></span>
56 <span id="save_status"></span>
42 <span id="save_status"></span>
57 </span>
43 </span>
58
44
59 {% end %}
45 {% end %}
60
46
61
47
62 {% block site %}
48 {% block site %}
63
49
64 <div id="menubar_container">
50 <div id="menubar_container">
65 <div id="menubar">
51 <div id="menubar">
66 <ul id="menus">
52 <ul id="menus">
67 <li><a href="#">File</a>
53 <li><a href="#">File</a>
68 <ul>
54 <ul>
69 <li id="new_notebook"><a href="#">New</a></li>
55 <li id="new_notebook"><a href="#">New</a></li>
70 <li id="open_notebook"><a href="#">Open...</a></li>
56 <li id="open_notebook"><a href="#">Open...</a></li>
71 <hr/>
57 <hr/>
72 <li id="copy_notebook"><a href="#">Make a Copy...</a></li>
58 <li id="copy_notebook"><a href="#">Make a Copy...</a></li>
73 <li id="rename_notebook"><a href="#">Rename...</a></li>
59 <li id="rename_notebook"><a href="#">Rename...</a></li>
74 <li id="save_notebook"><a href="#">Save</a></li>
60 <li id="save_notebook"><a href="#">Save</a></li>
75 <hr/>
61 <hr/>
76 <li><a href="#">Download as</a>
62 <li><a href="#">Download as</a>
77 <ul>
63 <ul>
78 <li id="download_ipynb"><a href="#">IPython (.ipynb)</a></li>
64 <li id="download_ipynb"><a href="#">IPython (.ipynb)</a></li>
79 <li id="download_py"><a href="#">Python (.py)</a></li>
65 <li id="download_py"><a href="#">Python (.py)</a></li>
80 </ul>
66 </ul>
81 </li>
67 </li>
82 <hr/>
68 <hr/>
83 <li id="print_notebook"><a href="/{{notebook_id}}/print" target="_blank">Print View</a></li>
69 <li id="print_notebook"><a href="/{{notebook_id}}/print" target="_blank">Print View</a></li>
84 <hr/>
70 <hr/>
85 <li id="kill_and_exit"><a href="#" >Close and halt</a></li>
71 <li id="kill_and_exit"><a href="#" >Close and halt</a></li>
86 </ul>
72 </ul>
87 </li>
73 </li>
88 <li><a href="#">Edit</a>
74 <li><a href="#">Edit</a>
89 <ul>
75 <ul>
90 <li id="cut_cell"><a href="#">Cut Cell</a></li>
76 <li id="cut_cell"><a href="#">Cut Cell</a></li>
91 <li id="copy_cell"><a href="#">Copy Cell</a></li>
77 <li id="copy_cell"><a href="#">Copy Cell</a></li>
92 <li id="paste_cell" class="ui-state-disabled"><a href="#">Paste Cell</a></li>
78 <li id="paste_cell" class="ui-state-disabled"><a href="#">Paste Cell</a></li>
93 <li id="paste_cell_above" class="ui-state-disabled"><a href="#">Paste Cell Above</a></li>
79 <li id="paste_cell_above" class="ui-state-disabled"><a href="#">Paste Cell Above</a></li>
94 <li id="paste_cell_below" class="ui-state-disabled"><a href="#">Paste Cell Below</a></li>
80 <li id="paste_cell_below" class="ui-state-disabled"><a href="#">Paste Cell Below</a></li>
95 <li id="delete_cell"><a href="#">Delete</a></li>
81 <li id="delete_cell"><a href="#">Delete</a></li>
96 <hr/>
82 <hr/>
97 <li id="split_cell"><a href="#">Split Cell</a></li>
83 <li id="split_cell"><a href="#">Split Cell</a></li>
98 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
84 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
99 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
85 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
100 <hr/>
86 <hr/>
101 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
87 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
102 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
88 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
103 <hr/>
89 <hr/>
104 <li id="select_previous"><a href="#">Select Previous Cell</a></li>
90 <li id="select_previous"><a href="#">Select Previous Cell</a></li>
105 <li id="select_next"><a href="#">Select Next Cell</a></li>
91 <li id="select_next"><a href="#">Select Next Cell</a></li>
106 </ul>
92 </ul>
107 </li>
93 </li>
108 <li><a href="#">View</a>
94 <li><a href="#">View</a>
109 <ul>
95 <ul>
110 <li id="toggle_header"><a href="#">Toggle Header</a></li>
96 <li id="toggle_header"><a href="#">Toggle Header</a></li>
111 <li id="toggle_toolbar"><a href="#">Toggle Toolbar</a></li>
97 <li id="toggle_toolbar"><a href="#">Toggle Toolbar</a></li>
112 </ul>
98 </ul>
113 </li>
99 </li>
114 <li><a href="#">Insert</a>
100 <li><a href="#">Insert</a>
115 <ul>
101 <ul>
116 <li id="insert_cell_above"><a href="#">Insert Cell Above</a></li>
102 <li id="insert_cell_above"><a href="#">Insert Cell Above</a></li>
117 <li id="insert_cell_below"><a href="#">Insert Cell Below</a></li>
103 <li id="insert_cell_below"><a href="#">Insert Cell Below</a></li>
118 </ul>
104 </ul>
119 </li>
105 </li>
120 <li><a href="#">Cell</a>
106 <li><a href="#">Cell</a>
121 <ul>
107 <ul>
122 <li id="run_cell"><a href="#">Run</a></li>
108 <li id="run_cell"><a href="#">Run</a></li>
123 <li id="run_cell_in_place"><a href="#">Run in Place</a></li>
109 <li id="run_cell_in_place"><a href="#">Run in Place</a></li>
124 <li id="run_all_cells"><a href="#">Run All</a></li>
110 <li id="run_all_cells"><a href="#">Run All</a></li>
125 <li id="run_all_cells_above"><a href="#">Run All Above</a></li>
111 <li id="run_all_cells_above"><a href="#">Run All Above</a></li>
126 <li id="run_all_cells_below"><a href="#">Run All Below</a></li>
112 <li id="run_all_cells_below"><a href="#">Run All Below</a></li>
127 <hr/>
113 <hr/>
128 <li id="to_code"><a href="#">Code</a></li>
114 <li id="to_code"><a href="#">Code</a></li>
129 <li id="to_markdown"><a href="#">Markdown </a></li>
115 <li id="to_markdown"><a href="#">Markdown </a></li>
130 <li id="to_raw"><a href="#">Raw Text</a></li>
116 <li id="to_raw"><a href="#">Raw Text</a></li>
131 <li id="to_heading1"><a href="#">Heading 1</a></li>
117 <li id="to_heading1"><a href="#">Heading 1</a></li>
132 <li id="to_heading2"><a href="#">Heading 2</a></li>
118 <li id="to_heading2"><a href="#">Heading 2</a></li>
133 <li id="to_heading3"><a href="#">Heading 3</a></li>
119 <li id="to_heading3"><a href="#">Heading 3</a></li>
134 <li id="to_heading4"><a href="#">Heading 4</a></li>
120 <li id="to_heading4"><a href="#">Heading 4</a></li>
135 <li id="to_heading5"><a href="#">Heading 5</a></li>
121 <li id="to_heading5"><a href="#">Heading 5</a></li>
136 <li id="to_heading6"><a href="#">Heading 6</a></li>
122 <li id="to_heading6"><a href="#">Heading 6</a></li>
137 <hr/>
123 <hr/>
138 <li id="toggle_output"><a href="#">Toggle Current Output</a></li>
124 <li id="toggle_output"><a href="#">Toggle Current Output</a></li>
139 <li id="all_outputs"><a href="#">All Output</a>
125 <li id="all_outputs"><a href="#">All Output</a>
140 <ul>
126 <ul>
141 <li id="expand_all_output"><a href="#">Expand</a></li>
127 <li id="expand_all_output"><a href="#">Expand</a></li>
142 <li id="scroll_all_output"><a href="#">Scroll Long</a></li>
128 <li id="scroll_all_output"><a href="#">Scroll Long</a></li>
143 <li id="collapse_all_output"><a href="#">Collapse</a></li>
129 <li id="collapse_all_output"><a href="#">Collapse</a></li>
144 <li id="clear_all_output"><a href="#">Clear</a></li>
130 <li id="clear_all_output"><a href="#">Clear</a></li>
145 </ul>
131 </ul>
146 </li>
132 </li>
147 </ul>
133 </ul>
148 </li>
134 </li>
149 <li><a href="#">Kernel</a>
135 <li><a href="#">Kernel</a>
150 <ul>
136 <ul>
151 <li id="int_kernel"><a href="#">Interrupt</a></li>
137 <li id="int_kernel"><a href="#">Interrupt</a></li>
152 <li id="restart_kernel"><a href="#">Restart</a></li>
138 <li id="restart_kernel"><a href="#">Restart</a></li>
153 </ul>
139 </ul>
154 </li>
140 </li>
155 <li><a href="#">Help</a>
141 <li><a href="#">Help</a>
156 <ul>
142 <ul>
157 <li><a href="http://ipython.org/documentation.html" target="_blank">IPython Help</a></li>
143 <li><a href="http://ipython.org/documentation.html" target="_blank">IPython Help</a></li>
158 <li><a href="http://ipython.org/ipython-doc/stable/interactive/htmlnotebook.html" target="_blank">Notebook Help</a></li>
144 <li><a href="http://ipython.org/ipython-doc/stable/interactive/htmlnotebook.html" target="_blank">Notebook Help</a></li>
159 <li id="keyboard_shortcuts"><a href="#">Keyboard Shortcuts</a></li>
145 <li id="keyboard_shortcuts"><a href="#">Keyboard Shortcuts</a></li>
160 <hr/>
146 <hr/>
161 <li><a href="http://docs.python.org" target="_blank">Python</a></li>
147 <li><a href="http://docs.python.org" target="_blank">Python</a></li>
162 <li><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></li>
148 <li><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></li>
163 <li><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></li>
149 <li><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></li>
164 <li><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></li>
150 <li><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></li>
165 <li><a href="http://matplotlib.sourceforge.net/" target="_blank">Matplotlib</a></li>
151 <li><a href="http://matplotlib.sourceforge.net/" target="_blank">Matplotlib</a></li>
166 </ul>
152 </ul>
167 </li>
153 </li>
168 </ul>
154 </ul>
169
155
170 </div>
156 </div>
171 <div id="notification_area">
157 <div id="notification_area">
172 </div>
158 </div>
173 </div>
159 </div>
174
160
175
161
176 <div id="maintoolbar"></div>
162 <div id="maintoolbar"></div>
177
163
178 <div id="main_app">
164 <div id="main_app">
179
165
180 <div id="notebook_panel">
166 <div id="notebook_panel">
181 <div id="notebook"></div>
167 <div id="notebook"></div>
182 <div id="pager_splitter"></div>
168 <div id="pager_splitter"></div>
183 <div id="pager_container">
169 <div id="pager_container">
184 <div id='pager_button_area'>
170 <div id='pager_button_area'>
185 </div>
171 </div>
186 <div id="pager"></div>
172 <div id="pager"></div>
187 </div>
173 </div>
188 </div>
174 </div>
189
175
190 </div>
176 </div>
191 <div id='tooltip' class='ipython_tooltip ui-corner-all' style='display:none'></div>
177 <div id='tooltip' class='ipython_tooltip ui-corner-all' style='display:none'></div>
192
178
193
179
194 {% end %}
180 {% end %}
195
181
196
182
197 {% block script %}
183 {% block script %}
198
184
199 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
185 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
200 <script src="{{ static_url("codemirror/lib/util/loadmode.js") }}" charset="utf-8"></script>
186 <script src="{{ static_url("codemirror/lib/util/loadmode.js") }}" charset="utf-8"></script>
201 <script src="{{ static_url("codemirror/lib/util/multiplex.js") }}" charset="utf-8"></script>
187 <script src="{{ static_url("codemirror/lib/util/multiplex.js") }}" charset="utf-8"></script>
202 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
188 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
203 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
189 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
204 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
190 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
205 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
191 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
206 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
192 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
207 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
193 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
208 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
194 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
209
195
210 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
196 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
211
197
212 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
198 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
213 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
199 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
214
200
215 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
201 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
216 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
202 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
217 <script src="{{ static_url("js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
203 <script src="{{ static_url("js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
218 <script src="{{ static_url("js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
204 <script src="{{ static_url("js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
219 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
205 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
220 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
206 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
221 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
207 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
222 <script src="{{ static_url("js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
208 <script src="{{ static_url("js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
223 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
209 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
224 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
210 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
225 <script src="{{ static_url("js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
211 <script src="{{ static_url("js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
226 <script src="{{ static_url("js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
212 <script src="{{ static_url("js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
227 <script src="{{ static_url("js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
213 <script src="{{ static_url("js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
228 <script src="{{ static_url("js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
214 <script src="{{ static_url("js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
229 <script src="{{ static_url("js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
215 <script src="{{ static_url("js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
230 <script src="{{ static_url("js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
216 <script src="{{ static_url("js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
231 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
217 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
232 <script src="{{ static_url("js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
218 <script src="{{ static_url("js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
233 <script src="{{ static_url("js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
219 <script src="{{ static_url("js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
234 <script src="{{ static_url("js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
220 <script src="{{ static_url("js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
235 <script src="{{ static_url("js/config.js") }}" type="text/javascript" charset="utf-8"></script>
221 <script src="{{ static_url("js/config.js") }}" type="text/javascript" charset="utf-8"></script>
236 <script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
222 <script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
237
223
238 <script src="{{ static_url("js/contexthint.js") }}" charset="utf-8"></script>
224 <script src="{{ static_url("js/contexthint.js") }}" charset="utf-8"></script>
239
225
240 {% end %}
226 {% end %}
@@ -1,95 +1,81 b''
1 {% extends page.html %}
1 {% extends page.html %}
2
2
3 {% block stylesheet %}
3 {% block stylesheet %}
4
4
5 {% if mathjax_url %}
5 {% if mathjax_url %}
6 <script type="text/x-mathjax-config">
6 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script>
7 MathJax.Hub.Config({
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
20 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full" charset="utf-8"></script>
21 {% end %}
7 {% end %}
22 <script type="text/javascript">
8 <script type="text/javascript">
23 // MathJax disabled, set as null to distingish from *missing* MathJax,
9 // MathJax disabled, set as null to distingish from *missing* MathJax,
24 // where it will be undefined, and should prompt a dialog later.
10 // where it will be undefined, and should prompt a dialog later.
25 window.mathjax_url = "{{mathjax_url}}";
11 window.mathjax_url = "{{mathjax_url}}";
26 </script>
12 </script>
27
13
28 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
14 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
29 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
15 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
30
16
31 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
17 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
32
18
33 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
19 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
34 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" />
20 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" />
35 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
21 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
36
22
37 {% end %}
23 {% end %}
38
24
39
25
40 {% block params %}
26 {% block params %}
41
27
42 data-project={{project}}
28 data-project={{project}}
43 data-base-project-url={{base_project_url}}
29 data-base-project-url={{base_project_url}}
44 data-base-kernel-url={{base_kernel_url}}
30 data-base-kernel-url={{base_kernel_url}}
45 data-read-only={{read_only and not logged_in}}
31 data-read-only={{read_only and not logged_in}}
46 data-notebook-id={{notebook_id}}
32 data-notebook-id={{notebook_id}}
47
33
48 {% end %}
34 {% end %}
49
35
50
36
51 {% block header %}
37 {% block header %}
52 {% end %}
38 {% end %}
53
39
54
40
55 {% block site %}
41 {% block site %}
56
42
57 <div id="main_app">
43 <div id="main_app">
58
44
59 <div id="notebook_panel">
45 <div id="notebook_panel">
60 <div id="notebook"></div>
46 <div id="notebook"></div>
61 </div>
47 </div>
62
48
63 </div>
49 </div>
64
50
65 {% end %}
51 {% end %}
66
52
67
53
68 {% block script %}
54 {% block script %}
69
55
70 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
56 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
71 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
57 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
72 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
58 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
73 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
59 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
74 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
60 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
75 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
61 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
76 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
62 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
77 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
63 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
78
64
79 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
65 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
80
66
81 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
67 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
82 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
68 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
83
69
84 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
70 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
85 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
71 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
86 <script src="{{ static_url("js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
72 <script src="{{ static_url("js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
87 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
73 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
88 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
74 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
89 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
75 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
90 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
76 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
91 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
77 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
92 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
78 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
93 <script src="{{ static_url("js/printnotebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
79 <script src="{{ static_url("js/printnotebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
94
80
95 {% end %}
81 {% end %}
General Comments 0
You need to be logged in to leave comments. Login now