Skip to content

Commit

Permalink
ENH: split main_body() from convert() in Converter base class
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Sep 25, 2012
1 parent 1e557eb commit cdadada
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nbconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ def dispatch_display_format(self, format):
def convert(self, cell_separator='\n'):
lines = []
lines.extend(self.optional_header())
lines.extend(self.main_body(cell_separator))
lines.extend(self.optional_footer())
return u'\n'.join(lines)

def main_body(self, cell_separator='\n'):
converted_cells = []
for worksheet in self.nb.worksheets:
for cell in worksheet.cells:
Expand All @@ -281,9 +286,7 @@ def convert(self, cell_separator='\n'):
remove_fake_files_url(cell)
converted_cells.append('\n'.join(conv_fn(cell)))
cell_lines = cell_separator.join(converted_cells).split('\n')
lines.extend(cell_lines)
lines.extend(self.optional_footer())
return u'\n'.join(lines)
return cell_lines

def render(self):
"read, convert, and save self.infile"
Expand Down

0 comments on commit cdadada

Please sign in to comment.