latex.py
42 lines
| 1.5 KiB
| text/x-python
|
PythonLexer
Jonathan Frederic
|
r10436 | """Latex transformer. | ||
Matthias BUSSONNIER
|
r9882 | Module that allows latex output notebooks to be conditioned before | ||
Jonathan Frederic
|
r9776 | they are converted. | ||
""" | ||||
Jonathan Frederic
|
r10436 | #----------------------------------------------------------------------------- | ||
# Copyright (c) 2013, the IPython Development Team. | ||||
# | ||||
# Distributed under the terms of the Modified BSD License. | ||||
# | ||||
# The full license is in the file COPYING.txt, distributed with this software. | ||||
#----------------------------------------------------------------------------- | ||||
Jonathan Frederic
|
r9776 | |||
Jonathan Frederic
|
r10436 | #----------------------------------------------------------------------------- | ||
# Imports | ||||
#----------------------------------------------------------------------------- | ||||
from __future__ import print_function, absolute_import | ||||
Jonathan Frederic
|
r9776 | |||
Jonathan Frederic
|
r10436 | # Our own imports | ||
Jonathan Frederic
|
r9776 | # Needed to override transformer | ||
Jonathan Frederic
|
r10436 | from .transformers import (ActivatableTransformer) #TODO | ||
Jonathan Frederic
|
r9776 | |||
Jonathan Frederic
|
r10436 | #----------------------------------------------------------------------------- | ||
# Classes | ||||
#----------------------------------------------------------------------------- | ||||
Jonathan Frederic
|
r9776 | class LatexTransformer(ActivatableTransformer): | ||
""" | ||||
Converter for latex destined documents. | ||||
Matthias BUSSONNIER
|
r9882 | """ | ||
Jonathan Frederic
|
r9779 | |||
def cell_transform(self, cell, other, index): | ||||
Jonathan Frederic
|
r9776 | """ | ||
Jonathan Frederic
|
r9779 | Apply a transformation on each cell, | ||
receive the current cell, the resource dict and the index of current cell as parameter. | ||||
Returns modified cell and resource dict. | ||||
Jonathan Frederic
|
r9776 | """ | ||
Jonathan Frederic
|
r10476 | |||
Jonathan Frederic
|
r9779 | if hasattr(cell, "source") and cell.cell_type == "markdown": | ||
Jonathan Frederic
|
r9953 | cell.source = rm_math_space(cell.source) | ||
Jonathan Frederic
|
r9779 | return cell, other | ||