From 5458ed36d08b0582995452a88a39c0470826eed5 2012-01-30 19:50:04 From: Brian Granger Date: 2012-01-30 19:50:04 Subject: [PATCH] Changing rst->plaintext in nbformat. --- diff --git a/IPython/nbformat/current.py b/IPython/nbformat/current.py index 37f2ba1..7796fdf 100644 --- a/IPython/nbformat/current.py +++ b/IPython/nbformat/current.py @@ -21,10 +21,11 @@ import json from xml.etree import ElementTree as ET import re +from IPython.nbformat import v3 from IPython.nbformat import v2 from IPython.nbformat import v1 -from IPython.nbformat.v2 import ( +from IPython.nbformat.v3 import ( NotebookNode, new_code_cell, new_text_cell, new_notebook, new_output, new_worksheet, parse_filename, new_metadata, new_author diff --git a/IPython/nbformat/v3/nbpy.py b/IPython/nbformat/v3/nbpy.py index 2493fcd..ec7daf1 100644 --- a/IPython/nbformat/v3/nbpy.py +++ b/IPython/nbformat/v3/nbpy.py @@ -68,11 +68,11 @@ class PyReader(NotebookReader): state = u'markdowncell' cell_lines = [] kwargs = {} - elif line.startswith(u'# '): + elif line.startswith(u'# '): cell = self.new_cell(state, cell_lines, **kwargs) if cell is not None: cells.append(cell) - state = u'rstcell' + state = u'plaintextcell' cell_lines = [] kwargs = {} elif line.startswith(u'# ',u'']) lines.extend([u'# ' + line for line in input.splitlines()]) lines.append(u'') - elif cell.cell_type == u'rst': + elif cell.cell_type == u'plaintext': input = cell.get(u'source') if input is not None: - lines.extend([u'# ',u'']) + lines.extend([u'# ',u'']) lines.extend([u'# ' + line for line in input.splitlines()]) lines.append(u'') elif cell.cell_type == u'heading': diff --git a/IPython/nbformat/v3/tests/nbexamples.py b/IPython/nbformat/v3/tests/nbexamples.py index af6a251..6482fa7 100644 --- a/IPython/nbformat/v3/tests/nbexamples.py +++ b/IPython/nbformat/v3/tests/nbexamples.py @@ -33,7 +33,7 @@ ws.cells.append(new_text_cell( )) ws.cells.append(new_text_cell( - u'rst', + u'plaintext', source='A random array', )) @@ -106,7 +106,7 @@ import numpy # A random array -# +# # A random array diff --git a/IPython/nbformat/v3/tests/test_nbbase.py b/IPython/nbformat/v3/tests/test_nbbase.py index d973c79..3dc4cda 100644 --- a/IPython/nbformat/v3/tests/test_nbbase.py +++ b/IPython/nbformat/v3/tests/test_nbbase.py @@ -59,14 +59,14 @@ class TestCell(TestCase): self.assertEquals(tc.source, u'hi') self.assertEquals(tc.rendered, u'hi') - def test_empty_rst_cell(self): - tc = new_text_cell(u'rst') - self.assertEquals(tc.cell_type, u'rst') + def test_empty_plaintext_cell(self): + tc = new_text_cell(u'plaintext') + self.assertEquals(tc.cell_type, u'plaintext') self.assertEquals(u'source' not in tc, True) self.assertEquals(u'rendered' not in tc, True) - def test_rst_cell(self): - tc = new_text_cell(u'rst', 'hi', 'hi') + def test_plaintext_cell(self): + tc = new_text_cell(u'plaintext', 'hi', 'hi') self.assertEquals(tc.source, u'hi') self.assertEquals(tc.rendered, u'hi')