##// END OF EJS Templates
preserve trailing newlines in ipynb...
MinRK -
Show More
@@ -86,17 +86,17 b' def split_lines(nb):'
86 86 for cell in ws.cells:
87 87 if cell.cell_type == 'code':
88 88 if 'input' in cell and isinstance(cell.input, basestring):
89 cell.input = cell.input.splitlines()
89 cell.input = (cell.input + '\n').splitlines()
90 90 for output in cell.outputs:
91 91 for key in _multiline_outputs:
92 92 item = output.get(key, None)
93 93 if isinstance(item, basestring):
94 output[key] = item.splitlines()
94 output[key] = (item + '\n').splitlines()
95 95 else: # text, heading cell
96 96 for key in ['source', 'rendered']:
97 97 item = cell.get(key, None)
98 98 if isinstance(item, basestring):
99 cell[key] = item.splitlines()
99 cell[key] = (item + '\n').splitlines()
100 100 return nb
101 101
102 102 # b64 encode/decode are never actually used, because all bytes objects in
@@ -49,6 +49,14 b' ws.cells.append(new_code_cell('
49 49 prompt_number=2,
50 50 collapsed=True
51 51 ))
52 ws.cells.append(new_code_cell(
53 input='a = 10\nb = 5\n',
54 prompt_number=3,
55 ))
56 ws.cells.append(new_code_cell(
57 input='a = 10\nb = 5',
58 prompt_number=4,
59 ))
52 60
53 61 ws.cells.append(new_code_cell(
54 62 input=u'print "ünîcødé"',
@@ -122,6 +130,16 b' a = numpy.random.rand(100)'
122 130
123 131 # <codecell>
124 132
133 a = 10
134 b = 5
135
136 # <codecell>
137
138 a = 10
139 b = 5
140
141 # <codecell>
142
125 143 print "ünîcødé"
126 144
127 145 """ % nbformat
@@ -28,6 +28,11 b' class TestPy(formattest.NBFormatTestCase):'
28 28 for a,b in zip(da, db):
29 29 self.assertSubset(a,b)
30 30 else:
31 if isinstance(da, basestring) and isinstance(db, basestring):
32 # pyfile is not sensitive to preserving leading/trailing
33 # newlines in blocks through roundtrip
34 da = da.strip('\n')
35 db = db.strip('\n')
31 36 self.assertEquals(da, db)
32 37 return True
33 38
General Comments 0
You need to be logged in to leave comments. Login now