IPython Documentation

Table Of Contents

Previous topic

Module: nbconvert.preprocessors.extractoutput

Next topic

Module: nbconvert.preprocessors.latex

This Page

Module: nbconvert.preprocessors.highlightmagics

This preprocessor detect cells using a different language through magic extensions such as %%R or %%octave. Cell’s metadata is marked so that the appropriate highlighter can be used in the highlight filter.

1 Class

class IPython.nbconvert.preprocessors.highlightmagics.HighlightMagicsPreprocessor(config=None, **kw)

Bases: IPython.nbconvert.preprocessors.base.Preprocessor

Detects and tags code cells that use a different languages than Python.

__init__(config=None, **kw)

Public constructor

preprocess_cell(cell, resources, cell_index)

Tags cells using a magic extension language


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.

cell_index : int

Index of the cell being processed (see base.py)


When a cell uses another language through a magic extension, the other language is returned. If no language magic is detected, this function returns None.


source: str :

Source code of the cell to highlight