Markdown-mermaid语法

Mermaid是一个强大的图表生成库,支持Markdown语法,使得在Typora等编辑器中创建流程图、时序图、状态图和类图变得简单。例如,流程图用于展示步骤流程,时序图用于表示交互顺序,状态图描述对象状态变化,而类图则用于表示类之间的关系。通过Mermaid的简洁语法,可以轻松实现各种图表的可视化,提高文档的可读性。
摘要由CSDN通过智能技术生成

Mermaid是一种基于Javascript的绘图工具,使用类似于Markdown的语法,使用户可以方便快捷地通过代码创建图表。对于支持Mermaid语法的Markdown编辑器(Typora),可以实现使用文本和代码方便的实现图表创建及可视化效果。使用时需要使用"mermaid"作为代码块的语言标识。

Mermaid语法文档:About Mermaid (mermaid-js.github.io)

一、流程图(Flowchart)

示例
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
A
B
C
D

二、时序图(Sequence diagram)

示例
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!
Alice Bob John Hello John, how are you? Fight against hypochondria loop [Healthcheck] Rational thoughts prevail! Great! How about you? Jolly good! Alice Bob John

三、状态图(State diagrams)

示例
stateDiagram-v2
    [*] --> Still
    Still --> [*]

    Still --> Moving
    Moving --> Still
    Moving --> Crash
    Crash --> [*]
Still
Moving
Crash

四、类图(Class diagram)

示例
classDiagram
Class01 <|-- AveryLongClass : Cool
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
Cool
Where am i?
Cool label
Class01
int chimp
int gorilla
size()
AveryLongClass
Class03
Class04
Class05
Class06
Class07
Object[] elementData
equals()
Class08
Class09
C2
C3

五、甘特图(Gantt diagram)

示例
gantt
	dateFormat  YYYY-MM-DD
	title Adding GANTT diagram functionality to mermaid

	section A section
	Completed task            :done,    des1, 2014-01-06,2014-01-08
	Active task               :active,  des2, 2014-01-09, 3d
	Future task               :         des3, after des2, 5d
	Future task2              :         des4, after des3, 5d

    section Critical tasks
    Completed task in the critical line :crit, done, 2014-01-06,24h
    Implement parser and jison          :crit, done, after des1, 2d
    Create tests for parser             :crit, active, 3d
    Future task in critical line        :crit, 5d
    Create tests for renderer           :2d
    Add to mermaid                      :1d

    section Documentation
    Describe gantt syntax               :active, a1, after des1, 3d
    Add gantt diagram to demo page      :after a1  , 20h
    Add another diagram to demo page    :doc1, after a1  , 48h
Mon 06 Mon 13 Mon 20 Completed task Active task Future task Future task2 Completed task in the critical line Implement parser and jison Create tests for parser Future task in critical line Create tests for renderer Add to mermaid Describe gantt syntax Add gantt diagram to demo page Add another diagram to demo page A section Critical tasks Documentation Adding GANTT diagram functionality to mermaid

六、饼图(Pie chart)

示例
pie title Pets adopted by volunteers
    "Dogs" : 386
    "Cats" : 85
    "Rats" : 15
79% 17% 3% Pets adopted by volunteers Dogs Cats Rats

七、Git图(Git graph)

示例
gitGraph:
options
{
    "nodeSpacing": 20,
    "nodeRadius": 5
}
end
commit
branch newbranch
branch branch1
branch branch2
checkout newbranch
commit
commit
checkout branch1
commit
commit
checkout master
commit
commit
merge newbranch

master, 90308dd

ebef54f

4f2e548

branch2, 725b35c

newbranch, f65d9b1

cbf208d

branch1, 46c2c63

21d45c5

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

long7066

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值