Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@file 

3@brief Custom configuration for nbconvert, 

4see `custom_preprocessor <https://github.com/jupyter/nbconvert-examples/blob/master/custom_preprocessor/>`_ 

5""" 

6from nbconvert.preprocessors import Preprocessor 

7 

8 

9class LatexRawOutputPreprocessor(Preprocessor): 

10 """ 

11 Custom processor to apply a different style on raw output. 

12 """ 

13 

14 def __init__(self, *args, **kwargs): 

15 """ 

16 Overloads the constructor. 

17 """ 

18 Preprocessor.__init__(self, *args, **kwargs) 

19 

20 def preprocess_cell(self, cell, resources, cell_index): # pylint: disable=W0221,W0237 

21 """ 

22 Applies a transformation on each cell. See base.py for details, 

23 add ``\\begin{verbatim}`` and ``\\end{verbatim}``. 

24 """ 

25 if cell.cell_type == 'raw': 

26 if isinstance(cell.source, list): 

27 cell.source = ["\\begin{verbatim}\n"] + \ 

28 cell.source + ["\\end{verbatim}\n"] 

29 else: 

30 cell.source = "\\begin{verbatim}\n%s\n\\end{verbatim}\n" % cell.source 

31 return cell, resources