# sphinx_gallery.notebook

## Parser for Jupyter notebooks

Class that holds the Jupyter notebook information

### Functions

`sphinx_gallery.notebook.``add_code_cell`(work_notebook, code)

  Add a code cell to the notebook

  Parameters

    code (str) – Cell content

#### Examples using `sphinx_gallery.notebook.add_code_cell`

`sphinx_gallery.notebook.``add_markdown_cell`(work_notebook, markdown)

  Add a markdown cell to the notebook

  Parameters

    markdown (str) – Markdown cell content.

#### Examples using `sphinx_gallery.notebook.add_markdown_cell`

`sphinx_gallery.notebook.``directive_fun`(match, directive)

  Helper to fill in directives

#### Examples using `sphinx_gallery.notebook.directive_fun`

`sphinx_gallery.notebook.``fill_notebook`(work_notebook, script_blocks, gallery_conf, target_dir)

  Writes the Jupyter notebook cells

  If available, uses pypandoc to convert rst to markdown.

  Parameters

    script_blocks (list) – Each list element should be a tuple of (label, content, lineno).

#### Examples using `sphinx_gallery.notebook.fill_notebook`

`sphinx_gallery.notebook.``generate_image_src`(image_path, gallery_conf, target_dir)

#### Examples using `sphinx_gallery.notebook.generate_image_src`

`sphinx_gallery.notebook.``jupyter_notebook`(script_blocks, gallery_conf, target_dir)

  Generate a Jupyter notebook file cell-by-cell

  Parameters

    - script_blocks (list) – Script execution cells.

    - gallery_conf (dict) – The sphinx-gallery configuration dictionary.

    - target_dir (str) – Path that notebook is intended for. Used where relative paths may be required.

#### Examples using `sphinx_gallery.notebook.jupyter_notebook`

`sphinx_gallery.notebook.``jupyter_notebook_skeleton`()

  Returns a dictionary with the elements of a Jupyter notebook

#### Examples using `sphinx_gallery.notebook.jupyter_notebook_skeleton`

`sphinx_gallery.notebook.``python_to_jupyter_cli`(args=None, namespace=None)

  Exposes the jupyter notebook renderer to the command line

  Takes the same arguments as ArgumentParser.parse_args

#### Examples using `sphinx_gallery.notebook.python_to_jupyter_cli`

`sphinx_gallery.notebook.``rst2md`(text, gallery_conf, target_dir, heading_levels)

  Converts the RST text from the examples docstrings and comments into markdown text for the Jupyter notebooks

  Parameters

    - text (str) – RST input to be converted to MD

    - gallery_conf (dict) – The sphinx-gallery configuration dictionary.

    - target_dir (str) – Path that notebook is intended for. Used where relative paths may be required.

    - heading_levels (dict) – Mapping of heading style `(over_char, under_char)` to heading level. Note that `over_char` is None when only underline is present.

#### Examples using `sphinx_gallery.notebook.rst2md`

`sphinx_gallery.notebook.``save_notebook`(work_notebook, write_file)

  Saves the Jupyter work_notebook to write_file

#### Examples using `sphinx_gallery.notebook.save_notebook`