Mermaid 语法格式解读

985 阅读3分钟

mermaid节点

---  
title: Node  
---  
flowchart LR  
    id  
    id1[This is the text  in the box]  
    id1[This is the text <BR/> in the \n box asdas ]  
    markdown["`This **is** _Markdown_`"]  
   
newLines["`Line1  
    Line 2  
    Line 3`"]  
  
 id3[This is the tas as a asd a asd da fsfsdf in the \n box asdas ]
---  
title: Node  
---  
flowchart LR  
    id  
    id1[This is the text  in the box]  
    id1[This is the text <BR/> in the \n box asdas ]  
    markdown["`This **is** _Markdown_`"]  
   
newLines["`Line1  
    Line 2  
    Line 3`"]  
  
 id3[This is the tas as a asd a asd da fsfsdf in the \n box asdas ]
  • Title: 字段是流程图的标题(可以省略)
  • flowchart LR: 代表开始画流程图与 (LR代表方向 具体的下文会讲到)
  • id : 代表画流程的节点 (id 其实就是 流程图节点的ID 唯一字段 )

节点内容

  • id : 代表画流程的节点 (id 其实就是 流程图节点的ID 唯一字段 )

    • 如果有[] []的内容代表 节点的内容 没有[] 使用前面的id 来表示节点的内容 默认为矩形
    • 如果节点id 重复 则后者内容覆盖前者内容
    • 节点内容支持换行和md格式

    • 可以支持换行 \n 不支持换行
    • 节点最大宽度200 超出了mermaid会自动换行

节点形状

flowchart LR  
    Start1  
    Start[asdasd]  
    id1(This is the text in the box)  
    id2([This is the text in the box])  
  id3((This is the text in the circle))  
   id4{This is the text in the box}
flowchart LR  
    Start1  
    Start[asdasd]  
    id1(This is the text in the box)  
    id2([This is the text in the box])  
  id3((This is the text in the circle))  
   id4{This is the text in the box}

  • 节点中 有括号的 代表形状

  • 没有括号 默认为矩形

  • [] 矩形

  • () 圆角矩形

  • ([]) 圆角角度100% 矩形

  • (()) 园

  • {} 菱形

线的方向

flowchart TB   
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2
flowchart TB   
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2
  • TB - Top to bottom (从顶部到底部)

    •   新建节点 就是 在顶部新建 往左边排列 连接线的方向 都是从上往下

flowchart TD  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2
flowchart TD  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2
  • TD - Top-down/ same as top to bottom(类似从顶部到底部)
flowchart BT  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2

flowchart BT  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2

  • BT - Bottom to top(底部到顶部)

  • 解释:线的方向都是从下到上 新建节点 在底部新建 从右到左依次排列

flowchart RL  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2

flowchart RL  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2

  • RL - Right to left(从右到左边))

  • 解释:线的方向都是从左边往右 新建节点 在底部新建 从上到下依次排列

flowchart LR  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2

flowchart LR  
    Start --> Stop  
    Start1 --> Stop  
    Start2 --> Stop2

  • LR - Left to right(从左到右边)
  • 解释:线的方向都是从右边往左边 新建节点 在底部新建 从上到下依次排列

线的解读

flowchart LR  
    A-dsa-B  
    A1----asda---B1  
    A1 --- B  
    A2-- This is the text! ---B2  
   A3 ---|This is the text|B3  
   A4 ------->|This is the text|B4   
   A5 --asd-->B5  
   A6 -- text --> B7 -- text2 --> C8

flowchart LR  
    A-dsa-B  
    A1----asda---B1  
    A1 --- B  
    A2-- This is the text! ---B2  
   A3 ---|This is the text|B3  
   A4 ------->|This is the text|B4   
   A5 --asd-->B5  
   A6 -- text --> B7 -- text2 --> C8

解释

A---B 节点A指向B

写法:

  • ---- 或者 --->
  • ----横杠越多 代表线越长
  • 可以连接着写 A -- text --> B -- text2 --> C 从A到B到C

虚线和实线

暂时无法在飞书文档外展示此内容

  • A--->B; 代表实线

  • A-. text .-> B 中间有点代表虚线

  • A =====> B 代表线加粗

线上的内容

  • A2-- This is the text! ---B2 可以写在中间

  • A3 ---|This is the text|B3 可以写在终点节点的 前面 --- 的后面 要用|| 包括

  • A-->B 横杠最短两条线 A-asuid->B这样不对 A5 --asd-->B5

如果要用AI生成 线的生成结构最好统一 用一种语法

节点分组

flowchart TB  
    c1-->a2  
    subgraph one  
    a1-->a2  
    end  
    subgraph two  
    b1-->b2  
    end  
    subgraph three  
    c1-->c2  
    end

flowchart TB  
    c1-->a2  
    subgraph one  
    a1-->a2  
    end  
    subgraph two  
    b1-->b2  
    end  
    subgraph three  
    c1-->c2  
    end

  • subgraph three end 相当于对subgraph end之间的的节点分组 分组名字three
flowchart TB  
    c1-->a2  
    subgraph ide1 [one]  
    a1-->a2  
    end
flowchart TB  
    c1-->a2  
    subgraph ide1 [one]  
    a1-->a2  
    end
  • 也可以单独 使用[] 符号来说明 分组名字

总结

  • A[阐明VAL竞争性结合Vimentin调控Trim16介导泛素化的分子机制]--AHUIFAHF-->B(VAL-Vimentin结合位点)

解释 从A节点到B节点 A的形状为矩形 B的形状为圆角矩形 线上的内容AHUIFAHF

暂时无法在飞书文档外展示此内容