From 676b208923c3098255a857074efd6e2d87459c2a 2012-12-15 04:05:23 From: damianavila Date: 2012-12-15 04:05:23 Subject: [PATCH] Implemented loading of pyerr, images and videos outside the markdown cell --- diff --git a/converters/reveal.py b/converters/reveal.py index 3f562ce..3e98b1a 100644 --- a/converters/reveal.py +++ b/converters/reveal.py @@ -1,5 +1,6 @@ from converters.markdown import ConverterMarkdown -from IPython.utils.text import indent +from IPython.utils.text import indent, dedent +from converters.utils import highlight, remove_ansi import io import os import itertools @@ -79,6 +80,47 @@ class ConverterReveal(ConverterMarkdown): else: return [self.meta2str(cell.metadata), cell.source, ''] + def render_pyout(self, output): + for fmt in ['html', 'latex', 'png', 'jpeg', 'svg', 'text']: + if fmt in output: + conv_fn = self.dispatch_display_format(fmt) + return conv_fn(output) + return [] + + def render_pyerr(self, output): + # Note: a traceback is a *list* of frames. + return [indent(remove_ansi('\n'.join(output.traceback))), ''] + + def _img_lines(self, img_file): + return ['![](%s)' % img_file, ''] + + def render_display_format_png(self, output): + return ['' % output.png, ''] + + def render_display_format_svg(self, output): + return [output.svg, ''] + + def render_display_format_jpeg(self, output): + return ['' % output.jpeg, ''] + + def render_display_format_text(self, output): + return [indent(output.text), ''] + + def _unknown_lines(self, data): + return ['Warning: Unknown cell', data, ''] + + def render_display_format_html(self, output): + return [dedent(output.html), ''] + + def render_display_format_latex(self, output): + return ['LaTeX::', indent(output.latex), ''] + + def render_display_format_json(self, output): + return ['JSON:', indent(output.json), ''] + + def render_display_format_javascript(self, output): + return ['JavaScript:', indent(output.javascript), ''] + def convert(self, cell_separator='\n'): """ Specific method to converts notebook to a string representation.