markdown-mode
markdown-mode copied to clipboard
Support for MyST syntax
It would be useful to have a mode to support MyST syntax. MyST is an extension of CommonMark that adds support for various RST-style markup for use with Sphinx. It is gaining popularity as a replacement for RST with the Sphinx document system, especially in the Python ecosystem.
You can see the full list of MyST syntax here https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html. In particular, it would be nice if it didn't consider ```{directive} to be a code block, as typical directives just use Markdown syntax inside of them. Right now, it renders every directive block as a code block, which removes all syntax highlighting and other features inside of it, and even disables flyspell spell checking.
Syntax highlighting of things like {ref}`target` and (target)= would also be useful.
MyST syntax is a superset of CommonMark, so I would imagine that just like gfm-mode it wouldn't be too hard to add a custom mode for it with at least basic support.
Related to this, when writing code blocks for myst-nb text-based notebooks (where you're writing jupyter notebooks as .md files), the syntax for code blocks is:
```{code-cell} ipython3
print('python here')
\```
(that last slash isn't part of the syntax, but I'm not sure how to render a code block within a code block with github markdown without it)
I think the ipython3 there is optional. Regardless, it should be possible to get markdown-mode to properly fontify this code block by editing markdown-code-lang-modes, but I have been unable to figure out how to do so. Neither
(add-to-list 'markdown-code-lang-modes '("\\{code-cell\\}" . python-mode))
nor
(add-to-list 'markdown-code-lang-modes '("{code-cell}" . python-mode))
work.
I would be particularly interested in the ability to properly fill paragraphs directives, without the directive itself being filled. In the following, typing M-q while being the in the paragraph:
:::{admonition}
A long paragraph ...
:::
should not lead to
:::{admonition} ... a long paragraph ...
...:::
Currently, I always insert empty lines to avoid this as in the following example, but this is wasting vertical space.
:::{admonition}
A long paragraph ...
:::
Thanks in advance!