V2026.32026-03-27VLOOK™<br>让你的 Markdown 有了新看wán法<br>──<br>脚本化图表参考指南<br>最新版本V2026.32026-03-27<br><br>MAX°孟兆<br>Copyright © 2016-2026 MAX°DESIGN. All rights reserved.关于脚本化关于 Mermaid关于 Markdown建模类图表流程图关于所支持的 FontAwesome 版本流程图扩展应用说明分角色流程图顺序图说明状态机图流程图扩展的状态机图状态机图扩展应用说明标准状态机图类图实体关系图方块图四象限图数据包图架构图ZenUML 图应用类图表思维导图关于对 FontAwesome 的支持Gitgraph 图桑基图时间线XY 图饼图雷达图树状图看板图甘特图The End
Mermaid 是一个用于画流程图、状态机图、顺序图、甘特图的库,使用 JS 进行本地渲染,广泛集成于许多 Markdown 编辑器中。
Markdown 是什么?
2004 年,John Gruber 创造了
Markdown,一种专门针对网络写作的
文本标记语言。使用 Markdown,你只需在写作过程中插入少量的标记符号,就能很轻松地进行排版(例如设置标题、加粗、列表、引用块等);Markdown 文档以
纯文本格式存储,这意味着,它们可以用几乎任一种文本编辑器打开。同时,又能通过 Markdown 编辑器导出为带排版的富文本文档、HTML 网页等等。纯粹、简洁、易用、灵活,都是人们喜欢 Markdown 的原因;目前 Markdown 的标准化项目是 CommonMark 。
60 秒学会、10 分钟深入学习 Markdown 语法
推荐Github Flavored Markdown (GFM) 语法参考:Typora 目前采用该标准 详细;标准化 CommonMark 语法参考:60 秒学会 Markdown 语法、10 分钟深入学习 Markdown 。
流程图以上的「分支流程」内容由下图进行接续)
分支流程(接续上图)
查看完整画图脚本示例
x1```mermaid2flowchart TB3%% 图的方向说明4%% LR:从左到图,RL:从右到左,TB:从上到下,BT:从下到上56%% 连续连接7START(["`**开始**`"])8START --> pre1{{"❤ 准备"}} --> node2[节点]9pre1 --> node1(可选)1011subgraph 子图12subgraph 子图的子图13%% 一对多14node1 --> join1{ }15join1 --> |分支|groud1[["`**子流程**`"]] & database[(存档)] & inpage1(("`A<br>_(同页)_`"))16%% click clickable "#Mermaid 的状态机图"17end18node2 --> data1[/数据/]19node2 --> data2[\文件\]20node2 --> data3(((双圈圆<br>点击可访问<br>GitHub)))21click data3 "https://www.github.com" _blank22end2324%% this is a comment2526groud1 ==> |重要分支|cond1{"判断?"}27cond1 --> |条件1|END28cond1 --> |条件2|B[/手工输入\]29cond1 --> |条件3|B2[\手动操作/]30cond1 -.-> |条件4|outpage2>"`B _(离页)_`"]3132inpage2(("`A<br>_(同页)_`")) --> END33END(["`**结束**`"])34```
更多 FontAwesome 图标库及标识代码参考 - 详情
VLOOK™ 针对流程图中特定的节点类型进行扩展,实现重绘为不同的样式,具体如下:
流程图特定标识应用说明
| 应用建议 | 节点形状 | 说明 |
|---|---|---|
| 开始、结束 | 体育场(药丸) | 节点别名使用以下 VLOOK™ 的命名规范,会呈现出特定的样式(具体呈现效果见上图): - 开始:命名为 START ,如:START([开始])- 结束:命名为 END ,如: END([结束]) |
| 同页符号 | 圆形 | 节点别名使用以下 VLOOK™ 的命名规范,会呈现出特定的样式(具体呈现效果见上图): 以 inpage 为前缀,如: inpageA1((A)) |
| 离页符号 | 旗形 | 节点别名使用以下 VLOOK™ 的命名规范,会呈现出特定的样式(具体呈现效果见上图): 以 outpage 为前缀,如: inpageB1((B)) |
用流程图模的泳道图
查看完整画图脚本示例
xxxxxxxxxx321```mermaid2flowchart LR3%% 图的方向说明4%% LR:从左到图,RL:从右到左,TB:从上到下,BT:从下到上56%% 角色A 相关的流程节点7subgraph 角色A8START([开始]) --> node1[节点1]9end1011%% 角色B 相关的流程节点12subgraph 角色B13node1 --> join1{ } --> node2("可点击打开<br>Github")14click node2 "https://www.github.com" _blank15end16node2 --> END1718%% 角色C 相关的流程节点19subgraph 角色C20direction BT21join1 --> node3(节点3) --> node31(节点31)22end2324%% 角色D 相关的流程节点25subgraph 角色D26node31 --> node4(节点4) --> END27end2829角色C --> 角色D3031END([结束])32```
顺序图(也称:时序图)
查看完整画图脚本示例
xxxxxxxxxx501```mermaid2sequenceDiagram3%% 设置显示消息的自动编号45actor User as 人物角色6participant Client as 前端触点7participant MP as 普通系统8participant Server as **重要系统角色9participant Extend as --外部系统角色1011par 平行消息12User ->> Client: 并行发送消息113and14break 例外情况15User -x Client: 中断处理消息16end17and18Client -)+ Server: 并行发送消息319Server --)- Client: 发送消息20end2122%% 设置区域高亮23rect rgba(128, 128, 128, 0.3)24Extend ->> Extend: 内部动作25end2627Note left of Extend: 显示在外部系统<br>左侧备注说明28Note right of Extend: 显示在外部系统<br>右侧备注说明29Note over Client,Server: 跨对象备注说明30loop 循环31Client ->>+ Extend: 发送消息A32alt 默认情况33Server ->> Client: 默认情况消息A134else 非默认情况35Server -->> Client: 非默认消息A236end3738opt 可选39Extend ->>- Server: 发送消息X40end4142critical 必须执行43Server -)+ Client: 必须执行消息44option 可选情况A45Server ->> Client: 执行可选消息A46option 可选情况B47Server ->> Client: 执行可选消息B48end49end50```
针对顺序图的不同图元应用,重绘不同的外观、形状;
针对 loopCy alt / elseVn optPu parOg criticalRd breakBk 标签设置不同的外观、本地语言的标题;
建议使用实体别名,以提高画图脚本的复用度和可维护性;
支持三类消息线条:同步请求消息、异步请求消息、返回消息;
角色在标准的一类样式的基础上,增加三类扩展的样式,在输出HTML后应用 VLOOK™ 插件后渲染为不同的样式:
重要系统/角色:在角色名称前添加两个星号 ** ,如 **后端支撑系统名称
外部系统/角色:在角色名称前添加两个减号 -- ,如 --外部系统名称
支持以下分组在输出 HTML 渲染为不同的样式:
loop...end :用于 循环
alt...else...end :用于条件 分支(if / else)
opt...end :用于 可选 (即只有 if、没有 else 的情况)
par...end :用于 并行
critical...option...option...end :用于作为一个 整体执行,并根据不同情况进行 条件 处理
break...end :用于 中断
支持备注说明。
流程图扩展的状态机图(兼容性较高)
竖向样式
查看完整画图脚本示例
xxxxxxxxxx221```mermaid2flowchart LR3横向状态机图4%% 图的方向说明5%% LR:从左到图,RL:从右到左,TB:从上到下,BT:从下到上67%% 正常情况8INIT(( )) --> |初始|A([状态 A])9%% joinv 表示汇聚为竖向样式,join 表示汇聚为横向样式10A --> |汇聚|joinv1[ ]11joinv1 --> |"<角色:行为>"<br>Act / 变更处理说明|B([状态 B\n多行样式])12subgraph 状态集13B --> |"<角色:行为>"<br>Act / 变更处理说明|C([状态 C])14end15C --> FINAL1617%% 异常情况18joinv1 -.-> |"<角色:行为>"<br>Act / 变更处理说明|C19joinv1 -.-> |Act / 变更处理说明|D([状态 D])20D --> FINAL21FINAL(( ))22```
VLOOK™ 针对流程图中特定的节点类型进行扩展,实现以流程图为基础的状态机图能渲染为不同的样式,具体如下:
状态图特定标识应用说明
| 应用建议 | 节点形状 | 说明 |
|---|---|---|
| 初始、终止 | 圆形 | 节点别名使用以下 VLOOK™ 的命名规范,会呈现出特定的样式(具体呈现效果见上图): - 初始:命名为 INIT ,如:INIT(( ))- 结束:命名为 FINAL ,如: FINAL(( )) |
| 汇聚、转换 | 圆形 | 节点别名使用以下 VLOOK™ 的命名规范,会呈现出特定的样式(具体呈现效果见上图): 以 join 为前缀,如: join1(( )) |
| : | 菱形 | 以 join 为前缀,如: join1{ } |
| : | 矩形 | 以 join 或 joinv 为前缀,一般用于状态机图中,如: join1[ ] (默认横向), joinv1[ ] (竖向) |
| 同页符号 | : | 节点别名使用以下 VLOOK™ 的命名规范,会呈现出特定的样式(具体呈现效果见上图): 以 inpage 为前缀,如: inpageA1((A)) |
| 离页符号 | 旗形 | 节点别名使用以下 VLOOK™ 的命名规范,会呈现出特定的样式(具体呈现效果见上图): 以 outpage 为前缀,如: inpageB1((B)) |
新版标准状态机图 (1)
查看完整画图脚本示例
xxxxxxxxxx91```mermaid2stateDiagram3[*] --> 状态A4状态A --> 状态B : <角色:行为><br>Act / 变更处理说明5状态B --> 状态C : 状态转换说明6状态C --> 状态B : 状态转换说明7状态C --> 状态A : 状态转换说明8状态C --> [*]9```
新版标准状态机图 (2)
查看完整画图脚本示例
xxxxxxxxxx421```mermaid2stateDiagram3state fork_state <<fork>>45[*] --> 状态组16状态组1 --> fork_state7fork_state --> 状态组28fork_state --> 状态组3910note right of 状态组111【状态组1】右边的备注信息,12内容支持换行。13end note14state 状态组1 {15状态11 : 在此填写状态的描述内容16[*] --> 状态11 : <角色:行为><br>Act / 变更处理说明17状态11 --> [*]18}1920note left of 状态组2 : 【状态组2】左边的备注信息21state 状态组2 {22[*] --> 状态21: 状态转换说明23状态21 --> [*]24}2526%% 可以编写注释(以两个英文百分号开头)27state 状态组3 {28[*] --> 状态3129状态31 --> [*]30--31[*] --> 大写【关闭】32大写【关闭】 --> 大写【打开】 : 按一下 CapLock 键33大写【打开】 --> 大写【关闭】 : 按一下 CapLock 键34}3536state join_state <<join>>3738状态组2 --> join_state39状态组3 --> join_state40join_state --> 状态441状态4 --> [*]42```
类图示例 (1)
查看完整画图脚本示例
xxxxxxxxxx321```mermaid2classDiagram3classA <|-- classB : Inheritance<br>继承4classC *-- classD : Composition<br>组合5classE o-- classF : Aggregation<br>聚合6classG "*" <-- "1" classH : Association<br>关联7classI "*" -- classJ : Link (Solid)8classK ..> "n" classL : Dependency<br>依赖9classM <|.. classN : Realization<br>实现10classO .. classP : Link (Dashed)1112class classA~Class~{13<<interface>>14+public attribute15-private attribute16#protected attribute17~package attribute18+public method()19-private method()20#protected method()21~package method()22}2324class classC{25<<enumeration>>26Red27Blue28Green29WHITE30BLACK31}32```
类图示例 (2)
查看完整画图脚本示例
xxxxxxxxxx531```mermaid2classDiagram34人_Person <|-- 学生_Student : Inheritance5人_Person <|-- 老师_Techer : Inheritance6老师_Techer "*" *-- "*" 班级_Class : Composition7班级_Class *-- "*" 学生_Student : Composition8学校_School <.. "*" 老师_Techer : Dependency9学校_School o-- "*" 班级_Class : Composition10学校_School <.. "*" 学生_Student : Dependency1112class 人_Person {13姓名14性别15年龄16}17class 学校_School {18学校名称19所属省份20所属城市21学校类型22}23class 学生_Student {24所属学校25所属班级26学号27+交作业()28}29class 老师_Techer {30所属学校31老师证号32+授课()33}34class 班级_Class {35所属学校36所属年级37班名38}3940公司 o-- "*" 抽象部门 : Composition41抽象部门 <|-- 市场类部门 : Inheritance42市场类部门 <|-- 策划部 : Inheritance43市场类部门 <|-- 销售部 : Inheritance44抽象部门 <|-- 生产类部门 : Inheritance45生产类部门 <|-- 研发部 : Inheritance46生产类部门 <|-- 实施部 : Inheritance47生产类部门 <|-- IT部 : Inheritance48抽象部门 <|-- 支持类部门 : Inheritance49支持类部门 <|-- 质量部 : Inheritance50支持类部门 <|-- 财务部 : Inheritance51支持类部门 <|-- 行政人事部 : Inheritance52支持类部门 <|-- IT部 : Inheritance53```
实体关系图(ER图)
查看完整画图脚本示例
xxxxxxxxxx311```mermaid2---3title: Entity Relationship Diagrams example4---5erDiagram6CUSTOMER["客户"]7ORDER["订单"]8DELIVERY-ADDRESS["收货地址"]910CUSTOMER }|..|{ DELIVERY-ADDRESS : has11CUSTOMER ||--o{ ORDER : places12CUSTOMER ||--o{ INVOICE : "liable for"13DELIVERY-ADDRESS ||--o{ ORDER : receives14INVOICE ||--|{ ORDER : covers15ORDER ||--|{ ORDER-ITEM : includes16PRODUCT-CATEGORY ||--|{ PRODUCT : contains17PRODUCT ||--o{ ORDER-ITEM : "ordered in"1819CAR ||--o{ NAMED-DRIVER : allows20CAR {21string registrationNumber22string make23string model24}25PERSON ||--o{ NAMED-DRIVER : is26PERSON {27string firstName28string lastName29int age30}31```
方块图示例
查看完整画图脚本示例
xxxxxxxxxx161```mermaid2block3columns 14db(("DB"))5blockArrowId6<[" "]>(down)6block:ID7A8B["A wide one in the middle"]9C10end11space12D13ID --> D14C --> D15style B fill:#969,stroke:#333,stroke-width:4px16```
四象限图示例
查看完整画图脚本示例
xxxxxxxxxx161```mermaid2quadrantChart3title Reach and engagement of campaigns4x-axis Low Reach --> High Reach5y-axis Low Engagement --> High Engagement6quadrant-1 We should expand7quadrant-2 Need to promote8quadrant-3 Re-evaluate9quadrant-4 May be improved10Campaign A: [0.3, 0.6]11Campaign B: [0.45, 0.23]12Campaign C: [0.57, 0.69]13Campaign D: [0.78, 0.34]14Campaign E: [0.40, 0.34]15Campaign F: [0.35, 0.78]16```
数据包图示例
查看完整画图脚本示例
xxxxxxxxxx211---2title: "TCP Packet"3---4packet50-15: "Source Port"616-31: "Destination Port"732-63: "Sequence Number"864-95: "Acknowledgment Number"996-99: "Data Offset"10100-105: "Reserved"11106: "URG"12107: "ACK"13108: "PSH"14109: "RST"15110: "SYN"16111: "FIN"17112-127: "Window"18128-143: "Checksum"19144-159: "Urgent Pointer"20160-191: "(Options and Padding)"21192-255: "Data (variable length)"
查看完整画图脚本示例
xxxxxxxxxx301```mermaid2architecture-beta3group api(cloud)[API]45service db(database)[Database] in api6service disk1(disk)[Storage] in api7service disk2(disk)[Storage] in api8service server(server)[Server] in api910db:L -- R:server11disk1:T -- B:server12disk2:T -- B:db131415service left_disk(disk)[Disk]16service top_disk(disk)[Disk]17service bottom_disk(disk)[Disk]18service top_gateway(internet)[Gateway]19service bottom_gateway(internet)[Gateway]20junction junctionCenter21junction junctionRight2223left_disk:R -- L:junctionCenter24top_disk:B -- T:junctionCenter25bottom_disk:T -- B:junctionCenter26junctionCenter:R -- L:junctionRight27top_gateway:B -- T:junctionRight28bottom_gateway:T -- B:junctionRight2930```
ZenUML 图示例 1
ZenUML 图示例 2
思维导图示例
Mindmap
Origins
📓 Long history
Popularisation
British popular psychology author Tony Buzan
Origins 2
Popularisation 2
Research
🍺 On effectiveness
and features
On Automatic
creation
Uses
Creative techniques
Strategic planning
Argument mapping
Research 2
Tools
Pen and paper
Mermaid
Tools 2
Pen and paper 2
Tools 3
查看完整画图脚本示例
xxxxxxxxxx241```mermaid2mindmap3root((Mindmap))4Origins5📓 Long history6Popularisation7(British popular psychology author Tony Buzan)8Origins 29Popularisation 210Research11))🍺 On effectiveness<br>and features((12)On Automatic<br>creation(13Uses14Creative techniques15{{Strategic planning}}16Argument mapping17Research 218Tools19[Pen and paper]20[Mermaid]21Tools 222Pen and paper 223Tools 324```
不建议使用 FontAwesome 图标库特性,除非你独立构建相关资源的环境
Gitgraph 图示例 1
查看完整画图脚本示例
xxxxxxxxxx251```mermaid2---3title: Example Gitgraph diagram4---5gitGraph6commit id: "Alpha" tag: "0.0.1"78commit9branch develop10branch nice_feature11checkout nice_feature12commit id: "Beta"13checkout main14merge nice_feature15checkout develop1617commit id: "Reverse" type: REVERSE18commit1920checkout main21merge develop22commit id: "Hightlgith" type: HIGHLIGHT2324commit id: "Gamma" tag: "RC_1"25```
Gitgraph 图示例 2
查看完整画图脚本示例
xxxxxxxxxx261```mermaid2---3title: Map of MetroLine4---5%%{init: {'mainBranchName': 'MetroLine1'}} }%%6gitGraph7commit id:"NewYork"8commit id:"Dallas"9branch MetroLine210commit id:"LosAngeles"11commit id:"Chicago"12commit id:"Houston"13branch MetroLine314commit id:"Phoenix"15commit type: HIGHLIGHT id:"Denver"16commit id:"Boston"17checkout main18commit id:"Atlanta"19merge MetroLine320commit id:"Miami"21commit id:"Washington"22merge MetroLine2 tag:"MY JUNCTION"23commit id:"Boston"24commit id:"Detroit"25commit type:REVERSE id:"SanFrancisco"26```
Gitgraph 图示例 3
桑基图示例一
查看完整画图脚本示例一
xxxxxxxxxx141```mermaid2sankey34Direct, Visit, 5005Search, Visit, 8006Social, Visit, 4007Ads, Visit, 30089Visit, Register, 90010Visit, Bounce, 11001112Register, Paid, 30013Register, Free, 60014```
桑基图示例二
查看完整画图脚本示例二
xxxxxxxxxx161```mermaid2sankey34Total Sales, Shampoo, 5005Total Sales, Detergent, 3006Total Sales, Skincare, 20078Shampoo, Online, 2009Shampoo, Offline, 3001011Detergent, Online, 10012Detergent, Offline, 2001314Skincare, Online, 15015Skincare, Offline, 5016```
时间线示例
查看完整画图脚本示例
xxxxxxxxxx111```mermaid2timeline3title History of Social Media Platform42002 : LinkedIn52004 : Facebook672005 : Youtube82006 : Twitter92023 : GPT-3.510: GPT-411```
时间线示例(分段)
查看完整画图脚本示例
xxxxxxxxxx111```mermaid2timeline3title Timeline of Industrial Revolution4section 17th-20th century5Industry 1.0 : Machinery, Water power, Steam <br>power6Industry 2.0 : Electricity, Internal combustion engine, Mass production7Industry 3.0 : Electronics, Computers, Automation8section 21st century9Industry 4.0 : Internet, Robotics, Internet of Things10Industry 5.0 : Artificial intelligence, Big data,3D printing11```
时间线示例(二级分类列表)
XY 图示例
查看完整画图脚本示例
xxxxxxxxxx81```mermaid2xychart3title "Sales Revenue"4x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]5y-axis "Revenue (in $)" 4000 --> 110006bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]7line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]8```
Q3 2019 中国线上智能手机市场主要品牌市场份额数据来自:互联网
查看完整画图脚本示例
xxxxxxxxxx101```mermaid2pie title Q3 2019 中国线上智能手机市场主要品牌市场份额3"华为" : 264"荣耀" : 205"小米" : 146"VIVO" : 107"Apple" : 98"OPPO" : 59"其他" : 1610```
查看完整画图脚本示例
xxxxxxxxxx141```mermaid2---3title: "Grades"4---5radar-beta6axis m["Math"], s["Science"], e["English"]7axis h["History"], g["Geography"], a["Art"]8curve a["Alice"]{85, 90, 80, 70, 75, 90}9curve b["Bob"]{70, 75, 85, 80, 90, 85}1011max 10012min 01314```
查看完整画图脚本示例
xxxxxxxxxx121```mermaid2treemap-beta3"Products"4"Electronics"5"Phones": 506"Computers": 307"Accessories": 208"Clothing"9"Men's": 4010"Women's": 401112```
看板图示例
Todo
In progress
Ready for deploy
Ready for test
Done
Can't reproduce
Create Documentation
Create Blog about the new diagram
Create renderer so that it works in all cases. We also add som extra text here for testing purposes. And some more just for the extra flare.
Design grammar
knsv
MC-2038
Create parsing tests
K.Sveidqvist
last item
knsv
define getData
MC-2036
Title of diagram is more than 100 chars when user duplicates diagram with 100 char
MC-2037
Update DB function
knsv
Weird flickering in Firefox
查看完整画图脚本示例
xxxxxxxxxx241---2config:3kanban:4ticketBaseUrl: 'https://mermaidchart.atlassian.net/browse/#TICKET#'5---6kanban7Todo8[Create Documentation]9docs[Create Blog about the new diagram]10[In progress]11id6[Create renderer so that it works in all cases. We also add som extra text here for testing purposes. And some more just for the extra flare.]12id9[Ready for deploy]13id8[Design grammar]@{ assigned: 'knsv' }14id10[Ready for test]15id4[Create parsing tests]@{ ticket: MC-2038, assigned: 'K.Sveidqvist', priority: 'High' }16id66[last item]@{ priority: 'Very Low', assigned: 'knsv' }17id11[Done]18id5[define getData]19id2[Title of diagram is more than 100 chars when user duplicates diagram with 100 char]@{ ticket: MC-2036, priority: 'Very High'}20id3[Update DB function]@{ ticket: MC-2037, assigned: knsv, priority: 'High' }2122id12[Can't reproduce]23id3[Weird flickering in Firefox]24
甘特图示例
查看完整画图脚本示例
xxxxxxxxxx221```mermaid2gantt3dateFormat MM-DD4title 这里显示甘特图标题5%% 排除的日期:monday...saturday, sunday, weekends6excludes weekends78section 区块A9已完成的普通任务 :done, des1, 04-01, 04-0310执行中的普通任务 :active, des2, 04-02, 3d11未来的任务 :des3, after des2, 2d12未来的任务2 :des4, after des3, 2d1314section 区块B15已完成的关键路径任务 :crit, done, 04-06, 24h16已完成的关键路径任务2 :crit, done, after des1, 2d17里程碑 :milestone, after des2, 0d1819section 区块C20执行中的关键路径任务 :crit, active, 3d21未来的关键路径任务 :crit, 2d22```
return early