##// END OF EJS Templates
Changing rst->plaintext in nbformat.
Brian Granger -
Show More
@@ -21,10 +21,11 b' import json'
21 21 from xml.etree import ElementTree as ET
22 22 import re
23 23
24 from IPython.nbformat import v3
24 25 from IPython.nbformat import v2
25 26 from IPython.nbformat import v1
26 27
27 from IPython.nbformat.v2 import (
28 from IPython.nbformat.v3 import (
28 29 NotebookNode,
29 30 new_code_cell, new_text_cell, new_notebook, new_output, new_worksheet,
30 31 parse_filename, new_metadata, new_author
@@ -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'# <rstcell>'):
71 elif line.startswith(u'# <plaintextcell>'):
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'rstcell'
75 state = u'plaintextcell'
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'rstcell':
116 elif state == u'plaintextcell':
117 117 text = self._remove_comments(lines)
118 118 if text:
119 return new_text_cell(u'rst',source=text)
119 return new_text_cell(u'plaintext',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'rst':
175 elif cell.cell_type == u'plaintext':
176 176 input = cell.get(u'source')
177 177 if input is not None:
178 lines.extend([u'# <rstcell>',u''])
178 lines.extend([u'# <plaintextcell>',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'rst',
36 u'plaintext',
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 # <rstcell>
109 # <plaintextcell>
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_rst_cell(self):
63 tc = new_text_cell(u'rst')
64 self.assertEquals(tc.cell_type, u'rst')
62 def test_empty_plaintext_cell(self):
63 tc = new_text_cell(u'plaintext')
64 self.assertEquals(tc.cell_type, u'plaintext')
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_rst_cell(self):
69 tc = new_text_cell(u'rst', 'hi', 'hi')
68 def test_plaintext_cell(self):
69 tc = new_text_cell(u'plaintext', '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