MDExMermaid (MDExMermaid v0.2.0)
View SourceUsage
Mix.install([
{:mdex_mermaid, "~> 0.1"}
])
markdown = """
# Flowchart
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
"""
mdex = MDEx.new() |> MDExMermaid.attach()
MDEx.to_html!(mdex, document: markdown) |> IO.puts()
#=>
# <h1>Flowchart</h1>
# <pre id="mermaid-1" class="mermaid" phx-update="ignore">graph TD;
# A-->B;
# A-->C;
# B-->D;
# C-->D;
# </pre>
# <script type="module">
# import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
#
# const theme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default';
#
# mermaid.initialize({
# securityLevel: 'loose',
# theme: theme,
# });
# </script>
See attach/2 for more info.
Summary
Functions
Attaches the MDExMermaid plugin into the MDEx pipeline.
Functions
@spec attach( MDEx.Pipe.t(), keyword() ) :: MDEx.Pipe.t()
Attaches the MDExMermaid plugin into the MDEx pipeline.
- Mermaid is loaded from https://www.jsdelivr.com/package/npm/mermaid
- Theme is determined by the user's
prefers-color-scheme
system preference
Options
:mermaid_version
(String.t/0
. Defaults to "11") - The version of mermaid to use.:mermaid_security_level
(String.t/0
. Defaults to "loose") - The security level to use for the mermaid diagrams.