|
816 | 816 | "outputs": [], |
817 | 817 | "source": [ |
818 | 818 | "#| export\n", |
819 | | - "def render_outputs(outputs, ansi_renderer=strip_ansi):\n", |
| 819 | + "def render_outputs(outputs, ansi_renderer=strip_ansi, include_imgs=True):\n", |
820 | 820 | " try: import mistletoe\n", |
821 | 821 | " except ImportError: return print('mistletoe not found -- please install it')\n", |
822 | 822 | " def render_output(out):\n", |
|
830 | 830 | " if d := _g('text/html'): return d\n", |
831 | 831 | " if d := _g('application/javascript'): return f'<script>{d}</script>'\n", |
832 | 832 | " if d := _g('text/markdown'): return mistletoe.markdown(d)\n", |
833 | | - " if d := _g('image/svg+xml'): return d\n", |
834 | | - " if d := _g('image/jpeg'): return f'<img src=\"data:image/jpeg;base64,{d}\"/>'\n", |
835 | | - " if d := _g('image/png'): return f'<img src=\"data:image/png;base64,{d}\"/>'\n", |
836 | 833 | " if d := _g('text/latex'): return f'<div class=\"math\">${d}$</div>'\n", |
837 | 834 | " if d := _g('text/plain'): return f\"<pre>{escape(d)}</pre>\"\n", |
| 835 | + " if d := _g('image/svg+xml'): return d\n", |
| 836 | + " if include_imgs:\n", |
| 837 | + " if d := _g('image/jpeg'): return f'<img src=\"data:image/jpeg;base64,{d}\"/>'\n", |
| 838 | + " if d := _g('image/png'): return f'<img src=\"data:image/png;base64,{d}\"/>'\n", |
838 | 839 | " return ''\n", |
839 | 840 | " \n", |
840 | 841 | " return '\\n'.join(map(render_output, outputs))" |
|
0 commit comments