question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe the solution you’d like

support mermaid

Describe alternatives you’ve considered

The conf.py I used to make work mermaid with recommonmark:

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

This mermaid is rendered

```mermaid::

  graph LR
    a --> b
\```

Note that the above need to have a new line after mermaid:: and graph need to start with a space.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
brianv0commented, Sep 7, 2022

Just to add a bit of context which may be helpful. Mermaid itself already has directives that are relevant for rendering a figure. Those are already passed through to e.g. mmdc and sphinxcontrib-mermaid, for example. sphinxcontrib-mermaid supports a few extra parameters for it’s directive.

I’d like to request that mermaid-tagged fenced code blocks, specifically, and possibly others down the road, be treated as directives instead of languages.

You could do so here, by detecting “special” languages that should be interpreted as directives instead of languages to highlight.

https://github.com/executablebooks/MyST-Parser/blob/310580730652f3b84da3868f2a886ef9fc743959/myst_parser/mdit_to_docutils/base.py#L596-L603

A hacky version I did was able to deal with this:

 info = token.info.strip() if token.info else token.info 
 language = info.split()[0] if info else "" 
 if language in ["mermaid", ...]:
     # update language to mimic directive
     language = "{%s}" % language
     # rewrite token.token.info for render_directive
     token.token.info = language + (" %s" + ' '.join(info.split()[1:]) if info.split()[1:] else "")
  
 if (not self.md_config.commonmark_only) and (not self.md_config.gfm_only): 
     if language == "{eval-rst}": 
         return self.render_restructuredtext(token) 
     if language.startswith("{") and language.endswith("}"): 
         return self.render_directive(token) 
0reactions
ajcerejeiracommented, Mar 14, 2022

Oh so you are talking about this Gitlab only feature: https://docs.gitlab.com/ee/user/markdown.html#mermaid? This won’t work on Github (unless perhaps you have a browser extension https://github.com/BackMarket/github-mermaid-extension), and kind of works more by luck, than by design on Gitlab (it seems to be ok ignoring the :: at the end)

It works now on GitHub as well: https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/

Here an example:

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

It produces:

  graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Include diagrams in your Markdown files with Mermaid
A picture tells a thousand words. Now you can quickly create and edit diagrams in markdown using words with Mermaid support in your...
Read more >
Mermaid | Diagramming and charting tool
JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. Get Started · View on ...
Read more >
Mermaid diagrams can be displayed within Markdown #372
Today, we're excited to add native support for Mermaid wherever Markdown is supported (e.g., issues, repositories, discussions, gists). Intended ...
Read more >
GitHub Writer now available with Mermaid support - CKEditor
GitHub has recently introduced Mermaid support. Mermaid is a flowchart and visualization tool that relies on the Markdown language.
Read more >
Markdown Preview Mermaid Support
Extension for Visual Studio Code - Adds Mermaid diagram and flowchart support to VS Code's builtin markdown preview.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found