Source code for pyquickhelper.helpgen._nbconvert_preprocessor

"""
Custom configuration for nbconvert,
see `custom_preprocessor <https://github.com/jupyter/nbconvert-examples/blob/master/custom_preprocessor/>`_


:githublink:`%|py|6`
"""
from nbconvert.preprocessors import Preprocessor


[docs]class LatexRawOutputPreprocessor(Preprocessor): """ Custom processor to apply a different style on raw output. :githublink:`%|py|12` """
[docs] def __init__(self, *args, **kwargs): """ Overloads the constructor. :githublink:`%|py|17` """ Preprocessor.__init__(self, *args, **kwargs)
[docs] def preprocess_cell(self, cell, resources, cell_index): # pylint: disable=W0221 """ Applies a transformation on each cell. See base.py for details, add ``\\begin{verbatim}`` and ``\\end{verbatim}``. :githublink:`%|py|24` """ 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