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

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

""" 

@file 

@brief Custom configuration for nbconvert, 

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

""" 

from nbconvert.preprocessors import Preprocessor 

 

 

class LatexRawOutputPreprocessor(Preprocessor): 

""" 

Custom processor to apply a different style on raw output. 

""" 

 

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

""" 

Overloads the constructor. 

""" 

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

 

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

""" 

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

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

""" 

if cell.cell_type == 'raw': 

if isinstance(cell.source, list): 

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

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

else: 

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

return cell, resources