Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

MyST Demo Directive

Shows raw MyST content alongside its rendered output - perfect for documentation and tutorials.

Usage

Add to your myst.yml:

project:
  plugins:
    - https://raw.githubusercontent.com/jupyter-book/myst-plugins/main/plugins/demo/src/index.mjs

Basic Example

MyST Demo
This is **bold** and this is *italic*.

Here's a [link](https://mystmd.org).


This is bold and this is italic.

Here’s a link.

Lists and Structure

MyST Demo
### A Heading

Here's an unordered list:

- First item
- Second item
- Third item

And a numbered list:

1. Step one
2. Step two
3. Step three


A Heading

Here’s an unordered list:

  • First item

  • Second item

  • Third item

And a numbered list:

  1. Step one

  2. Step two

  3. Step three

Code Blocks

MyST Demo
Here's some Python code:

```python
def hello_world():
    print("Hello, MyST!")
```


Here’s some Python code:

def hello_world():
    print("Hello, MyST!")

Admonitions

MyST Demo
:::{note}
This is a note admonition with important information!
:::

:::{warning}
This is a warning - be careful!
:::


Math

MyST Demo
Inline math: $E = mc^2$

Display math:

$$
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
$$


Inline math: E=mc2E = mc^2

Display math:

0ex2dx=π2\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}

Images and Figures

MyST Demo
```{figure} https://picsum.photos/seed/myst-demo/400/300.jpg
:name: random-figure

A random image from Unsplash
```


A random image from Unsplash

Figure 1:A random image from Unsplash

Cross-References

MyST Demo
You can reference the figure above: see {ref}`random-figure` for an example.


You can reference the figure above: see Figure 1 for an example.

How It Works

The myst:demo directive takes any MyST content and displays it in a single card:

  1. MyST Demo heading (customizable via an argument)

  2. A code block titled “Source MyST” showing the raw markdown

  3. Rendered output below

You can also use myst-demo as an alias if needed.

This makes it perfect for:

This directive is used extensively throughout the myst-plugins documentation to show examples of each plugin in action!