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