##// END OF EJS Templates
Improve conversion to latex of output cells...
Improve conversion to latex of output cells Improve the latex convert possibilites of pyout and display_data cells. Detailed changes: - set display_data_priority for latex output to start with 'latex' - use numbered equations - define relative figure size instead of absolute - specify image file position relative to input file position - pyout.text is only rendered if latex representation is not available - place display_data_format_latex output in equation environment - some minor code clean-up

File last commit:

r8749:712b994d
r8804:70796c14
Show More
custom_converter.py
27 lines | 752 B | text/x-python | PythonLexer
/ custom_converter.py
"""
This module gives a simple example of a custom notebook converter that only
captures display data and deletes the cell inputs.
"""
import copy
import nbconvert as nb
class CustomNotebookConverter(nb.ConverterNotebook):
def render_code(self, cell):
captured_outputs = ['text', 'html', 'svg', 'latex', 'javascript']
cell = copy.deepcopy(cell)
cell['input'] = ''
for output in cell.outputs:
if output.output_type != 'display_data':
cell.outputs.remove(output)
return nb.ConverterNotebook.render_code(self, cell)
if __name__ == '__main__':
infile = 'tests/test_display.ipynb'
converter = CustomNotebookConverter(infile, 'test_only_display')
converter.render()