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