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="autumn-hl" style="background-color: #282C34; color: #ABB2BF;"><code class="language-javascript" translate="no"><span class="ahl-keyword" style="color: #E06C75;">import</span> <span class="ahl-variable" style="color: #ABB2BF;">mermaid</span> <span class="ahl-keyword" style="color: #E06C75;">from</span> <span class="ahl-string" style="color: #98C379;">&#x27;https:&#x2f;&#x2f;cdn.jsdelivr.net&#x2f;npm&#x2f;mermaid@10&#x2f;dist&#x2f;mermaid.esm.min.mjs&#x27;</span><span class="ahl-punctuation ahl-delimiter" style="color: #ABB2BF;">;</span>
<span class="ahl-variable" style="color: #ABB2BF;">mermaid</span><span class="ahl-punctuation ahl-delimiter" style="color: #ABB2BF;">.</span>initialize<span class="ahl-punctuation ahl-bracket" style="color: #ABB2BF;">(</span><span class="ahl-punctuation ahl-bracket" style="color: #ABB2BF;">{</span> startOnLoad: <span class="ahl-constant ahl-builtin" style="color: #D19A66;">true</span> <span class="ahl-punctuation ahl-bracket" style="color: #ABB2BF;">}</span><span class="ahl-punctuation ahl-bracket" style="color: #ABB2BF;">)</span><span class="ahl-punctuation ahl-delimiter" style="color: #ABB2BF;">;</span>
</code></pre>