Enabling Mermaid Diagrams in Blog Garden Posts

Overview of Mermaid Mermaid is a JavaScript-based charting tool that allows users to generate diagrams programmatically using a syntax similar to Markdown. Integrating these diagrams into your blog posts can significantly enhance the readability and visual appeal of technical documentation.

Using Mermaid in Markdown To embed a Mermaid diagram within your Markdown content, wrap the specific syntax inside a fenced code block designated with the mermaid language identifier:

    diagram_type
        mermaid_syntax_definitions

Supported Diagram Categories

Flowcharts: Initiated with the flowchart keyword.
Sequence Diagrams: Initiated with sequenceDiagram.
Class Diagrams: Initiated with classDiagram.
State Diagrams: Initiated with stateDiagram.
Entity Relationship Diagrams: Initiated with erDiagram.
User Journeys: Initiated with journey.
Gantt Charts: Initiated with gantt.
Pie Charts: Initiated with pie.
Requirement Diagrams: Initiated with requirementDiagram.

Note: Using non-ASCII characters (like Chinese) in specific syntax parts might lead to rendering errors.

Code Examples

Entity Rleationship Diagram

erDiagram
    CLIENT }|..|{ ADDRESS : resides
    CLIENT ||--o{ PURCHASE : makes
    CLIENT ||--o{ BILL : "responsible for"
    ADDRESS ||--o{ PURCHASE : ships_to
    BILL ||--|{ PURCHASE : covers
    PURCHASE ||--|{ ITEM : contains
    CATEGORY ||--|{ PRODUCT : groups
    PRODUCT ||--o{ ITEM : "listed in"

Class Diagram

classDiagram
    Vehicle <|-- Car : Extends
    Vehicle <|-- Truck : Extends
    Vehicle : +int speed
    Vehicle : +start()
    Car : +string model
    Car : +drive()
    Truck : +int capacity
    Truck : +load()

Flowchart Basics Flowcharts are defined using the flowchart keyword followed by a direction indicator (e.g., LR for Left-to-Right).

Defining Nodes Nodes can be defined simply by an ID, or with a display label using square brackets [label].

flowchart LR
    A
    B[Custom Label]

Direction Controls You can change the orientation of the graph using the following directives:

TB or TD: Top to Bottom
BT: Bottom to Top
LR: Left to Right
RL: Right to Left

Connections and Shapes Use arrows like --> to connect nodes. Node shapes can be altered using different brackets:

(text): Round edges
((text)): Circle
{text}: Diamond/Rhombus
[/text\]: Trapezoid (Note: / and \ usually require pairing)

flowchart LR
    Start --> Process((Decision)) --> End[Finish]

For comprehensive documentation and advanced features, please refer to the official Mermaid.js web site.

Tags: mermaid blog-garden Markdown diagrams flowchart

Posted on Wed, 13 May 2026 18:41:39 +0000 by ali_2kool2002