executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
751 stars 197 forks source link

mermaid is not rendering in Markdown #959

Closed monajalal closed 1 month ago

monajalal commented 2 months ago

What version of myst-parser are you using?

$ pip show myst-parser Name: myst-parser Version: 3.0.1 Summary: An extended CommonMark compliant parser, Home-page: Author: Author-email: Chris Sewell chrisj_sewell@hotmail.com License: Location: /home/mona/anaconda3/lib/python3.9/site-packages Requires: docutils, jinja2, markdown-it-py, mdit-py-plugins, pyyaml, sphinx Required-by:

What version dependencies are you using?

sphinxcontrib-mermaid

$ pip show sphinxcontrib-mermaid
Name: sphinxcontrib-mermaid
Version: 0.9.2
Summary: Mermaid diagrams in yours Sphinx powered docs
Home-page: https://github.com/mgaitan/sphinxcontrib-mermaid
Author: Martín Gaitán
Author-email: gaitan@gmail.com
License: BSD
Location: /home/mona/anaconda3/lib/python3.9/site-packages
Requires: 
Required-by: 

What operating system are you using?

Ubuntu 22.04

Describe the Bug

I am using

https://github.com/mgaitan/sphinxcontrib-mermaid

and when I do make html this is what I get.

Screenshot from 2024-08-07 13-09-49

$ cat simple_mermaid.md 
# Simple Mermaid

```{mermaid}
  graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;


### Expected Behavior

to actually render the mermaid charts inside the md files properly

### To Reproduce

_No response_
chrisjsewell commented 2 months ago

Heya, have you tried doing it in a restructuredtext file? from a first look this does not appear to be an issue with myst-parser, and should be raised in https://github.com/mgaitan/sphinxcontrib-mermaid

FYI though I don't think you need to indent the mermaid syntax:

```{mermaid}
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
monajalal commented 2 months ago

Heya, have you tried doing it in a restructuredtext file? from a first look this does not appear to be an issue with myst-parser, and should be raised in https://github.com/mgaitan/sphinxcontrib-mermaid

FYI though I don't think you need to indent the mermaid syntax:

```{mermaid}
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

I specifically want the mermaid chart to be inside the .md file. The extension I linked in OP shows it should be possible.

image

chrisjsewell commented 2 months ago

I specifically want the mermaid chart to be inside the .md file.

yes but... thus far, there is nothing to suggest this is a bug with myst-parser or anything that can be fixed here, its more likely a bug in https://github.com/mgaitan/sphinxcontrib-mermaid

if it was shown that exactly the same thing works correctly within a restructuredtext file, then ok, thats more evidence that perhaps there is a fault in myst-parser.

I'd also note that previously I had a mermaid graph example in the documentation for this repo, but removed it due to this issue: https://github.com/mgaitan/sphinxcontrib-mermaid/issues/109, which infuriatingly after 1.5 years is still not fixed. If they fix that, I would add an example back into the docs 😅

iso2013 commented 2 months ago

I was not able to reproduce this using the given example or any variation on its whitespace. My guess as to what appears to be happening based on the output image (if it is MyST Parser) is that the graph's content is somehow getting recognized as a Markdown code block, which can be specified in Markdown by indenting.

The versions I'm using are:

@monajalal can you please provide a full file example?

I will investigate if this could be a regression in 3.0.1 shortly, but I doubt it.

cclauss commented 1 month ago

Is the problem about the presence or lack of braces {} as discussed in:

GitHub seems to need no braces and sphinxcontrib-mermaid appears to need the braces.

Fixed by adding myst_fence_as_directive = ["mermaid"] to conf.py as discussed at