Show More
@@ -119,12 +119,14 b' def new_text_cell(cell_type, source=None, rendered=None):' | |||
|
119 | 119 | return cell |
|
120 | 120 | |
|
121 | 121 | |
|
122 | def new_heading_cell(source=None, level=1): | |
|
122 | def new_heading_cell(source=None, rendered=None, level=1): | |
|
123 | 123 | """Create a new section cell with a given integer level.""" |
|
124 | 124 | cell = NotebookNode() |
|
125 | 125 | cell.cell_type = u'heading' |
|
126 | 126 | if source is not None: |
|
127 | 127 | cell.source = unicode(source) |
|
128 | if rendered is not None: | |
|
129 | cell.rendered = unicode(rendered) | |
|
128 | 130 | cell.level = int(level) |
|
129 | 131 | return cell |
|
130 | 132 |
@@ -64,9 +64,7 b' def rejoin_lines(nb):' | |||
|
64 | 64 | item = output.get(key, None) |
|
65 | 65 | if isinstance(item, list): |
|
66 | 66 | output[key] = u'\n'.join(item) |
|
67 |
el |
|
|
68 | pass | |
|
69 | else: # text cell | |
|
67 | else: # text, heading cell | |
|
70 | 68 | for key in ['source', 'rendered']: |
|
71 | 69 | item = cell.get(key, None) |
|
72 | 70 | if isinstance(item, list): |
@@ -92,9 +90,7 b' def split_lines(nb):' | |||
|
92 | 90 | item = output.get(key, None) |
|
93 | 91 | if isinstance(item, basestring): |
|
94 | 92 | output[key] = item.splitlines() |
|
95 |
el |
|
|
96 | pass | |
|
97 | else: # text cell | |
|
93 | else: # text, heading cell | |
|
98 | 94 | for key in ['source', 'rendered']: |
|
99 | 95 | item = cell.get(key, None) |
|
100 | 96 | if isinstance(item, basestring): |
@@ -74,10 +74,12 b' class TestCell(TestCase):' | |||
|
74 | 74 | tc = new_heading_cell() |
|
75 | 75 | self.assertEquals(tc.cell_type, u'heading') |
|
76 | 76 | self.assertEquals(u'source' not in tc, True) |
|
77 | self.assertEquals(u'rendered' not in tc, True) | |
|
77 | 78 | |
|
78 | 79 | def test_heading_cell(self): |
|
79 |
tc = new_heading_cell(u' |
|
|
80 |
self.assertEquals(tc.source, u' |
|
|
80 | tc = new_heading_cell(u'hi', u'hi', level=2) | |
|
81 | self.assertEquals(tc.source, u'hi') | |
|
82 | self.assertEquals(tc.rendered, u'hi') | |
|
81 | 83 | self.assertEquals(tc.level, 2) |
|
82 | 84 | |
|
83 | 85 |
General Comments 0
You need to be logged in to leave comments.
Login now