Jupyter notebook files have .ipynb extension. Notebook is rendered in web browser by the notebook app. It can be exported to various file formats by using download as an option in the file menu. Jupyter also has a command line interface in the form of nbconvert option. By default, nbconvert exports the notebook to HTML format. You can use the following command for tis purpose −
jupyter nbconvert mynotebook.ipynb
This will convert mynotebook.ipynb to the mynotebook.html. Other export format is specified with `--to` clause.
Note that other options include ['asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides']
HTML includes 'basic' and 'full' templates. You can specify that in the command line as shown below −
jupyter nbconvert --to html --template basic mynotebook.ipynb
LaTex is a document preparation format used specially in scientific typesetting. Jupyter includes 'base', 'article' and 'report' templates.
jupyter nbconvert --to latex –template report mynotebook.ipynb
To generate PDF via latex, use the following command −
jupyter nbconvert mynotebook.ipynb --to pdf
Notebook can be exported to HTML slideshow. The conversion uses Reveal.js in the background. To serve the slides by an HTTP server, add --postserve on the command-line. To make slides that does not require an internet connection, just place the Reveal.js library in the same directory where your_talk.slides.html is located.
jupyter nbconvert myslides.ipynb --to slides --post serve
The markdown option converts notebook to simple markdown output. Markdown cells are unaffected, and code cells indented 4 spaces.
--to markdown
You can use rst option to convert notebook to Basic reStructuredText output. It is useful as a starting point for embedding notebooks in Sphinx docs.
--to rst
This is the simplest way to get a Python (or other language, depending on the kernel) script out of a notebook.
--to script