Converting Formats (ipynb, md)#

Jupyter Notebook (ipynb) to Myst Markdown (myst)#

It is recommended to use jupytext to convert ipynb to md (MyST) files. This tool is included in the quantecon environment.

Once it is installed you can do this via the command line

jupytext <notebook>.ipynb --to myst

Or you can use the Jupyter menu and pair the notebook with a Myst Markdown file for automatic file creation using jupyter.

Warning

When you convert the ipynb file to a myst markdown file using jupytext you will get two files, the original ipynb and the new md file. If you build using jupyter-book it will issue a warning that there are two source files such as:

WARNING: multiple files found for the document "BCG_complete_mkts": ['BCG_complete_mkts.ipynb', 'BCG_complete_mkts.md']
Use 'python-lecture-sandpit.myst/lectures-mixed/BCG_complete_mkts.md' for the build.

By default it will use the md version of the file to build the project.

Myst Markdown (md) to Jupyter Notebook (ipynb)#

It is recommended to use jupytext to convert md (MyST) to ipynb files. This tool is included in the quantecon environment.

Once it is installed you can do this via the command line

jupytext <filename>.md --to ipynb

Tip

If you are starting from markdown you will need to let jupytext know it is encoded as a myst document. The easiest way to do this is to add header metadata to the top of your markdown document.

For a python project it would be:

---
jupytext:
  text_representation:
    extension: .md
    format_name: myst
kernelspec:
  display_name: Python 3 (ipykernel)
  language: python
  name: python3
---

If jupytext is installed then you can also open the md file directly with jupyter notebook and it will convert the file to ipynb when it opens the md file.

Warning

When you convert the myst markdown file to an ipynb file using jupytext you will get two files, the original md file and the new ipynb file. If you build using jupyter-book it will issue a warning that there are two source files such as:

WARNING: multiple files found for the document "BCG_complete_mkts": ['BCG_complete_mkts.ipynb', 'BCG_complete_mkts.md']
Use 'python-lecture-sandpit.myst/lectures-mixed/BCG_complete_mkts.md' for the build.

By default it will use the md version of the file to build the project.