Warning

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

Module: nbconvert.exporters.templateexporter

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

1 Class

class IPython.nbconvert.exporters.templateexporter.TemplateExporter(config=None, extra_loaders=None, **kw)

Bases: IPython.nbconvert.exporters.exporter.Exporter

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/preprocessors. If the filters/ preprocessors 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.

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

Public constructor

Parameters:

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_notebook_node(nb, resources=None, **kw)

Convert a notebook from a notebook node instance.

Parameters:

nb : NotebookNode

Notebook node

resources : dict

Additional resources that can be accessed read/write by preprocessors 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.

Parameters:

name : str

name to give the filter in the Jinja engine

filter : filter