1 """This preprocessor marks cell's metadata so that the appropriate
2 highlighter can be used in the `highlight` filter afterwards.
3 More precisely, the language of a cell is set to C++ in two scenarios:
4 - Python notebooks: cells with `%%cpp` or `%%dcl` magic extensions.
5 - ROOT prompt C++ notebooks: all cells.
6 This preprocessor relies on the metadata section of the notebook to
7 find out about the notebook's language.
10 from IPython.nbconvert.preprocessors.base
import Preprocessor
16 Detects and tags code cells that use the C++ language.
19 magics = [
'%%cpp',
'%%dcl' ]
24 super(CppHighlighter, self).
__init__(config=config, **kw)
28 any_magic =
"|".join(self.
magics)
32 m = reg_expr.match(source)
41 cell[
'metadata'][
'magics_language'] = self.
cpp
43 return cell, resources
47 if cell.cell_type ==
"code":
48 cell[
'metadata'][
'magics_language'] = self.
cpp
50 return cell, resources
55 if nb.metadata.kernelspec.language ==
"c++":
60 return super(CppHighlighter, self).
preprocess(nb, resources)
static std::string format(double x, double y, int digits, int width)
def __init__(self, config=None, kw)
def preprocess(self, nb, resources)
def _preprocess_cell_cpp(self, cell, resources, cell_index)
def matches(self, source, reg_expr)
def _preprocess_cell_python(self, cell, resources, cell_index)