MAIDR JavaScript API
    Preparing search index...
    • Renders every diagram matching a selector and makes each one accessible, in place of mermaid.run().

      Diagrams are rendered one at a time, in document order, because some of Mermaid's diagram databases are shared between parses. A diagram that fails is reported on the console and left as Mermaid drew it -- or as text when Mermaid could not -- and the rest are still made accessible.

      Calling it again is safe: a diagram already made accessible is skipped, and so is one that failed, which is tried again only once its source -- the data-maidr-mermaid-source attribute, or the element's text when that attribute is removed -- changes.

      Parameters

      • mermaid: MermaidApi

        The Mermaid API

      • selector: string = '.mermaid'

        Which elements hold diagram source. Defaults to .mermaid

      • root: ParentNode = document

        Where to look. Defaults to the document

      Returns Promise<Maidr[]>

      The figures made, one per diagram that converted

      <pre class="mermaid">
      pie title Pets
      "Dogs" : 386
      "Cats" : 85
      </pre>
      <script>
      mermaid.initialize({ startOnLoad: false });
      maidrMermaid.bindMermaid(mermaid);
      </script>