地址

markdown 中流程图语法及示例

语法结构

  1. 定义节点
  2. 连接节点
  3. 样式调整(可选)

7种节点

  • 开始(椭圆形):start
  • 结束(椭圆形):end
  • 操作(矩形):operation
  • 多输出操作(矩形):parallel
  • 条件判断(菱形):condition
  • 输入输出(平行四边形):inputoutput
  • 预处理/子程序(圣旨形):subroutine

节点定义

变量名=>节点标识: 节点显示名

节点连线

变量名1->变量名2->…->变量名n

连线样式

设置变量m和变量n之间连线的样式,具体样式由变量n后面key-value控制,需要两个变量之间有直接连线。语法中的连接符为(@>)。

变量名m@>变量名n({“key”:”value”})

关键字

  • yes/true:condition类型变量连接时,用于分别表示yes条件的流向
  • no/false:同上,表示否定条件的流向
  • left/right:表示连线出口在节点位置(默认下面是出口,如op3),可以跟condition变量一起用:cond(yes,right)
  • path1/path2/path3:parallel变量的三个出口路径(默认下面是出口)

节点状态

为节点设置不同的状态,可以通过不同的颜色显示,其中状态包括下面6个,含义如英文所示,不过CSDN中好像目前还不支持:

  • past
  • current
  • future
  • approved
  • rejected
  • invalid

示例一

1
2
3
4
5
6
7
8
9
10
11
12
13
14
st=>start: Start
e=>end: End
op1=>operation: My Operation
op2=>operation: Stuff|current
sub1=>subroutine: My Subroutine
cond=>condition: Yes or No?
c2=>condition: Good idea
io=>inputoutput: catch something...

st->op1(right)->cond
cond(yes, right)->c2
cond(no)->sub1(left)->op1
c2(yes)->io->e
c2(no)->op2->e

示例二

1
2
3
4
5
6
7
8
9
st=>start: Start
e=>end: End
cond=>condition: Option
op1=>operation: solution_1
op2=>operation: solution_2

st->cond
cond(yes)->op1->e
cond(no)->op2->e

示例三

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
st=>start: Start
e=>end: End
cloud_type=>condition: server or domain?
req_server=>operation: request server API
req_domain=>operation: request domain API
req_contact=>operation: requst contact API
get_config=>operation: get config
mk_dct=>operation: make cloud contact dict
send_mail=>operation: send mail

st->cloud_type
cloud_type(yes, right)->req_server
cloud_type(no)->req_domain
req_server->get_config
req_domain->get_config
get_config->req_contact
req_contact->mk_dct
mk_dct->send_mail
mk_dct->e