##// END OF EJS Templates
@jasongrout 's changes on the wiki.
@jasongrout 's changes on the wiki.

File last commit:

r20544:b98d516b merge
r20545:018cc477
Show More
nbconvert.rst
165 lines | 5.2 KiB | text/x-rst | RstLexer
MinRK
rename nbconvert doc to nbconvert.rst
r11835 .. _nbconvert:
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
Converting notebooks to other formats
=====================================
Newly added in the 1.0 release of IPython is the ``nbconvert`` tool, which
allows you to convert an ``.ipynb`` notebook document file into various static
formats.
Currently, ``nbconvert`` is provided as a command line tool, run as a script
MinRK
update nbconvert doc...
r11824 using IPython. A direct export capability from within the
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792 IPython Notebook web app is planned.
The command-line syntax to run the ``nbconvert`` script is::
MinRK
update nbconvert doc...
r11824 $ ipython nbconvert --to FORMAT notebook.ipynb
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
This will convert the IPython document file ``notebook.ipynb`` into the output
format given by the ``FORMAT`` string.
MinRK
update nbconvert doc...
r11824 The default output format is html, for which the ``--to`` argument may be
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792 omitted::
$ ipython nbconvert notebook.ipynb
MinRK
update nbconvert doc...
r11824 IPython provides a few templates for some output formats, and these can be
specified via an additional ``--template`` argument.
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 The currently supported export formats are:
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 * ``--to html``
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 - ``--template full`` (default)
MinRK
add some detail in rst and markdown output
r11837
MinRK
update nbconvert doc...
r11824 A full static HTML render of the notebook.
This looks very similar to the interactive view.
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 - ``--template basic``
MinRK
add some detail in rst and markdown output
r11837
MinRK
update nbconvert doc...
r11824 Simplified HTML, useful for embedding in webpages, blogs, etc.
This excludes HTML headers.
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 * ``--to latex``
MinRK
add some detail in rst and markdown output
r11837
MinRK
update nbconvert doc...
r11824 Latex export. This generates ``NOTEBOOK_NAME.tex`` file,
ready for export. You can automatically run latex on it to generate a PDF
by adding ``--post PDF``.
- ``--template article`` (default)
MinRK
add some detail in rst and markdown output
r11837
MinRK
update nbconvert doc...
r11824 Latex article, derived from Sphinx's howto template.
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 - ``--template book``
MinRK
add some detail in rst and markdown output
r11837
MinRK
update nbconvert doc...
r11824 Latex book, derived from Sphinx's manual template.
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 - ``--template basic``
MinRK
add some detail in rst and markdown output
r11837
MinRK
update nbconvert doc...
r11824 Very basic latex output - mainly meant as a starting point for custom templates.
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 * ``--to slides``
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 This generates a Reveal.js HTML slideshow.
damianavila
Deleted jargon-ish reference to no-connectity.
r14007 It must be served by an HTTP server. The easiest way to do this is adding
``--post serve`` on the command-line. The ``serve`` post-processor proxies
Reveal.js requests to a CDN if no local Reveal.js library is present.
To make slides that don't require an internet connection, just place the
Reveal.js library in the same directory where your_talk.slides.html is located,
or point to another directory using the ``--reveal-prefix`` alias.
MinRK
update reveal docs with recent changes
r12514
MinRK
add some detail in rst and markdown output
r11837 * ``--to markdown``
Simple markdown output. Markdown cells are unaffected,
Paul Ivanov
fix docs, closes #5345
r15878 and code cells indented 4 spaces.
MinRK
add some detail in rst and markdown output
r11837
* ``--to rst``
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
add some detail in rst and markdown output
r11837 Basic reStructuredText output. Useful as a starting point for embedding notebooks
in Sphinx docs.
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
Min RK
discuss `--to notebook`...
r20543 * ``--to script``
MinRK
add some detail in rst and markdown output
r11837
Min RK
discuss `--to notebook`...
r20543 Convert a notebook to an executable script.
This is the simplest way to get a Python (or other language, depending on the kernel) script out of a notebook.
If there were any magics in an IPython notebook, this may only be executable from
MinRK
update nbconvert doc...
r11824 an IPython session.
Min RK
discuss `--to notebook`...
r20543
* ``--to notebook``
.. versionadded:: 3.0
This doesn't convert a notebook to a different format *per se*,
instead it allows the running of nbconvert preprocessors on a notebook,
and/or conversion to other notebook formats. For example::
ipython nbconvert --to notebook --execute mynotebook.ipynb
will open the notebook, execute it, capture new output, and save the result in
:file:`mynotebook.nbconvert.ipynb`.
::
ipython nbconvert --to notebook --nbformat 3 mynotebook
will create a copy of :file:`mynotebook.ipynb` in :file:`mynotebook.v3.ipynb`
in version 3 of the :ref:`notebook format <nbformat>`.
If you want to convert a notebook in-place,
you can specify the ouptut file to be the same as the input file::
ipython nbconvert --to notebook mynb --output mynb
Be careful with that, since it will replace the input file.
MinRK
add some detail in rst and markdown output
r11837
MinRK
add pandoc note
r11838 .. note::
nbconvert uses pandoc_ to convert between various markup languages,
Min RK
discuss `--to notebook`...
r20543 so pandoc is a dependency when converting to latex or reStructuredText.
MinRK
add pandoc note
r11838
.. _pandoc: http://johnmacfarlane.net/pandoc/
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 The output file created by ``nbconvert`` will have the same base name as
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792 the notebook and will be placed in the current working directory. Any
supporting files (graphics, etc) will be placed in a new directory with the
same base name as the notebook, suffixed with ``_files``::
$ ipython nbconvert notebook.ipynb
$ ls
notebook.ipynb notebook.html notebook_files/
MinRK
update nbconvert doc...
r11824 For simple single-file output, such as html, markdown, etc.,
the output may be sent to standard output with::
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
MinRK
update nbconvert doc...
r11824 $ ipython nbconvert --to markdown notebook.ipynb --stdout
David P. Sanders
Initial refactoring of htmlnotebook.txt into 3 parts....
r11792
Multiple notebooks can be specified from the command line::
$ ipython nbconvert notebook*.ipynb
$ ipython nbconvert notebook1.ipynb notebook2.ipynb
or via a list in a configuration file, say ``mycfg.py``, containing the text::
c = get_config()
c.NbConvertApp.notebooks = ["notebook1.ipynb", "notebook2.ipynb"]
and using the command::
$ ipython nbconvert --config mycfg.py
Brian E. Granger
Adding docs about latex citations.
r12270 LaTeX citations
---------------
``nbconvert`` now has support for LaTeX citations. With this capability you
can:
* Manage citations using BibTeX.
* Cite those citations in Markdown cells using HTML data attributes.
* Have ``nbconvert`` generate proper LaTeX citations and run BibTeX.
For an example of how this works, please see the citations example in
the nbconvert-examples_ repository.
.. _nbconvert-examples: https://github.com/ipython/nbconvert-examples