##// END OF EJS Templates
Comment & Refactor, utils and nbconvert main.
Comment & Refactor, utils and nbconvert main.

File last commit:

r10626:2c777c5d
r10673:70e4dc3c
Show More
latex.py
43 lines | 1.5 KiB | text/x-python | PythonLexer
"""Latex transformer.
Module that allows latex output notebooks to be conditioned before
they are converted.
"""
#-----------------------------------------------------------------------------
# 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.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from __future__ import print_function, absolute_import
# Our own imports
# Needed to override transformer
from .activatable import (ActivatableTransformer)
from nbconvert.filters import latex
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
class LatexTransformer(ActivatableTransformer):
"""
Converter for latex destined documents.
"""
def cell_transform(self, cell, other, index):
"""
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.
"""
if hasattr(cell, "source") and cell.cell_type == "markdown":
cell.source = latex.rm_math_space(cell.source)
return cell, other