Sandbox for Markdown Files

Diese Seite: Sandkasten zum Ausprobieren!

Executing code in your markdown files

(JB: Text copied and modified from the which was generated by jb create dsci-lab)

If you’d like to include computational content inside these markdown files, you can use MyST Markdown to define cells that will be executed when your book is built. Jupyter Book uses jupytext to do this.

First, add Jupytext metadata to the file. For example, to add Jupytext metadata to this markdown page, run this command in the shell:

jupyter-book myst init

Once a markdown file has Jupytext metadata in it, you can add the following directive to run the code at build time:

print("Die Antwort lautet", 6*7)
print("Die Antwort lautet", 6*7)
Die Antwort lautet 42

When your book is built, the contents of any {code-cell} blocks will be executed with your default Jupyter kernel, and their outputs will be displayed in-line with the rest of your content.

For more information about executing computational content with Jupyter Book, see The MyST-NB documentation.