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.

how to add mermaid support?

See original GitHub issue

Following https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/, there might be greater use of mermaid overall. How can one go about adding official mermaid block support to zero-md?

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
zerodevxcommented, Sep 9, 2022

@CetinSert

The demo linked below uses SyncHTML.io. (I am building it.)

Wow! That’s a cool project - looks really good!

the approach suggested above breaks encapsulation.

Unfortunately, yes, mainly because of how mermaid works. For now, the markdown must be rendered into light dom - until first-class support is eventually added into zero-md (soon!). 😞

3reactions
zerodevxcommented, Feb 15, 2022

Hey, thanks for your note. Given that Github now supports mermaid natively, I might add first-class support of this feature in a future release. In the meantime, something like this will work:

<head>
  ...
  <!-- Load mermaid -->
  <script defer src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>    
  <script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@2/dist/zero-md.min.js"></script>
</head>

<body>
  <!-- Render zero-md in light dom -->
  <zero-md id="app" src="mermaid.md" no-shadow manual-render></zero-md>
  <script>
    app.addEventListener('zero-md-ready', async () => {
      // Create custom marked renderer
      const renderer = new marked.Renderer()
      renderer.code = function (code, lang) {
        return lang === 'mermaid'
          ? `<div class="mermaid">${code}</div>`
          : `<pre><code>${code}</code></pre>`
      }
      await app.render({ renderer })
      mermaid.init()
    })
  </script>
</body>

Here’s a demo: https://plnkr.co/edit/Q64k8e498RfGDdlC

Read more comments on GitHub >

github_iconTop Results From Across the Web

Include diagrams in your Markdown files with Mermaid
Now you can quickly create and edit diagrams in markdown using words with Mermaid support in your Markdown files. Include diagrams in your ......
Read more >
Mermaid.js support in Markdown files - GoLand Guide
Turn on the Mermaid option in Settings/Preferences | Languages & Frameworks | Markdown under the Markdown Extensions section.
Read more >
How to Include Mermaid Diagrams in Your GitHub Project
Did you know that GitHub now offers support for Mermaid diagrams? Here's how to deploy them in your own apps.
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).
Read more >
GitHub Writer now available with Mermaid support - CKEditor
Mermaid is a flowchart and visualization tool that relies on the Markdown language. Users can create a variety of chart types and insert...
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