Mermaid
Mermaid is a popular Javascript library creating SVG diagrams from text and code descriptions.
The Mermaid site offers Tutorials and good documentation.
Syntax
```mermaid
%%{init: {
"theme": "forest",
"fontFamily": "ibm plex sans"
}}%%
stateDiagram-v2
[*] --> Still
Still --> [*]
Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
```
The diagram descriptions are formatted as
code blocks with the language identifier mermaid
. The example shows the code for the state diagram below.
Mermaid diagrams can change their color theme and also some attributes can be configured in a JSON preamble enclosed by %%
.
Not all themes or configurable attributes are available with every type of diagram for now. We have to test our diagrams before we publish them. One good way is the official Mermaid live editor.
Layout
The following diagrams are only a few examples to give an impression of the layout. More diagram types exist and their number is growing.
State diagram
%%{init: { "theme": "forest", "fontFamily": "ibm plex sans" } }%% stateDiagram-v2 [*] --> Still Still --> [*] Still --> Moving Moving --> Still Moving --> Crash Crash --> [*]
Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia.
It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life. One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.
The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way.
Flow chart
%%{init: { "theme": "base", "fontFamily": "ibm plex sans" } }%% flowchart LR A(Start) -->|Show edges| B[Hard Edge] B -->|Link text| C(Round edge) C -->|Show decision| D{Decision} D -->|One| E[Result one] D -->|Two| F[Result two]
Entity relation
%%{init: { "theme": "base", "fontFamily": "ibm plex sans" } }%% erDiagram CUSTOMER }|..|{ DELIVERY-ADDRESS : has CUSTOMER ||--o{ ORDER : places CUSTOMER ||--o{ INVOICE : "liable for" DELIVERY-ADDRESS ||--o{ ORDER : receives INVOICE ||--|{ ORDER : covers ORDER ||--|{ ORDER-ITEM : includes PRODUCT-CATEGORY ||--|{ PRODUCT : contains PRODUCT ||--o{ ORDER-ITEM : "ordered in"