##// END OF EJS Templates
rename plaintext cell -> raw cell
MinRK -
Show More
@@ -130,8 +130,8 b' 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_plaintext').click(function () {
134 IPython.notebook.to_plaintext();
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 b' 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 Plaintext = t
144 that.to_plaintext();
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 b' 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 === 'plaintext') {
527 cell = new IPython.PlaintextCell(this);
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 b' 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 === 'plaintext') {
561 cell = new IPython.PlaintextCell(this);
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 b' var IPython = (function (IPython) {'
640 640 };
641 641
642 642
643 Notebook.prototype.to_plaintext = function (index) {
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.PlaintextCell)) {
650 target_cell = this.insert_cell_below('plaintext',i);
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 = '';
@@ -41,7 +41,7 b' 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: 'plaintext cell'},
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 b' var IPython = (function (IPython) {'
237 237 };
238 238
239 239
240 // PlaintextCell
240 // RawCell
241 241
242 var PlaintextCell = function (notebook) {
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 = 'plaintext';
246 this.cell_type = 'raw';
247 247 };
248 248
249 249
250 PlaintextCell.prototype = new TextCell();
250 RawCell.prototype = new TextCell();
251 251
252 252
253 PlaintextCell.prototype.render = function () {
253 RawCell.prototype.render = function () {
254 254 this.rendered = true;
255 255 this.edit();
256 256 };
257 257
258 258
259 PlaintextCell.prototype.select = function () {
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 PlaintextCell.prototype.at_top = function () {
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 b' var IPython = (function (IPython) {'
273 273 };
274 274
275 275
276 PlaintextCell.prototype.at_bottom = function () {
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 b' var IPython = (function (IPython) {'
353 353 IPython.TextCell = TextCell;
354 354 IPython.HTMLCell = HTMLCell;
355 355 IPython.MarkdownCell = MarkdownCell;
356 IPython.PlaintextCell = PlaintextCell;
356 IPython.RawCell = RawCell;
357 357 IPython.HeadingCell = HeadingCell;
358 358
359 359
@@ -113,8 +113,8 b' 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 === 'plaintext') {
117 IPython.notebook.to_plaintext();
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 b' 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_plaintext"><a href="#">Plaintext</a></li>
110 <li id="to_raw"><a href="#">Raw</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 b' 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="plaintext">Plaintext</option>
174 <option value="raw">Raw</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>
@@ -68,11 +68,11 b' class PyReader(NotebookReader):'
68 68 state = u'markdowncell'
69 69 cell_lines = []
70 70 kwargs = {}
71 elif line.startswith(u'# <plaintextcell>'):
71 elif line.startswith(u'# <rawcell>'):
72 72 cell = self.new_cell(state, cell_lines, **kwargs)
73 73 if cell is not None:
74 74 cells.append(cell)
75 state = u'plaintextcell'
75 state = u'rawcell'
76 76 cell_lines = []
77 77 kwargs = {}
78 78 elif line.startswith(u'# <headingcell'):
@@ -113,10 +113,10 b' class PyReader(NotebookReader):'
113 113 text = self._remove_comments(lines)
114 114 if text:
115 115 return new_text_cell(u'markdown',source=text)
116 elif state == u'plaintextcell':
116 elif state == u'rawcell':
117 117 text = self._remove_comments(lines)
118 118 if text:
119 return new_text_cell(u'plaintext',source=text)
119 return new_text_cell(u'raw',source=text)
120 120 elif state == u'headingcell':
121 121 text = self._remove_comments(lines)
122 122 level = kwargs.get('level',1)
@@ -172,10 +172,10 b' class PyWriter(NotebookWriter):'
172 172 lines.extend([u'# <markdowncell>',u''])
173 173 lines.extend([u'# ' + line for line in input.splitlines()])
174 174 lines.append(u'')
175 elif cell.cell_type == u'plaintext':
175 elif cell.cell_type == u'raw':
176 176 input = cell.get(u'source')
177 177 if input is not None:
178 lines.extend([u'# <plaintextcell>',u''])
178 lines.extend([u'# <rawcell>',u''])
179 179 lines.extend([u'# ' + line for line in input.splitlines()])
180 180 lines.append(u'')
181 181 elif cell.cell_type == u'heading':
@@ -33,7 +33,7 b' ws.cells.append(new_text_cell('
33 33 ))
34 34
35 35 ws.cells.append(new_text_cell(
36 u'plaintext',
36 u'raw',
37 37 source='A random array',
38 38 ))
39 39
@@ -106,7 +106,7 b' import numpy'
106 106
107 107 # A random array
108 108
109 # <plaintextcell>
109 # <rawcell>
110 110
111 111 # A random array
112 112
@@ -59,14 +59,14 b' 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_plaintext_cell(self):
63 tc = new_text_cell(u'plaintext')
64 self.assertEquals(tc.cell_type, u'plaintext')
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_plaintext_cell(self):
69 tc = new_text_cell(u'plaintext', 'hi', 'hi')
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