See also

Configuration options
Configurable options for the nbconvert application
class nbconvert.nbconvertapp.NbConvertApp(**kwargs)

Application used to convert from notebook file type (*.ipynb)


Construct the list of notebooks.

If notebooks are passed on the command-line, they override (rather than add) notebooks specified in config files. Glob each notebook to replace notebook patterns with filenames.


Convert the notebooks in the self.notebook traitlet

convert_single_notebook(notebook_filename, input_buffer=None)

Convert a single notebook.

Performs the following steps:

  1. Initialize notebook resources
  2. Export the notebook to a particular format
  3. Write the exported notebook to file
  4. (Maybe) postprocess the written file
  • notebook_filename (str) –
  • input_buffer – If input_buffer is not None, conversion is done and the buffer is used as source into a file basenamed by the notebook_filename argument.

Step 1: Initialize resources

This initializes the resources dictionary for a single notebook.

resources dictionary for a single notebook that MUST include the following keys:
  • config_dir: the location of the Jupyter config directory
  • unique_key: the notebook name
  • output_files_dir: a directory where output files (not including the notebook itself) should be saved
Return type:dict
export_single_notebook(notebook_filename, resources, input_buffer=None)

Step 2: Export the notebook

Exports the notebook to a particular format according to the specified exporter. This function returns the output and (possibly modified) resources from the exporter.

  • notebook_filename (str) – name of notebook file.
  • resources (dict) –
  • input_buffer – readable file-like object returning unicode. if not None, notebook_filename is ignored

  • output
  • dict – resources (possibly modified)

write_single_notebook(output, resources)

Step 3: Write the notebook to file

This writes output from the exporter to file using the specified writer. It returns the results from the writer.

  • output
  • resources (dict) – resources for a single notebook including name, config directory and directory to save output

results from the specified writer output of exporter

Return type:



Step 4: Post-process the written file

Only used if a postprocessor has been specified. After the converted notebook is written to a file in Step 3, this post-processes the notebook.