Show More
@@ -1,32 +1,27 b'' | |||
|
1 | import os, copy | |
|
1 | """ | |
|
2 | This module gives a simple example of a custom notebook converter taht only | |
|
3 | captures display data and deletes the cell inputs. | |
|
4 | """ | |
|
2 | 5 | |
|
6 | import copy | |
|
3 | 7 | import nbconvert as nb |
|
4 | import json | |
|
5 | from decorators import DocInherit | |
|
6 | ||
|
7 | from IPython.external import argparse | |
|
8 | from IPython.nbformat import current as nbformat | |
|
9 | from IPython.nbformat.v3.nbjson import from_dict, rejoin_lines, BytesEncoder | |
|
10 | from IPython.utils.text import indent | |
|
11 | from IPython.utils import py3compat | |
|
12 | ||
|
13 | 8 | |
|
14 | 9 | class CustomNotebookConverter(nb.ConverterNotebook): |
|
15 | 10 | |
|
16 | 11 | def render_code(self, cell): |
|
17 | 12 | |
|
18 | 13 | captured_outputs = ['text', 'html', 'svg', 'latex', 'javascript'] |
|
19 | 14 | |
|
20 | 15 | cell = copy.deepcopy(cell) |
|
21 | 16 | cell['input'] = '' |
|
22 | 17 | |
|
23 | 18 | for output in cell.outputs: |
|
24 | 19 | if output.output_type != 'display_data': |
|
25 | 20 | cell.outputs.remove(output) |
|
26 | 21 | return nb.ConverterNotebook.render_code(self, cell) |
|
27 | 22 | |
|
28 | 23 | if __name__ == '__main__': |
|
29 | 24 | infile = 'tests/test_display.ipynb' |
|
30 | 25 | converter = CustomNotebookConverter(infile, 'test_only_display') |
|
31 | 26 | converter.render() |
|
32 | 27 |
General Comments 0
You need to be logged in to leave comments.
Login now