from converters.markdown import ConverterMarkdown import io import os class ConverterReveal(ConverterMarkdown): """Convert a notebook to a html slideshow. It generates a static html slideshow based in markdown and reveal.js. """ def __init__(self, infile, highlight_source=False, show_prompts=True, inline_prompt=True): super(ConverterMarkdown, self).__init__(infile) self.highlight_source = highlight_source self.show_prompts = show_prompts self.inline_prompt = inline_prompt def convert(self, cell_separator='\n'): """ Generic method to converts notebook to a string representation. This is accomplished by dispatching on the cell_type, so subclasses of Convereter class do not need to re-implement this method, but just need implementation for the methods that will be dispatched. Parameters ---------- cell_separator : string Character or string to join cells with. Default is "\n" Returns ------- out : string """ lines = [] lines.extend(self.optional_header()) top = '
' text = self.main_body(cell_separator) for i,j in enumerate(text): if j == u'---': text[i] = bottom + top lines.extend(text) lines.extend(self.optional_footer()) return u'\n'.join(lines) def save(self, outfile=None, encoding=None): "read and parse notebook into self.nb" if outfile is None: outfile = self.outbase + '_slides.' + 'html' if encoding is None: encoding = self.default_encoding with io.open(outfile, 'w', encoding=encoding) as f: f.write(self.output) return os.path.abspath(outfile) def optional_header(self): optional_header_body = [\ '''
'''] return optional_footer_body