Skip to content

Commit b98d516

Browse files
committed
Merge pull request #7878 from minrk/nbconvert-downgrade
add downgrade example to whatsnew
2 parents 9e486f4 + 1d01eff commit b98d516

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

docs/source/notebook/nbconvert.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,44 @@ The currently supported export formats are:
7878
Basic reStructuredText output. Useful as a starting point for embedding notebooks
7979
in Sphinx docs.
8080

81-
* ``--to python``
81+
* ``--to script``
8282

83-
Convert a notebook to an executable Python script.
84-
This is the simplest way to get a Python script out of a notebook.
85-
If there were any magics in the notebook, this may only be executable from
83+
Convert a notebook to an executable script.
84+
This is the simplest way to get a Python (or other language, depending on the kernel) script out of a notebook.
85+
If there were any magics in an IPython notebook, this may only be executable from
8686
an IPython session.
87+
88+
* ``--to notebook``
89+
90+
.. versionadded:: 3.0
91+
92+
This doesn't convert a notebook to a different format *per se*,
93+
instead it allows the running of nbconvert preprocessors on a notebook,
94+
and/or conversion to other notebook formats. For example::
95+
96+
ipython nbconvert --to notebook --execute mynotebook.ipynb
97+
98+
will open the notebook, execute it, capture new output, and save the result in
99+
:file:`mynotebook.nbconvert.ipynb`.
100+
101+
::
102+
103+
ipython nbconvert --to notebook --nbformat 3 mynotebook
104+
105+
will create a copy of :file:`mynotebook.ipynb` in :file:`mynotebook.v3.ipynb`
106+
in version 3 of the :ref:`notebook format <nbformat>`.
107+
108+
If you want to convert a notebook in-place,
109+
you can specify the ouptut file to be the same as the input file::
110+
111+
ipython nbconvert --to notebook mynb --output mynb
112+
113+
Be careful with that, since it will replace the input file.
87114

88115
.. note::
89116

90117
nbconvert uses pandoc_ to convert between various markup languages,
91-
so pandoc is a dependency of most nbconvert transforms,
92-
excluding Markdown and Python.
118+
so pandoc is a dependency when converting to latex or reStructuredText.
93119

94120
.. _pandoc: http://johnmacfarlane.net/pandoc/
95121

docs/source/whatsnew/version3.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ Backwards incompatible changes
217217
to read and write notebook files
218218
instead of the deprecated :mod:`IPython.nbformat.current` APIs.
219219

220+
You can downgrade a notebook to v3 via ``nbconvert``::
221+
222+
ipython nbconvert --to notebook --nbformat 3 <notebook>
223+
224+
which will create :file:`notebook.v3.ipynb`, a copy of the notebook in v3 format.
225+
220226
* :func:`IPython.core.oinspect.getsource` call specification has changed:
221227

222228
* `oname` keyword argument has been added for property source formatting

0 commit comments

Comments
 (0)