##// END OF EJS Templates
Starting to rename text cell to html cell.
Brian E. Granger -
Show More
1 NO CONTENT: file renamed from IPython/frontend/html/notebook/static/js/textcell.js to IPython/frontend/html/notebook/static/js/htmlcell.js
@@ -7,7 +7,7 from IPython.nbformat import v1
7 7
8 8 from IPython.nbformat.v2 import (
9 9 NotebookNode,
10 new_code_cell, new_text_cell, new_notebook, new_output, new_worksheet
10 new_code_cell, new_html_cell, new_notebook, new_output, new_worksheet
11 11 )
12 12
13 13
@@ -1,7 +1,7
1 1
2 2 from .nbbase import (
3 3 NotebookNode,
4 new_code_cell, new_text_cell, new_notebook, new_output, new_worksheet
4 new_code_cell, new_html_cell, new_notebook, new_output, new_worksheet
5 5 )
6 6
7 7 from .nbjson import reads as reads_json, writes as writes_json
@@ -1,5 +1,5
1 1 from .nbbase import (
2 new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output
2 new_code_cell, new_html_cell, new_worksheet, new_notebook, new_output
3 3 )
4 4
5 5 def convert_to_this_nbformat(nb, orig_version=1):
@@ -10,7 +10,7 def convert_to_this_nbformat(nb, orig_version=1):
10 10 if cell.cell_type == 'code':
11 11 newcell = new_code_cell(input=cell.get('code'),prompt_number=cell.get('prompt_number'))
12 12 elif cell.cell_type == 'text':
13 newcell = new_text_cell(text=cell.get('text'))
13 newcell = new_html_cell(source=cell.get('text'))
14 14 ws.cells.append(newcell)
15 15 newnb.worksheets.append(ws)
16 16 return newnb
@@ -65,12 +65,12 def new_code_cell(input=None, prompt_number=None, outputs=None, language=u'pytho
65 65
66 66 return cell
67 67
68 def new_text_cell(text=None):
68 def new_html_cell(source=None):
69 69 """Create a new text cell."""
70 70 cell = NotebookNode()
71 if text is not None:
72 cell.text = unicode(text)
73 cell.cell_type = u'text'
71 if source is not None:
72 cell.source = unicode(source)
73 cell.cell_type = u'html'
74 74 return cell
75 75
76 76
@@ -5,7 +5,7 from xml.etree import ElementTree as ET
5 5
6 6 from .rwbase import NotebookReader, NotebookWriter
7 7 from .nbbase import (
8 new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output
8 new_code_cell, new_html_cell, new_worksheet, new_notebook, new_output
9 9 )
10 10
11 11 def indent(elem, level=0):
@@ -87,7 +87,7 class XMLReader(NotebookReader):
87 87 language = _get_text(cell_e,'language')
88 88 outputs = []
89 89 for output_e in cell_e.find('outputs').getiterator('output'):
90 prompt_number = _get_int(output_e,'prompt_number')
90 out_prompt_number = _get_int(output_e,'prompt_number')
91 91 output_type = _get_text(output_e,'output_type')
92 92 output_text = _get_text(output_e,'text')
93 93 output_png = _get_binary(output_e,'png')
@@ -100,15 +100,15 class XMLReader(NotebookReader):
100 100 output_text=output_text,output_svg=output_svg,
101 101 output_html=output_html,output_latex=output_latex,
102 102 output_json=output_json,output_javascript=output_javascript,
103 prompt_number=prompt_number
103 prompt_number=out_prompt_number
104 104 )
105 105 outputs.append(output)
106 106 cc = new_code_cell(input=input,prompt_number=prompt_number,
107 107 language=language,outputs=outputs)
108 108 cells.append(cc)
109 if cell_e.tag == 'textcell':
110 text = _get_text(cell_e,'text')
111 cells.append(new_text_cell(text=text))
109 if cell_e.tag == 'htmlcell':
110 source = _get_text(cell_e,'source')
111 cells.append(new_html_cell(source=source))
112 112 ws = new_worksheet(name=wsname,cells=cells)
113 113 worksheets.append(ws)
114 114
@@ -138,7 +138,7 class XMLWriter(NotebookWriter):
138 138 outputs_e = ET.SubElement(cell_e, 'outputs')
139 139 for output in cell.outputs:
140 140 output_e = ET.SubElement(outputs_e, 'output')
141 _set_int(cell,'prompt_number',output_e,'prompt_number')
141 _set_int(output,'prompt_number',output_e,'prompt_number')
142 142 _set_text(output,'output_type',output_e,'output_type')
143 143 _set_text(output,'text',output_e,'text')
144 144 _set_binary(output,'png',output_e,'png')
@@ -147,9 +147,9 class XMLWriter(NotebookWriter):
147 147 _set_text(output,'latex',output_e,'latex')
148 148 _set_text(output,'json',output_e,'json')
149 149 _set_text(output,'javascript',output_e,'javascript')
150 elif cell_type == 'text':
151 cell_e = ET.SubElement(cells_e, 'textcell')
152 _set_text(cell,'text',cell_e,'text')
150 elif cell_type == 'html':
151 cell_e = ET.SubElement(cells_e, 'htmlcell')
152 _set_text(cell,'source',cell_e,'source')
153 153
154 154 indent(nb_e)
155 155 txt = ET.tostring(nb_e, encoding="utf-8")
@@ -1,14 +1,14
1 1 from ..nbbase import (
2 2 NotebookNode,
3 new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output
3 new_code_cell, new_html_cell, new_worksheet, new_notebook, new_output
4 4 )
5 5
6 6
7 7
8 8 ws = new_worksheet(name='worksheet1')
9 9
10 ws.cells.append(new_text_cell(
11 text='Some NumPy Examples'
10 ws.cells.append(new_html_cell(
11 source='Some NumPy Examples'
12 12 ))
13 13
14 14
@@ -33,7 +33,8 ws.cells.append(new_code_cell(
33 33 output_png=b'data',
34 34 output_svg=u'<svg>',
35 35 output_json=u'json data',
36 output_javascript=u'var i=0;'
36 output_javascript=u'var i=0;',
37 prompt_number=3
37 38 ),new_output(
38 39 output_type=u'display_data',
39 40 output_text=u'<array a>',
@@ -42,7 +43,8 ws.cells.append(new_code_cell(
42 43 output_png=b'data',
43 44 output_svg=u'<svg>',
44 45 output_json=u'json data',
45 output_javascript=u'var i=0;'
46 output_javascript=u'var i=0;',
47 prompt_number=4
46 48 )]
47 49 ))
48 50
@@ -2,7 +2,7 from unittest import TestCase
2 2
3 3 from ..nbbase import (
4 4 NotebookNode,
5 new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output
5 new_code_cell, new_html_cell, new_worksheet, new_notebook, new_output
6 6 )
7 7
8 8 class TestCell(TestCase):
@@ -16,21 +16,23 class TestCell(TestCase):
16 16
17 17 def test_code_cell(self):
18 18 cc = new_code_cell(input='a=10', prompt_number=0)
19 cc.outputs = [new_output(output_type='pyout',output_svg='foo',output_text='10')]
19 cc.outputs = [new_output(output_type='pyout',
20 output_svg='foo',output_text='10',prompt_number=0)]
20 21 self.assertEquals(cc.input, u'a=10')
21 22 self.assertEquals(cc.prompt_number, 0)
22 23 self.assertEquals(cc.language, u'python')
23 24 self.assertEquals(cc.outputs[0].svg, u'foo')
24 25 self.assertEquals(cc.outputs[0].text, u'10')
26 self.assertEquals(cc.outputs[0].prompt_number, 0)
25 27
26 def test_empty_text_cell(self):
27 tc = new_text_cell()
28 self.assertEquals(tc.cell_type, 'text')
29 self.assertEquals('text' not in tc, True)
28 def test_empty_html_cell(self):
29 tc = new_html_cell()
30 self.assertEquals(tc.cell_type, 'html')
31 self.assertEquals('source' not in tc, True)
30 32
31 def test_text_cell(self):
32 tc = new_text_cell('hi')
33 self.assertEquals(tc.text, u'hi')
33 def test_html_cell(self):
34 tc = new_html_cell('hi')
35 self.assertEquals(tc.source, u'hi')
34 36
35 37
36 38 class TestWorksheet(TestCase):
@@ -41,7 +43,7 class TestWorksheet(TestCase):
41 43 self.assertEquals('name' not in ws, True)
42 44
43 45 def test_worksheet(self):
44 cells = [new_code_cell(), new_text_cell()]
46 cells = [new_code_cell(), new_html_cell()]
45 47 ws = new_worksheet(cells=cells,name='foo')
46 48 self.assertEquals(ws.cells,cells)
47 49 self.assertEquals(ws.name,u'foo')
@@ -2,7 +2,7 from unittest import TestCase
2 2
3 3 from ..nbbase import (
4 4 NotebookNode,
5 new_code_cell, new_text_cell, new_worksheet, new_notebook
5 new_code_cell, new_html_cell, new_worksheet, new_notebook
6 6 )
7 7
8 8 from ..nbpy import reads, writes
General Comments 0
You need to be logged in to leave comments. Login now