IPython Documentation

Table Of Contents

Previous topic

Module: nbconvert.exporters.export

Next topic

Module: nbconvert.exporters.html

This Page


This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: nbconvert.exporters.exporter

This module defines Exporter, a highly configurable converter that uses Jinja2 to export notebook files into different formats.

2 Classes

class IPython.nbconvert.exporters.exporter.ResourcesDict

Bases: collections.defaultdict

class IPython.nbconvert.exporters.exporter.Exporter(config=None, extra_loaders=None, **kw)

Bases: IPython.config.configurable.LoggingConfigurable

Exports notebooks into other file formats. Uses Jinja 2 templating engine to output new formats. Inherit from this class if you are creating a new template type along with new filters/transformers. If the filters/ transformers provided by default suffice, there is no need to inherit from this class. Instead, override the template_file and file_extension traits via a config file.

  • highlight2html
  • filter_data_type
  • markdown2html
  • markdown2rst
  • get_lines
  • ansi2latex
  • strip_ansi
  • comment_lines
  • markdown2latex
  • escape_latex
  • add_anchor
  • ipython2python
  • posix_path
  • highlight2latex
  • path2url
  • ansi2html
  • wrap_text
  • strip_math_space
  • indent
  • strip_dollars
  • html2text
  • strip_files_prefix
__init__(config=None, extra_loaders=None, **kw)

Public constructor


config : config

User configuration instance.

extra_loaders : list[of Jinja Loaders]

ordered list of Jinja loader to find templates. Will be tried in order before the default FileSystem ones.

template : str (optional, kw arg)

Template to use when exporting.

from_file(file_stream, resources=None, **kw)

Convert a notebook from a notebook file.


file_stream : file-like object

Notebook file-like object to convert.

from_filename(filename, resources=None, **kw)

Convert a notebook from a notebook file.


filename : str

Full filename of the notebook file to open and convert.

from_notebook_node(nb, resources=None, **kw)

Convert a notebook from a notebook node instance.


nb : Notebook node

resources : dict (**kw)

of additional resources that can be accessed read/write by transformers and filters.

register_filter(name, jinja_filter)

Register a filter. A filter is a function that accepts and acts on one string. The filters are accesible within the Jinja templating engine.


name : str

name to give the filter in the Jinja engine

filter : filter

register_transformer(transformer, enabled=False)

Register a transformer. Transformers are classes that act upon the notebook before it is passed into the Jinja templating engine. Transformers are also capable of passing additional information to the Jinja templating engine.

Parameters:transformer : transformer