diff --git a/IPython/nbconvert/transformers/__init__.py b/IPython/nbconvert/transformers/__init__.py index 0573abb..375b125 100755 --- a/IPython/nbconvert/transformers/__init__.py +++ b/IPython/nbconvert/transformers/__init__.py @@ -1,5 +1,4 @@ # Class base Transformers -from .activatable import ActivatableTransformer from .base import ConfigurableTransformer from .convertfigures import ConvertFiguresTransformer from .svg2pdf import Svg2PdfTransformer diff --git a/IPython/nbconvert/transformers/base.py b/IPython/nbconvert/transformers/base.py index e288e7e..c5a9bd7 100755 --- a/IPython/nbconvert/transformers/base.py +++ b/IPython/nbconvert/transformers/base.py @@ -17,6 +17,7 @@ It exposes a convenient class to inherit from to access configurability. #----------------------------------------------------------------------------- from ..utils.config import GlobalConfigurable +from IPython.utils.traitlets import Bool #----------------------------------------------------------------------------- # Classes and Functions @@ -33,6 +34,9 @@ class ConfigurableTransformer(GlobalConfigurable): you can overwrite transform_cell to apply a transformation independently on each cell or __call__ if you prefer your own logic. See corresponding docstring for informations. + + Disabled by default and can be enabled via the config by + 'c.YourTransformerName.enabled = True' """ enabled = Bool(False, config=True) @@ -53,7 +57,11 @@ class ConfigurableTransformer(GlobalConfigurable): def __call__(self, nb, resources): - return self.call(nb,resources) + if self.enabled: + return self.call(nb,resources) + else: + return nb, resources + def call(self, nb, resources): """ diff --git a/IPython/nbconvert/transformers/convertfigures.py b/IPython/nbconvert/transformers/convertfigures.py index 2af3aa8..6bfe239 100644 --- a/IPython/nbconvert/transformers/convertfigures.py +++ b/IPython/nbconvert/transformers/convertfigures.py @@ -15,13 +15,13 @@ one format to another. # Imports #----------------------------------------------------------------------------- -from .activatable import ActivatableTransformer +from .base import ConfigurableTransformer #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class ConvertFiguresTransformer(ActivatableTransformer): +class ConvertFiguresTransformer(ConfigurableTransformer): """ Converts all of the outputs in a notebook from one format to another. """ diff --git a/IPython/nbconvert/transformers/csshtmlheader.py b/IPython/nbconvert/transformers/csshtmlheader.py index afa6796..5c65559 100755 --- a/IPython/nbconvert/transformers/csshtmlheader.py +++ b/IPython/nbconvert/transformers/csshtmlheader.py @@ -16,18 +16,18 @@ import os import io from pygments.formatters import HtmlFormatter - + from IPython.utils import path -from .activatable import ActivatableTransformer +from .base import ConfigurableTransformer from IPython.utils.traitlets import Unicode - + #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- -class CSSHTMLHeaderTransformer(ActivatableTransformer): +class CSSHTMLHeaderTransformer(ConfigurableTransformer): """ Transformer used to pre-process notebook for HTML output. Adds IPython notebook front-end CSS and Pygments CSS to HTML output. diff --git a/IPython/nbconvert/transformers/extractfigure.py b/IPython/nbconvert/transformers/extractfigure.py index bafd79d..5ee5597 100755 --- a/IPython/nbconvert/transformers/extractfigure.py +++ b/IPython/nbconvert/transformers/extractfigure.py @@ -15,13 +15,13 @@ notebook file. The extracted figures are returned in the 'resources' dictionary import sys from IPython.utils.traitlets import Dict, Unicode -from .activatable import ActivatableTransformer +from .base import ConfigurableTransformer #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class ExtractFigureTransformer(ActivatableTransformer): +class ExtractFigureTransformer(ConfigurableTransformer): """ Extracts all of the figures from the notebook file. The extracted figures are returned in the 'resources' dictionary. diff --git a/IPython/nbconvert/transformers/latex.py b/IPython/nbconvert/transformers/latex.py index 5718b57..22cc203 100755 --- a/IPython/nbconvert/transformers/latex.py +++ b/IPython/nbconvert/transformers/latex.py @@ -17,14 +17,14 @@ from __future__ import print_function, absolute_import # Our own imports # Needed to override transformer -from .activatable import (ActivatableTransformer) +from .base import (ConfigurableTransformer) from IPython.nbconvert import filters #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class LatexTransformer(ActivatableTransformer): +class LatexTransformer(ConfigurableTransformer): """ Converter for latex destined documents. """ diff --git a/IPython/nbconvert/transformers/sphinx.py b/IPython/nbconvert/transformers/sphinx.py index 6f18cd0..935ec12 100755 --- a/IPython/nbconvert/transformers/sphinx.py +++ b/IPython/nbconvert/transformers/sphinx.py @@ -33,7 +33,7 @@ from pygments.formatters import LatexFormatter from IPython.utils.traitlets import Unicode, Bool # Needed to override transformer -from .activatable import (ActivatableTransformer) #TODO +from .base import (ConfigurableTransformer) from IPython.nbconvert.utils import console @@ -41,7 +41,7 @@ from IPython.nbconvert.utils import console # Classes and functions #----------------------------------------------------------------------------- -class SphinxTransformer(ActivatableTransformer): +class SphinxTransformer(ConfigurableTransformer): """ Sphinx utility transformer.