Mermaid Support für das Blog

Erstellt: 16.04.2022 Bearbeitet: 29.09.2024

Mermaid ist eine Javascript basiertes diagram und Chart Lib, bei der man mit einfachen text bausteinen, Diagramme Schreiben kann.

Beispiele

    ​~~~mermaid
    graph TB
        A --> B
        B --> C
    ​~~~
graph TB A --> B B --> C
    ​~~~mermaid
    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"
    ​~~~
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"
    ~~~mermaid
    stateDiagram-v2
        [*] --> Still
        Still --> [*]
        Still --> Moving
        Moving --> Still
        Moving --> Crash
        Crash --> [*]
    ​~~~
stateDiagram-v2 [*] --> Still Still --> [*] Still --> Moving Moving --> Still Moving --> Crash Crash --> [*]
    ~~~mermaid
    gitGraph
    commit
    commit
    branch two
    commit
    checkout main
    commit
    branch three
    checkout three
    commit
    commit
    checkout main
    commit
    commit
    branch one
    checkout one
    commit
    checkout two
    commit
    checkout main
    merge two
    checkout one
    merge two
    merge three
    commit
    commit
    checkout main
    merge one
    ​~~~
gitGraph commit commit branch two commit checkout main commit branch three checkout three commit commit checkout main commit commit branch one checkout one commit checkout two commit checkout main merge two checkout one merge two merge three commit commit checkout main merge one
    ~~~mermaid
    sequenceDiagram
            title: FancySequenceDiagramaccDescription Test a description
            participant Alice
            participant Bob
            participant John as John<br />Second Line
            rect rgb(20, 20, 100)
            rect rgb(0, 5, 200)
            Alice ->> Bob: Hello Bob, how are you?
            Bob-->>John: How about you John?
            end
            Bob--x Alice: I am good thanks!
            Bob-x John: I am good thanks!
            Note right of John: John thinks a long<br />long time, so long<br />that the text does<br />not fit on a row.
            Bob-->Alice: Checking with John...
            Note over John:wrap: John looks like he's still thinking, so Bob prods him a bit.
            Bob-x John: Hey John - we're still waiting to know<br />how you're doing
            Note over John:nowrap: John's trying hard not to break his train of thought.
            Bob-x John:wrap: John! Are you still debating about how you're doing? How long does it take??
            Note over John: After a few more moments, John<br />finally snaps out of it.
            end
            alt either this
            Alice->>+John: Yes
            John-->>-Alice: OK
            else or this
            Alice->>John: No
            else or this will happen
            Alice->John: Maybe
            end
            par this happens in parallel
            Alice -->> Bob: Parallel message 1
            and
            Alice -->> John: Parallel message 2
            end
    ​~~~
sequenceDiagram title: FancySequenceDiagramaccDescription Test a description participant Alice participant Bob participant John as John
Second Line rect rgb(20, 20, 100) rect rgb(0, 5, 200) Alice ->> Bob: Hello Bob, how are you? Bob-->>John: How about you John? end Bob--x Alice: I am good thanks! Bob-x John: I am good thanks! Note right of John: John thinks a long
long time, so long
that the text does
not fit on a row. Bob-->Alice: Checking with John... Note over John:wrap: John looks like he's still thinking, so Bob prods him a bit. Bob-x John: Hey John - we're still waiting to know
how you're doing Note over John:nowrap: John's trying hard not to break his train of thought. Bob-x John:wrap: John! Are you still debating about how you're doing? How long does it take?? Note over John: After a few more moments, John
finally snaps out of it. end alt either this Alice->>+John: Yes John-->>-Alice: OK else or this Alice->>John: No else or this will happen Alice->John: Maybe end par this happens in parallel Alice -->> Bob: Parallel message 1 and Alice -->> John: Parallel message 2 end

Oder in einfacher

    ~~~mermaid
        sequenceDiagram
            Alice->>+John: Hello John, how are you?
            Alice->>+John: John, can you hear me?
            John-->>-Alice: Hi Alice, I can hear you!
            John-->>-Alice: I feel great!
    ​~~~
sequenceDiagram Alice->>+John: Hello John, how are you? Alice->>+John: John, can you hear me? John-->>-Alice: Hi Alice, I can hear you! John-->>-Alice: I feel great!
    ~~~mermaid
    pie
    "Dogs" : 42.96
    "Cats" : 50.05
    "Rats" : 10.01
    ​~~~
pie "Dogs" : 42.96 "Cats" : 50.05 "Rats" : 10.01