Show More
@@ -1,5 +1,6 b'' | |||||
1 | from converters.markdown import ConverterMarkdown |
|
1 | from converters.markdown import ConverterMarkdown | |
2 | from IPython.utils.text import indent |
|
2 | from IPython.utils.text import indent, dedent | |
|
3 | from converters.utils import highlight, remove_ansi | |||
3 | import io |
|
4 | import io | |
4 | import os |
|
5 | import os | |
5 | import itertools |
|
6 | import itertools | |
@@ -79,6 +80,47 b' class ConverterReveal(ConverterMarkdown):' | |||||
79 | else: |
|
80 | else: | |
80 | return [self.meta2str(cell.metadata), cell.source, ''] |
|
81 | return [self.meta2str(cell.metadata), cell.source, ''] | |
81 |
|
82 | |||
|
83 | def render_pyout(self, output): | |||
|
84 | for fmt in ['html', 'latex', 'png', 'jpeg', 'svg', 'text']: | |||
|
85 | if fmt in output: | |||
|
86 | conv_fn = self.dispatch_display_format(fmt) | |||
|
87 | return conv_fn(output) | |||
|
88 | return [] | |||
|
89 | ||||
|
90 | def render_pyerr(self, output): | |||
|
91 | # Note: a traceback is a *list* of frames. | |||
|
92 | return [indent(remove_ansi('\n'.join(output.traceback))), ''] | |||
|
93 | ||||
|
94 | def _img_lines(self, img_file): | |||
|
95 | return ['![](%s)' % img_file, ''] | |||
|
96 | ||||
|
97 | def render_display_format_png(self, output): | |||
|
98 | return ['<img src="data:image/png;base64,%s"></img>' % output.png, ''] | |||
|
99 | ||||
|
100 | def render_display_format_svg(self, output): | |||
|
101 | return [output.svg, ''] | |||
|
102 | ||||
|
103 | def render_display_format_jpeg(self, output): | |||
|
104 | return ['<img src="data:image/jpeg;base64,%s"></img>' % output.jpeg, ''] | |||
|
105 | ||||
|
106 | def render_display_format_text(self, output): | |||
|
107 | return [indent(output.text), ''] | |||
|
108 | ||||
|
109 | def _unknown_lines(self, data): | |||
|
110 | return ['Warning: Unknown cell', data, ''] | |||
|
111 | ||||
|
112 | def render_display_format_html(self, output): | |||
|
113 | return [dedent(output.html), ''] | |||
|
114 | ||||
|
115 | def render_display_format_latex(self, output): | |||
|
116 | return ['LaTeX::', indent(output.latex), ''] | |||
|
117 | ||||
|
118 | def render_display_format_json(self, output): | |||
|
119 | return ['JSON:', indent(output.json), ''] | |||
|
120 | ||||
|
121 | def render_display_format_javascript(self, output): | |||
|
122 | return ['JavaScript:', indent(output.javascript), ''] | |||
|
123 | ||||
82 | def convert(self, cell_separator='\n'): |
|
124 | def convert(self, cell_separator='\n'): | |
83 | """ |
|
125 | """ | |
84 | Specific method to converts notebook to a string representation. |
|
126 | Specific method to converts notebook to a string representation. |
General Comments 0
You need to be logged in to leave comments.
Login now