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.

  • path2url
  • strip_dollars
  • html2text
  • markdown2rst
  • strip_files_prefix
  • markdown2html
  • strip_ansi
  • add_prompts
  • ansi2latex
  • add_anchor
  • citation2latex
  • ascii_only
  • prevent_list_blocks
  • wrap_text
  • indent
  • highlight2latex
  • highlight2html
  • get_lines
  • markdown2latex
  • posix_path
  • ipython2python
  • filter_data_type
  • escape_latex
  • ansi2html
  • comment_lines
__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