Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
Module: nbconvert.preprocessors.base
¶
Base class for preprocessors
1 Class¶
-
class
IPython.nbconvert.preprocessors.base.
Preprocessor
(**kw)¶ Bases:
IPython.nbconvert.utils.base.NbConvertBase
A configurable preprocessor
Inherit from this class if you wish to have configurability for your preprocessor.
Any configurable traitlets this class exposed will be configurable in profiles using c.SubClassName.attribute = value
you can overwrite
preprocess_cell()
to apply a transformation independently on each cell orpreprocess()
if you prefer your own logic. See corresponding docstring for informations.- Disabled by default and can be enabled via the config by
- ‘c.YourPreprocessorName.enabled = True’
-
__init__
(**kw)¶ Public constructor
Parameters: config : Config
Configuration file structure
**kw : misc
Additional arguments
-
preprocess
(nb, resources)¶ Preprocessing to apply on each notebook.
Must return modified nb, resources.
If you wish to apply your preprocessing to each cell, you might want to override preprocess_cell method instead.
Parameters: nb : NotebookNode
Notebook being converted
resources : dictionary
Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.
-
preprocess_cell
(cell, resources, index)¶ Override if you want to apply some preprocessing to each cell. Must return modified cell and resource dictionary.
Parameters: cell : NotebookNode cell
Notebook cell being processed
resources : dictionary
Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.
index : int
Index of the cell being processed