Search code examples
python-sphinxmermaidmyst

It is possible to have sphinx MyST rendering mermaid


It is possible to make work mermaid inside \.md file with MyST md driver ?

For now the only way I found is

$ tail conf.py
extensions = [ 'recommonmark', 'sphinxcontrib.mermaid']
from recommonmark.transform import AutoStructify
def setup(app):
    app.add_transform(AutoStructify)
$

The below is rendered with recommonmark:

```mermaid::

  graph LR
    a --> b
```

but not with MyST-parser

I have open this issue in MyST: https://github.com/executablebooks/MyST-Parser/issues/366

Note: recommonmark does not render correctly tables that's why I try to use MyST-parser


Solution

  • mermaid is prefectly integrated to MyST-parser.

    You only need to call it like that with {mermaid}:

    ```{mermaid}
    graph LR
      a --> b
    ```
    

    No need to define in conf.py a def setup(app): only:

    extensions = ['myst_parser', 'sphinxcontrib.mermaid']