jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
219 stars 64 forks source link

MyST tries to parse directives that are embedded in code blocks #1651

Open choldgraf opened 6 days ago

choldgraf commented 6 days ago

In the plugin tutorial, I encountered some weird behavior in MyST. I have a lot of blocks in the tutorial that explain how to use a directive like this:

````{code} markdown
:filename: myplugindemo.md
# My demo page

```{mydirective} Not bold
:bold: true

When I build the site with Jupyter Book / MyST, I get a lot of these errors:

⛔️ tutorial/plugins.md:195 unknown directive: mydirective
⛔️ tutorial/plugins.md:279 unknown directive: mydirective
⛔️ tutorial/plugins.md:282 unknown directive: mydirective
⛔️ tutorial/plugins.md:405 unknown directive: mydirective
⛔️ tutorial/plugins.md:408 unknown directive: mydirective
⛔️ tutorial/plugins.md:412 unknown directive: mydirective
⛔️ tutorial/plugins.md:516 unknown directive: mydirective
⛔️ tutorial/plugins.md:520 unknown directive: mydirective
⛔️ tutorial/plugins.md:525 unknown directive: mydirective

It seems that MyST is trying to parse the literal markdown blocks to uncover the directive logic inside. This feels like a bug because we expect those blocks to not be parsed directly as myst.

What works and what doesn't

It seems to be unique to {code} and {code-block}

This raises a warning

````{code} markdown
```{mydirective}

and

````{code-block} markdown
```{mydirective}

This works fine

````markdown
```{mydirective}