Show More
@@ -130,8 +130,8 var IPython = (function (IPython) { | |||
|
130 | 130 | this.element.find('#to_markdown').click(function () { |
|
131 | 131 | IPython.notebook.to_markdown(); |
|
132 | 132 | }); |
|
133 |
this.element.find('#to_ |
|
|
134 |
IPython.notebook.to_ |
|
|
133 | this.element.find('#to_raw').click(function () { | |
|
134 | IPython.notebook.to_raw(); | |
|
135 | 135 | }); |
|
136 | 136 | this.element.find('#to_heading1').click(function () { |
|
137 | 137 | IPython.notebook.to_heading(undefined, 1); |
@@ -140,8 +140,8 var IPython = (function (IPython) { | |||
|
140 | 140 | that.control_key_active = false; |
|
141 | 141 | return false; |
|
142 | 142 | } else if (event.which === 84 && that.control_key_active) { |
|
143 |
// To |
|
|
144 |
that.to_ |
|
|
143 | // To Raw = t | |
|
144 | that.to_raw(); | |
|
145 | 145 | that.control_key_active = false; |
|
146 | 146 | return false; |
|
147 | 147 | } else if (event.which === 49 && that.control_key_active) { |
@@ -523,8 +523,8 var IPython = (function (IPython) { | |||
|
523 | 523 | cell = new IPython.MarkdownCell(this); |
|
524 | 524 | } else if (type === 'html') { |
|
525 | 525 | cell = new IPython.HTMLCell(this); |
|
526 |
} else if (type === ' |
|
|
527 |
cell = new IPython. |
|
|
526 | } else if (type === 'raw') { | |
|
527 | cell = new IPython.RawCell(this); | |
|
528 | 528 | } else if (type === 'heading') { |
|
529 | 529 | cell = new IPython.HeadingCell(this); |
|
530 | 530 | }; |
@@ -557,8 +557,8 var IPython = (function (IPython) { | |||
|
557 | 557 | cell = new IPython.MarkdownCell(this); |
|
558 | 558 | } else if (type === 'html') { |
|
559 | 559 | cell = new IPython.HTMLCell(this); |
|
560 |
} else if (type === ' |
|
|
561 |
cell = new IPython. |
|
|
560 | } else if (type === 'raw') { | |
|
561 | cell = new IPython.RawCell(this); | |
|
562 | 562 | } else if (type === 'heading') { |
|
563 | 563 | cell = new IPython.HeadingCell(this); |
|
564 | 564 | }; |
@@ -640,14 +640,14 var IPython = (function (IPython) { | |||
|
640 | 640 | }; |
|
641 | 641 | |
|
642 | 642 | |
|
643 |
Notebook.prototype.to_ |
|
|
643 | Notebook.prototype.to_raw = function (index) { | |
|
644 | 644 | var i = this.index_or_selected(index); |
|
645 | 645 | if (this.is_valid_cell_index(i)) { |
|
646 | 646 | var source_element = this.get_cell_element(i); |
|
647 | 647 | var source_cell = source_element.data("cell"); |
|
648 | 648 | var target_cell = null; |
|
649 |
if (!(source_cell instanceof IPython. |
|
|
650 |
target_cell = this.insert_cell_below(' |
|
|
649 | if (!(source_cell instanceof IPython.RawCell)) { | |
|
650 | target_cell = this.insert_cell_below('raw',i); | |
|
651 | 651 | var text = source_cell.get_text(); |
|
652 | 652 | if (text === source_cell.placeholder) { |
|
653 | 653 | text = ''; |
@@ -1197,6 +1197,12 var IPython = (function (IPython) { | |||
|
1197 | 1197 | var new_cell = null; |
|
1198 | 1198 | for (i=0; i<ncells; i++) { |
|
1199 | 1199 | cell_data = new_cells[i]; |
|
1200 | // VERSIONHACK: plaintext -> raw | |
|
1201 | // handle never-released plaintext name for raw cells | |
|
1202 | if (cell_data.cell_type === 'plaintext'){ | |
|
1203 | cell_data.cell_type = 'raw'; | |
|
1204 | } | |
|
1205 | ||
|
1200 | 1206 | new_cell = this.insert_cell_below(cell_data.cell_type); |
|
1201 | 1207 | new_cell.fromJSON(cell_data); |
|
1202 | 1208 | }; |
@@ -41,7 +41,7 var IPython = (function (IPython) { | |||
|
41 | 41 | {key: 'Ctrl-m k', help: 'move cell up'}, |
|
42 | 42 | {key: 'Ctrl-m y', help: 'code cell'}, |
|
43 | 43 | {key: 'Ctrl-m m', help: 'markdown cell'}, |
|
44 |
{key: 'Ctrl-m t', help: ' |
|
|
44 | {key: 'Ctrl-m t', help: 'raw cell'}, | |
|
45 | 45 | {key: 'Ctrl-m 1-6', help: 'heading 1-6 cell'}, |
|
46 | 46 | {key: 'Ctrl-m p', help: 'select previous'}, |
|
47 | 47 | {key: 'Ctrl-m n', help: 'select next'}, |
@@ -237,33 +237,33 var IPython = (function (IPython) { | |||
|
237 | 237 | }; |
|
238 | 238 | |
|
239 | 239 | |
|
240 |
// |
|
|
240 | // RawCell | |
|
241 | 241 | |
|
242 |
var |
|
|
242 | var RawCell = function (notebook) { | |
|
243 | 243 | this.placeholder = "Type plain text and LaTeX: $\\alpha^2$"; |
|
244 | 244 | this.code_mirror_mode = 'rst'; |
|
245 | 245 | IPython.TextCell.apply(this, arguments); |
|
246 |
this.cell_type = ' |
|
|
246 | this.cell_type = 'raw'; | |
|
247 | 247 | }; |
|
248 | 248 | |
|
249 | 249 | |
|
250 |
|
|
|
250 | RawCell.prototype = new TextCell(); | |
|
251 | 251 | |
|
252 | 252 | |
|
253 |
|
|
|
253 | RawCell.prototype.render = function () { | |
|
254 | 254 | this.rendered = true; |
|
255 | 255 | this.edit(); |
|
256 | 256 | }; |
|
257 | 257 | |
|
258 | 258 | |
|
259 |
|
|
|
259 | RawCell.prototype.select = function () { | |
|
260 | 260 | IPython.Cell.prototype.select.apply(this); |
|
261 | 261 | this.code_mirror.refresh(); |
|
262 | 262 | this.code_mirror.focus(); |
|
263 | 263 | }; |
|
264 | 264 | |
|
265 | 265 | |
|
266 |
|
|
|
266 | RawCell.prototype.at_top = function () { | |
|
267 | 267 | var cursor = this.code_mirror.getCursor(); |
|
268 | 268 | if (cursor.line === 0) { |
|
269 | 269 | return true; |
@@ -273,7 +273,7 var IPython = (function (IPython) { | |||
|
273 | 273 | }; |
|
274 | 274 | |
|
275 | 275 | |
|
276 |
|
|
|
276 | RawCell.prototype.at_bottom = function () { | |
|
277 | 277 | var cursor = this.code_mirror.getCursor(); |
|
278 | 278 | if (cursor.line === (this.code_mirror.lineCount()-1)) { |
|
279 | 279 | return true; |
@@ -353,7 +353,7 var IPython = (function (IPython) { | |||
|
353 | 353 | IPython.TextCell = TextCell; |
|
354 | 354 | IPython.HTMLCell = HTMLCell; |
|
355 | 355 | IPython.MarkdownCell = MarkdownCell; |
|
356 |
IPython. |
|
|
356 | IPython.RawCell = RawCell; | |
|
357 | 357 | IPython.HeadingCell = HeadingCell; |
|
358 | 358 | |
|
359 | 359 |
@@ -113,8 +113,8 var IPython = (function (IPython) { | |||
|
113 | 113 | IPython.notebook.to_code(); |
|
114 | 114 | } else if (cell_type === 'markdown') { |
|
115 | 115 | IPython.notebook.to_markdown(); |
|
116 |
} else if (cell_type === ' |
|
|
117 |
IPython.notebook.to_ |
|
|
116 | } else if (cell_type === 'raw') { | |
|
117 | IPython.notebook.to_raw(); | |
|
118 | 118 | } else if (cell_type === 'heading1') { |
|
119 | 119 | IPython.notebook.to_heading(undefined, 1); |
|
120 | 120 | } else if (cell_type === 'heading2') { |
@@ -107,7 +107,7 data-notebook-id={{notebook_id}} | |||
|
107 | 107 | <hr/> |
|
108 | 108 | <li id="to_code"><a href="#">Code</a></li> |
|
109 | 109 | <li id="to_markdown"><a href="#">Markdown </a></li> |
|
110 |
<li id="to_ |
|
|
110 | <li id="to_raw"><a href="#">Raw Text</a></li> | |
|
111 | 111 | <li id="to_heading1"><a href="#">Heading 1</a></li> |
|
112 | 112 | <li id="to_heading2"><a href="#">Heading 2</a></li> |
|
113 | 113 | <li id="to_heading3"><a href="#">Heading 3</a></li> |
@@ -171,7 +171,7 data-notebook-id={{notebook_id}} | |||
|
171 | 171 | <select id="cell_type"> |
|
172 | 172 | <option value="code">Code</option> |
|
173 | 173 | <option value="markdown">Markdown</option> |
|
174 |
<option value=" |
|
|
174 | <option value="raw">Raw Text</option> | |
|
175 | 175 | <option value="heading1">Heading 1</option> |
|
176 | 176 | <option value="heading2">Heading 2</option> |
|
177 | 177 | <option value="heading3">Heading 3</option> |
@@ -114,6 +114,10 def new_code_cell(input=None, prompt_number=None, outputs=None, | |||
|
114 | 114 | def new_text_cell(cell_type, source=None, rendered=None): |
|
115 | 115 | """Create a new text cell.""" |
|
116 | 116 | cell = NotebookNode() |
|
117 | # VERSIONHACK: plaintext -> raw | |
|
118 | # handle never-released plaintext name for raw cells | |
|
119 | if cell_type == 'plaintext': | |
|
120 | cell_type = 'raw' | |
|
117 | 121 | if source is not None: |
|
118 | 122 | cell.source = unicode(source) |
|
119 | 123 | if rendered is not None: |
@@ -68,11 +68,12 class PyReader(NotebookReader): | |||
|
68 | 68 | state = u'markdowncell' |
|
69 | 69 | cell_lines = [] |
|
70 | 70 | kwargs = {} |
|
71 | elif line.startswith(u'# <plaintextcell>'): | |
|
71 | # VERSIONHACK: plaintext -> raw | |
|
72 | elif line.startswith(u'# <rawcell>') or line.startswith(u'# <plaintextcell>'): | |
|
72 | 73 | cell = self.new_cell(state, cell_lines, **kwargs) |
|
73 | 74 | if cell is not None: |
|
74 | 75 | cells.append(cell) |
|
75 |
state = u' |
|
|
76 | state = u'rawcell' | |
|
76 | 77 | cell_lines = [] |
|
77 | 78 | kwargs = {} |
|
78 | 79 | elif line.startswith(u'# <headingcell'): |
@@ -113,10 +114,10 class PyReader(NotebookReader): | |||
|
113 | 114 | text = self._remove_comments(lines) |
|
114 | 115 | if text: |
|
115 | 116 | return new_text_cell(u'markdown',source=text) |
|
116 |
elif state == u' |
|
|
117 | elif state == u'rawcell': | |
|
117 | 118 | text = self._remove_comments(lines) |
|
118 | 119 | if text: |
|
119 |
return new_text_cell(u' |
|
|
120 | return new_text_cell(u'raw',source=text) | |
|
120 | 121 | elif state == u'headingcell': |
|
121 | 122 | text = self._remove_comments(lines) |
|
122 | 123 | level = kwargs.get('level',1) |
@@ -172,10 +173,10 class PyWriter(NotebookWriter): | |||
|
172 | 173 | lines.extend([u'# <markdowncell>',u'']) |
|
173 | 174 | lines.extend([u'# ' + line for line in input.splitlines()]) |
|
174 | 175 | lines.append(u'') |
|
175 |
elif cell.cell_type == u' |
|
|
176 | elif cell.cell_type == u'raw': | |
|
176 | 177 | input = cell.get(u'source') |
|
177 | 178 | if input is not None: |
|
178 |
lines.extend([u'# < |
|
|
179 | lines.extend([u'# <rawcell>',u'']) | |
|
179 | 180 | lines.extend([u'# ' + line for line in input.splitlines()]) |
|
180 | 181 | lines.append(u'') |
|
181 | 182 | elif cell.cell_type == u'heading': |
@@ -35,7 +35,7 ws.cells.append(new_text_cell( | |||
|
35 | 35 | )) |
|
36 | 36 | |
|
37 | 37 | ws.cells.append(new_text_cell( |
|
38 |
u' |
|
|
38 | u'raw', | |
|
39 | 39 | source='A random array', |
|
40 | 40 | )) |
|
41 | 41 | |
@@ -116,7 +116,7 import numpy | |||
|
116 | 116 | |
|
117 | 117 | # A random array |
|
118 | 118 | |
|
119 |
# < |
|
|
119 | # <rawcell> | |
|
120 | 120 | |
|
121 | 121 | # A random array |
|
122 | 122 |
@@ -59,14 +59,14 class TestCell(TestCase): | |||
|
59 | 59 | self.assertEquals(tc.source, u'hi') |
|
60 | 60 | self.assertEquals(tc.rendered, u'hi') |
|
61 | 61 | |
|
62 |
def test_empty_ |
|
|
63 |
tc = new_text_cell(u' |
|
|
64 |
self.assertEquals(tc.cell_type, u' |
|
|
62 | def test_empty_raw_cell(self): | |
|
63 | tc = new_text_cell(u'raw') | |
|
64 | self.assertEquals(tc.cell_type, u'raw') | |
|
65 | 65 | self.assertEquals(u'source' not in tc, True) |
|
66 | 66 | self.assertEquals(u'rendered' not in tc, True) |
|
67 | 67 | |
|
68 |
def test_ |
|
|
69 |
tc = new_text_cell(u' |
|
|
68 | def test_raw_cell(self): | |
|
69 | tc = new_text_cell(u'raw', 'hi', 'hi') | |
|
70 | 70 | self.assertEquals(tc.source, u'hi') |
|
71 | 71 | self.assertEquals(tc.rendered, u'hi') |
|
72 | 72 |
General Comments 0
You need to be logged in to leave comments.
Login now