Current section

Files

Jump to
mdex examples mermaid.html
Raw

examples/mermaid.html

<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
<h1>Mermaid Example</h1>
<p>In this example we'll inject the script code to initialize and render mermaid blocks.</p>
<pre class="mermaid">sequenceDiagram
participant Alice
participant Bob
Alice->>John: Hello John, how are you?
loop HealthCheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
</pre>
<p>The following script is used to load the mermaid library and initialize it:</p>
<pre class="athl" style="color: #abb2bf; background-color: #282c34;"><code class="language-javascript" translate="no" tabindex="0"><span class="line" data-line="1"><span style="color: #c678dd;">import</span> <span style="color: #abb2bf;">mermaid</span> <span style="color: #c678dd;">from</span> <span style="color: #98c379;">&#39;https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs&#39;</span><span style="color: #848b98;">;</span>
</span><span class="line" data-line="2"><span style="color: #abb2bf;">mermaid</span><span style="color: #848b98;">.</span><span style="color: #61afef;">initialize</span><span style="color: #848b98;">(</span><span style="color: #848b98;">&lbrace;</span> <span style="color: #56b6c2;">startOnLoad</span><span style="color: #848b98;">:</span> <span style="color: #d19a66;">true</span> <span style="color: #848b98;">&rbrace;</span><span style="color: #848b98;">)</span><span style="color: #848b98;">;</span>
</span></code></pre>