Skip to content

Commit 148c1ec

Browse files
authoredSep 6, 2021
Added support for Mermaid (#3050)
1 parent 8df825e commit 148c1ec

14 files changed

+2922
-1
lines changed
 

‎components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎components.json

+4
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,10 @@
803803
"title": "MEL",
804804
"owner": "Golmote"
805805
},
806+
"mermaid": {
807+
"title": "Mermaid",
808+
"owner": "RunDevelopment"
809+
},
806810
"mizar": {
807811
"title": "Mizar",
808812
"owner": "Golmote"

‎components/prism-mermaid.js

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
Prism.languages.mermaid = {
2+
'comment': {
3+
pattern: /%%.*/,
4+
greedy: true
5+
},
6+
7+
'style': {
8+
pattern: /^([ \t]*(?:classDef|linkStyle|style)[ \t]+[\w$-]+[ \t]+)\w.*[^\s;]/m,
9+
lookbehind: true,
10+
inside: {
11+
'property': /\b\w[\w-]*(?=[ \t]*:)/,
12+
'operator': /:/,
13+
'punctuation': /,/
14+
}
15+
},
16+
17+
'inter-arrow-label': {
18+
pattern: /([^<>ox.=-])(?:-[-.]|==)(?![<>ox.=-])[ \t]*(?:"[^"\r\n]*"|[^\s".=-](?:[^\r\n.=-]*[^\s.=-])?)[ \t]*(?:\.+->?|--+[->]|==+[=>])(?![<>ox.=-])/,
19+
lookbehind: true,
20+
greedy: true,
21+
inside: {
22+
'arrow': {
23+
pattern: /(?:\.+->?|--+[->]|==+[=>])$/,
24+
alias: 'operator'
25+
},
26+
'label': {
27+
pattern: /^([\s\S]{2}[ \t]*)\S(?:[\s\S]*\S)?/,
28+
lookbehind: true,
29+
alias: 'property'
30+
},
31+
'arrow-head': {
32+
pattern: /^\S+/,
33+
alias: ['arrow', 'operator']
34+
}
35+
}
36+
},
37+
38+
'arrow': [
39+
// This might look complex but it really isn't.
40+
// There are many possible arrows (see tests) and it's impossible to fit all of them into one pattern. The
41+
// problem is that we only have one lookbehind per pattern. However, we cannot disallow too many arrow
42+
// characters in the one lookbehind because that would create too many false negatives. So we have to split the
43+
// arrows into different patterns.
44+
{
45+
// ER diagram
46+
pattern: /(^|[^{}|o.-])[|}][|o](?:--|\.\.)[|o][|{](?![{}|o.-])/,
47+
lookbehind: true,
48+
alias: 'operator'
49+
},
50+
{
51+
// flow chart
52+
// (?:==+|--+|-\.*-)
53+
pattern: /(^|[^<>ox.=-])(?:[<ox](?:==+|--+|-\.*-)[>ox]?|(?:==+|--+|-\.*-)[>ox]|===+|---+|-\.+-)(?![<>ox.=-])/,
54+
lookbehind: true,
55+
alias: 'operator'
56+
},
57+
{
58+
// sequence diagram
59+
pattern: /(^|[^<>()x-])(?:--?(?:>>|[x>)])(?![<>()x])|(?:<<|[x<(])--?(?!-))/,
60+
lookbehind: true,
61+
alias: 'operator'
62+
},
63+
{
64+
// class diagram
65+
pattern: /(^|[^<>|*o.-])(?:[*o]--|--[*o]|<\|?(?:--|\.\.)|(?:--|\.\.)\|?>|--|\.\.)(?![<>|*o.-])/,
66+
lookbehind: true,
67+
alias: 'operator'
68+
},
69+
],
70+
71+
'label': {
72+
pattern: /(^|[^|<])\|(?:[^\r\n"|]|"[^"\r\n]*")+\|/,
73+
lookbehind: true,
74+
greedy: true,
75+
alias: 'property'
76+
},
77+
78+
'text': {
79+
pattern: /(?:[(\[{]+|\b>)(?:[^\r\n"()\[\]{}]|"[^"\r\n]*")+(?:[)\]}]+|>)/,
80+
alias: 'string'
81+
},
82+
'string': {
83+
pattern: /"[^"\r\n]*"/,
84+
greedy: true
85+
},
86+
87+
'annotation': {
88+
pattern: /<<(?:abstract|choice|enumeration|fork|interface|join|service)>>|\[\[(?:choice|fork|join)\]\]/i,
89+
alias: 'important'
90+
},
91+
92+
'keyword': [
93+
// This language has both case-sensitive and case-insensitive keywords
94+
{
95+
pattern: /(^[ \t]*)(?:action|callback|class|classDef|classDiagram|click|direction|erDiagram|flowchart|gantt|gitGraph|graph|journey|link|linkStyle|pie|requirementDiagram|sequenceDiagram|stateDiagram|stateDiagram-v2|style|subgraph)(?![\w$-])/m,
96+
lookbehind: true,
97+
greedy: true
98+
},
99+
{
100+
pattern: /(^[ \t]*)(?:activate|alt|and|as|autonumber|deactivate|else|end(?:[ \t]+note)?|loop|opt|par|participant|rect|state|note[ \t]+(?:over|(?:left|right)[ \t]+of))(?![\w$-])/im,
101+
lookbehind: true,
102+
greedy: true
103+
}
104+
],
105+
106+
'entity': /#[a-z0-9]+;/,
107+
108+
'operator': {
109+
pattern: /(\w[ \t]*)&(?=[ \t]*\w)|:::|:/,
110+
lookbehind: true
111+
},
112+
'punctuation': /[(){};]/
113+
};

‎components/prism-mermaid.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/prism-mermaid.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<h2>Full example</h2>
2+
<pre><code>%% https://github.com/mermaid-js/mermaid/blob/develop/docs/examples.md#larger-flowchart-with-some-styling
3+
4+
graph TB
5+
sq[Square shape] --> ci((Circle shape))
6+
7+
subgraph A
8+
od>Odd shape]-- Two line&lt;br/>edge comment --> ro
9+
di{Diamond with &lt;br/> line break} -.-> ro(Rounded&lt;br>square&lt;br>shape)
10+
di==>ro2(Rounded square shape)
11+
end
12+
13+
%% Notice that no text in shape are added here instead that is appended further down
14+
e --> od3>Really long text with linebreak&lt;br>in an Odd shape]
15+
16+
%% Comments after double percent signs
17+
e((Inner / circle&lt;br>and some odd &lt;br>special characters)) --> f(,.?!+-*ز)
18+
19+
cyr[Cyrillic]-->cyr2((Circle shape Начало));
20+
21+
classDef green fill:#9f6,stroke:#333,stroke-width:2px;
22+
classDef orange fill:#f96,stroke:#333,stroke-width:4px;
23+
class sq,e green
24+
class di orange
25+
</code></pre>
+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
%% flow chart
2+
3+
--- ---- -----
4+
--> ---> ---->
5+
<-- <--- <----
6+
=== ==== =====
7+
==> ===> ====>
8+
<== <=== <====
9+
-.- -..- -...-
10+
-.-> -..-> -...->
11+
<-.- <-..- <-...-
12+
--x ---x ----x
13+
--x -.-x -..-x
14+
x-- x--- x----
15+
x-- x-.- x-..-
16+
--o ---o ----o
17+
--o -.-o -..-o
18+
o-- o--- o----
19+
o-- o-.- o-..-
20+
21+
<--> <----> <-..-> <====>
22+
x--x x----x x-..-x x====x
23+
o--o o----o o-..-o o====o
24+
25+
%% sequence diagram
26+
27+
-> --> ->> -->>
28+
<- <-- <<- <<--
29+
-x --x -) --)
30+
x- x-- (- (--
31+
32+
%% class diagram
33+
34+
<|-- *-- o-- <-- <.. <|..
35+
--|> --* --o --> ..> ..|>
36+
-- ..
37+
38+
%% ER diagram
39+
40+
|o--o| |o..o|
41+
||--|| ||..||
42+
}o--o{ }o..o{
43+
}|--|{ }|..|{
44+
45+
|o--o| |o..o|
46+
||--o{ ||..o{
47+
}o--|{ }o..|{
48+
}|--|| }|..||
49+
50+
----------------------------------------------------
51+
52+
[
53+
["comment", "%% flow chart"],
54+
55+
["arrow", "---"], ["arrow", "----"], ["arrow", "-----"],
56+
["arrow", "-->"], ["arrow", "--->"], ["arrow", "---->"],
57+
["arrow", "<--"], ["arrow", "<---"], ["arrow", "<----"],
58+
["arrow", "==="], ["arrow", "===="], ["arrow", "====="],
59+
["arrow", "==>"], ["arrow", "===>"], ["arrow", "====>"],
60+
["arrow", "<=="], ["arrow", "<==="], ["arrow", "<===="],
61+
["arrow", "-.-"], ["arrow", "-..-"], ["arrow", "-...-"],
62+
["arrow", "-.->"], ["arrow", "-..->"], ["arrow", "-...->"],
63+
["arrow", "<-.-"], ["arrow", "<-..-"], ["arrow", "<-...-"],
64+
["arrow", "--x"], ["arrow", "---x"], ["arrow", "----x"],
65+
["arrow", "--x"], ["arrow", "-.-x"], ["arrow", "-..-x"],
66+
["arrow", "x--"], ["arrow", "x---"], ["arrow", "x----"],
67+
["arrow", "x--"], ["arrow", "x-.-"], ["arrow", "x-..-"],
68+
["arrow", "--o"], ["arrow", "---o"], ["arrow", "----o"],
69+
["arrow", "--o"], ["arrow", "-.-o"], ["arrow", "-..-o"],
70+
["arrow", "o--"], ["arrow", "o---"], ["arrow", "o----"],
71+
["arrow", "o--"], ["arrow", "o-.-"], ["arrow", "o-..-"],
72+
73+
["arrow", "<-->"],
74+
["arrow", "<---->"],
75+
["arrow", "<-..->"],
76+
["arrow", "<====>"],
77+
78+
["arrow", "x--x"],
79+
["arrow", "x----x"],
80+
["arrow", "x-..-x"],
81+
["arrow", "x====x"],
82+
83+
["arrow", "o--o"],
84+
["arrow", "o----o"],
85+
["arrow", "o-..-o"],
86+
["arrow", "o====o"],
87+
88+
["comment", "%% sequence diagram"],
89+
90+
["arrow", "->"], ["arrow", "-->"], ["arrow", "->>"], ["arrow", "-->>"],
91+
["arrow", "<-"], ["arrow", "<--"], ["arrow", "<<-"], ["arrow", "<<--"],
92+
["arrow", "-x"], ["arrow", "--x"], ["arrow", "-)"], ["arrow", "--)"],
93+
["arrow", "x-"], ["arrow", "x--"], ["arrow", "(-"], ["arrow", "(--"],
94+
95+
["comment", "%% class diagram"],
96+
97+
["arrow", "<|--"],
98+
["arrow", "*--"],
99+
["arrow", "o--"],
100+
["arrow", "<--"],
101+
["arrow", "<.."],
102+
["arrow", "<|.."],
103+
104+
["arrow", "--|>"],
105+
["arrow", "--*"],
106+
["arrow", "--o"],
107+
["arrow", "-->"],
108+
["arrow", "..>"],
109+
["arrow", "..|>"],
110+
111+
["arrow", "--"],
112+
["arrow", ".."],
113+
114+
["comment", "%% ER diagram"],
115+
116+
["arrow", "|o--o|"], ["arrow", "|o..o|"],
117+
["arrow", "||--||"], ["arrow", "||..||"],
118+
["arrow", "}o--o{"], ["arrow", "}o..o{"],
119+
["arrow", "}|--|{"], ["arrow", "}|..|{"],
120+
121+
["arrow", "|o--o|"], ["arrow", "|o..o|"],
122+
["arrow", "||--o{"], ["arrow", "||..o{"],
123+
["arrow", "}o--|{"], ["arrow", "}o..|{"],
124+
["arrow", "}|--||"], ["arrow", "}|..||"]
125+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
%% comment
2+
3+
----------------------------------------------------
4+
5+
[
6+
["comment", "%% comment"]
7+
]

‎tests/languages/mermaid/full_classdiagram.test

+656
Large diffs are not rendered by default.
+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
erDiagram
2+
CUSTOMER ||--o{ ORDER : places
3+
ORDER ||--|{ LINE-ITEM : contains
4+
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
5+
6+
erDiagram
7+
CUSTOMER ||--o{ ORDER : places
8+
CUSTOMER {
9+
string name
10+
string custNumber
11+
string sector
12+
}
13+
ORDER ||--|{ LINE-ITEM : contains
14+
ORDER {
15+
int orderNumber
16+
string deliveryAddress
17+
}
18+
LINE-ITEM {
19+
string productCode
20+
int quantity
21+
float pricePerUnit
22+
}
23+
24+
PROPERTY ||--|{ ROOM : contains
25+
26+
CAR ||--o{ NAMED-DRIVER : allows
27+
PERSON ||--o{ NAMED-DRIVER : is
28+
29+
erDiagram
30+
CAR ||--o{ NAMED-DRIVER : allows
31+
CAR {
32+
string registrationNumber
33+
string make
34+
string model
35+
}
36+
PERSON ||--o{ NAMED-DRIVER : is
37+
PERSON {
38+
string firstName
39+
string lastName
40+
int age
41+
}
42+
43+
erDiagram
44+
CAR ||--o{ NAMED-DRIVER : allows
45+
CAR {
46+
string registrationNumber
47+
string make
48+
string model
49+
}
50+
PERSON ||--o{ NAMED-DRIVER : is
51+
PERSON {
52+
string firstName
53+
string lastName
54+
int age
55+
}
56+
57+
----------------------------------------------------
58+
59+
[
60+
["keyword", "erDiagram"],
61+
62+
"\r\n CUSTOMER ",
63+
["arrow", "||--o{"],
64+
" ORDER ",
65+
["operator", ":"],
66+
" places\r\n ORDER ",
67+
["arrow", "||--|{"],
68+
" LINE-ITEM ",
69+
["operator", ":"],
70+
" contains\r\n CUSTOMER ",
71+
["arrow", "}|..|{"],
72+
" DELIVERY-ADDRESS ",
73+
["operator", ":"],
74+
" uses\r\n\r\n",
75+
76+
["keyword", "erDiagram"],
77+
78+
"\r\n CUSTOMER ",
79+
["arrow", "||--o{"],
80+
" ORDER ",
81+
["operator", ":"],
82+
" places\r\n CUSTOMER ",
83+
["punctuation", "{"],
84+
85+
"\r\n string name\r\n string custNumber\r\n string sector\r\n ",
86+
87+
["punctuation", "}"],
88+
89+
"\r\n ORDER ",
90+
["arrow", "||--|{"],
91+
" LINE-ITEM ",
92+
["operator", ":"],
93+
" contains\r\n ORDER ",
94+
["punctuation", "{"],
95+
96+
"\r\n int orderNumber\r\n string deliveryAddress\r\n ",
97+
98+
["punctuation", "}"],
99+
100+
"\r\n LINE-ITEM ",
101+
["punctuation", "{"],
102+
103+
"\r\n string productCode\r\n int quantity\r\n float pricePerUnit\r\n ",
104+
105+
["punctuation", "}"],
106+
107+
"\r\n\r\nPROPERTY ",
108+
["arrow", "||--|{"],
109+
" ROOM ",
110+
["operator", ":"],
111+
" contains\r\n\r\nCAR ",
112+
["arrow", "||--o{"],
113+
" NAMED-DRIVER ",
114+
["operator", ":"],
115+
" allows\r\n PERSON ",
116+
["arrow", "||--o{"],
117+
" NAMED-DRIVER ",
118+
["operator", ":"],
119+
" is\r\n\r\n",
120+
121+
["keyword", "erDiagram"],
122+
123+
"\r\n CAR ",
124+
["arrow", "||--o{"],
125+
" NAMED-DRIVER ",
126+
["operator", ":"],
127+
" allows\r\n CAR ",
128+
["punctuation", "{"],
129+
130+
"\r\n string registrationNumber\r\n string make\r\n string model\r\n ",
131+
132+
["punctuation", "}"],
133+
134+
"\r\n PERSON ",
135+
["arrow", "||--o{"],
136+
" NAMED-DRIVER ",
137+
["operator", ":"],
138+
" is\r\n PERSON ",
139+
["punctuation", "{"],
140+
141+
"\r\n string firstName\r\n string lastName\r\n int age\r\n ",
142+
143+
["punctuation", "}"],
144+
145+
["keyword", "erDiagram"],
146+
147+
"\r\n CAR ",
148+
["arrow", "||--o{"],
149+
" NAMED-DRIVER ",
150+
["operator", ":"],
151+
" allows\r\n CAR ",
152+
["punctuation", "{"],
153+
154+
"\r\n string registrationNumber\r\n string make\r\n string model\r\n ",
155+
156+
["punctuation", "}"],
157+
158+
"\r\n PERSON ",
159+
["arrow", "||--o{"],
160+
" NAMED-DRIVER ",
161+
["operator", ":"],
162+
" is\r\n PERSON ",
163+
["punctuation", "{"],
164+
165+
"\r\n string firstName\r\n string lastName\r\n int age\r\n ",
166+
167+
["punctuation", "}"]
168+
]

‎tests/languages/mermaid/full_flowchart.test

+930
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,389 @@
1+
sequenceDiagram
2+
Alice->>John: Hello John, how are you?
3+
John-->>Alice: Great!
4+
Alice-)John: See you later!
5+
6+
sequenceDiagram
7+
participant John
8+
participant Alice
9+
Alice->>John: Hello John, how are you?
10+
John-->>Alice: Great!
11+
12+
sequenceDiagram
13+
participant A as Alice
14+
participant J as John
15+
A->>J: Hello John, how are you?
16+
J->>A: Great!
17+
18+
[Actor][Arrow][Actor]:Message text
19+
20+
sequenceDiagram
21+
Alice->>John: Hello John, how are you?
22+
activate John
23+
John-->>Alice: Great!
24+
deactivate John
25+
26+
sequenceDiagram
27+
Alice->>+John: Hello John, how are you?
28+
John-->>-Alice: Great!
29+
30+
sequenceDiagram
31+
Alice->>+John: Hello John, how are you?
32+
Alice->>+John: John, can you hear me?
33+
John-->>-Alice: Hi Alice, I can hear you!
34+
John-->>-Alice: I feel great!
35+
36+
sequenceDiagram
37+
participant John
38+
Note right of John: Text in note
39+
40+
sequenceDiagram
41+
Alice->John: Hello John, how are you?
42+
Note over Alice,John: A typical interaction
43+
44+
loop Loop text
45+
... statements ...
46+
end
47+
48+
sequenceDiagram
49+
Alice->John: Hello John, how are you?
50+
loop Every minute
51+
John-->Alice: Great!
52+
end
53+
54+
alt Describing text
55+
... statements ...
56+
else
57+
... statements ...
58+
end
59+
60+
opt Describing text
61+
... statements ...
62+
end
63+
64+
sequenceDiagram
65+
Alice->>Bob: Hello Bob, how are you?
66+
alt is sick
67+
Bob->>Alice: Not so good :(
68+
else is well
69+
Bob->>Alice: Feeling fresh like a daisy
70+
end
71+
opt Extra response
72+
Bob->>Alice: Thanks for asking
73+
end
74+
75+
par [Action 1]
76+
... statements ...
77+
and [Action 2]
78+
... statements ...
79+
and [Action N]
80+
... statements ...
81+
end
82+
83+
rect rgb(0, 255, 0)
84+
... content ...
85+
end
86+
87+
rect rgba(0, 0, 255, .1)
88+
... content ...
89+
end
90+
91+
sequenceDiagram
92+
Alice->>John: Hello John, how are you?
93+
%% this is a comment
94+
John-->>Alice: Great!
95+
96+
sequenceDiagram
97+
A->>B: I #9829; you!
98+
B->>A: I #9829; you #infin; times more!
99+
100+
sequenceDiagram
101+
autonumber
102+
Alice->>John: Hello John, how are you?
103+
loop Healthcheck
104+
John->>John: Fight against hypochondria
105+
end
106+
Note right of John: Rational thoughts!
107+
John-->>Alice: Great!
108+
John->>Bob: How about you?
109+
Bob-->>John: Jolly good!
110+
111+
----------------------------------------------------
112+
113+
[
114+
["keyword", "sequenceDiagram"],
115+
116+
"\r\n Alice",
117+
["arrow", "->>"],
118+
"John",
119+
["operator", ":"],
120+
" Hello John, how are you?\r\n John",
121+
["arrow", "-->>"],
122+
"Alice",
123+
["operator", ":"],
124+
" Great!\r\n Alice",
125+
["arrow", "-)"],
126+
"John",
127+
["operator", ":"],
128+
" See you later!\r\n\r\n",
129+
130+
["keyword", "sequenceDiagram"],
131+
132+
["keyword", "participant"],
133+
" John\r\n ",
134+
135+
["keyword", "participant"],
136+
" Alice\r\n Alice",
137+
["arrow", "->>"],
138+
"John",
139+
["operator", ":"],
140+
" Hello John, how are you?\r\n John",
141+
["arrow", "-->>"],
142+
"Alice",
143+
["operator", ":"],
144+
" Great!\r\n\r\n",
145+
146+
["keyword", "sequenceDiagram"],
147+
148+
["keyword", "participant"],
149+
" A as Alice\r\n ",
150+
151+
["keyword", "participant"],
152+
" J as John\r\n A",
153+
["arrow", "->>"],
154+
"J",
155+
["operator", ":"],
156+
" Hello John, how are you?\r\n J",
157+
["arrow", "->>"],
158+
"A",
159+
["operator", ":"],
160+
" Great!\r\n\r\n",
161+
162+
["text", "[Actor]"],
163+
["text", "[Arrow]"],
164+
["text", "[Actor]"],
165+
["operator", ":"],
166+
"Message text\r\n\r\n",
167+
168+
["keyword", "sequenceDiagram"],
169+
170+
"\r\n Alice",
171+
["arrow", "->>"],
172+
"John",
173+
["operator", ":"],
174+
" Hello John, how are you?\r\n ",
175+
176+
["keyword", "activate"],
177+
" John\r\n John",
178+
["arrow", "-->>"],
179+
"Alice",
180+
["operator", ":"],
181+
" Great!\r\n ",
182+
183+
["keyword", "deactivate"],
184+
" John\r\n\r\n",
185+
186+
["keyword", "sequenceDiagram"],
187+
188+
"\r\n Alice",
189+
["arrow", "->>"],
190+
"+John",
191+
["operator", ":"],
192+
" Hello John, how are you?\r\n John",
193+
["arrow", "-->>"],
194+
"-Alice",
195+
["operator", ":"],
196+
" Great!\r\n\r\n",
197+
198+
["keyword", "sequenceDiagram"],
199+
200+
"\r\n Alice",
201+
["arrow", "->>"],
202+
"+John",
203+
["operator", ":"],
204+
" Hello John, how are you?\r\n Alice",
205+
["arrow", "->>"],
206+
"+John",
207+
["operator", ":"],
208+
" John, can you hear me?\r\n John",
209+
["arrow", "-->>"],
210+
"-Alice",
211+
["operator", ":"],
212+
" Hi Alice, I can hear you!\r\n John",
213+
["arrow", "-->>"],
214+
"-Alice",
215+
["operator", ":"],
216+
" I feel great!\r\n\r\n",
217+
218+
["keyword", "sequenceDiagram"],
219+
220+
["keyword", "participant"],
221+
" John\r\n ",
222+
223+
["keyword", "Note right of"],
224+
" John",
225+
["operator", ":"],
226+
" Text in note\r\n\r\n",
227+
228+
["keyword", "sequenceDiagram"],
229+
230+
"\r\n Alice",
231+
["arrow", "->"],
232+
"John",
233+
["operator", ":"],
234+
" Hello John, how are you?\r\n ",
235+
236+
["keyword", "Note over"],
237+
" Alice,John",
238+
["operator", ":"],
239+
" A typical interaction\r\n\r\n",
240+
241+
["keyword", "loop"], " Loop text\r\n... statements ...\r\n",
242+
["keyword", "end"],
243+
244+
["keyword", "sequenceDiagram"],
245+
246+
"\r\n Alice",
247+
["arrow", "->"],
248+
"John",
249+
["operator", ":"],
250+
" Hello John, how are you?\r\n ",
251+
252+
["keyword", "loop"],
253+
" Every minute\r\n John",
254+
["arrow", "-->"],
255+
"Alice",
256+
["operator", ":"],
257+
" Great!\r\n ",
258+
259+
["keyword", "end"],
260+
261+
["keyword", "alt"], " Describing text\r\n... statements ...\r\n",
262+
["keyword", "else"],
263+
"\r\n... statements ...\r\n",
264+
["keyword", "end"],
265+
266+
["keyword", "opt"], " Describing text\r\n... statements ...\r\n",
267+
["keyword", "end"],
268+
269+
["keyword", "sequenceDiagram"],
270+
271+
"\r\n Alice",
272+
["arrow", "->>"],
273+
"Bob",
274+
["operator", ":"],
275+
" Hello Bob, how are you?\r\n ",
276+
277+
["keyword", "alt"],
278+
" is sick\r\n Bob",
279+
["arrow", "->>"],
280+
"Alice",
281+
["operator", ":"],
282+
" Not so good ",
283+
["operator", ":"],
284+
["punctuation", "("],
285+
286+
["keyword", "else"],
287+
" is well\r\n Bob",
288+
["arrow", "->>"],
289+
"Alice",
290+
["operator", ":"],
291+
" Feeling fresh like a daisy\r\n ",
292+
293+
["keyword", "end"],
294+
295+
["keyword", "opt"],
296+
" Extra response\r\n Bob",
297+
["arrow", "->>"],
298+
"Alice",
299+
["operator", ":"],
300+
" Thanks for asking\r\n ",
301+
302+
["keyword", "end"],
303+
304+
["keyword", "par"], ["text", "[Action 1]"],
305+
"\r\n... statements ...\r\n",
306+
["keyword", "and"], ["text", "[Action 2]"],
307+
"\r\n... statements ...\r\n",
308+
["keyword", "and"], ["text", "[Action N]"],
309+
"\r\n... statements ...\r\n",
310+
["keyword", "end"],
311+
312+
["keyword", "rect"], " rgb", ["text", "(0, 255, 0)"],
313+
"\r\n... content ...\r\n",
314+
["keyword", "end"],
315+
316+
["keyword", "rect"], " rgba", ["text", "(0, 0, 255, .1)"],
317+
"\r\n... content ...\r\n",
318+
["keyword", "end"],
319+
320+
["keyword", "sequenceDiagram"],
321+
322+
"\r\n Alice",
323+
["arrow", "->>"],
324+
"John",
325+
["operator", ":"],
326+
" Hello John, how are you?\r\n ",
327+
328+
["comment", "%% this is a comment"],
329+
330+
"\r\n John",
331+
["arrow", "-->>"],
332+
"Alice",
333+
["operator", ":"],
334+
" Great!\r\n\r\n",
335+
336+
["keyword", "sequenceDiagram"],
337+
338+
"\r\n A",
339+
["arrow", "->>"],
340+
"B",
341+
["operator", ":"],
342+
" I ",
343+
["entity", "#9829;"],
344+
" you!\r\n B",
345+
["arrow", "->>"],
346+
"A",
347+
["operator", ":"],
348+
" I ",
349+
["entity", "#9829;"],
350+
" you ",
351+
["entity", "#infin;"],
352+
" times more!\r\n\r\n",
353+
354+
["keyword", "sequenceDiagram"],
355+
356+
["keyword", "autonumber"],
357+
358+
"\r\n Alice",
359+
["arrow", "->>"],
360+
"John",
361+
["operator", ":"],
362+
" Hello John, how are you?\r\n ",
363+
364+
["keyword", "loop"],
365+
" Healthcheck\r\n John",
366+
["arrow", "->>"],
367+
"John",
368+
["operator", ":"],
369+
" Fight against hypochondria\r\n ",
370+
371+
["keyword", "end"],
372+
373+
["keyword", "Note right of"],
374+
" John",
375+
["operator", ":"],
376+
" Rational thoughts!\r\n John",
377+
["arrow", "-->>"],
378+
"Alice",
379+
["operator", ":"],
380+
" Great!\r\n John",
381+
["arrow", "->>"],
382+
"Bob",
383+
["operator", ":"],
384+
" How about you?\r\n Bob",
385+
["arrow", "-->>"],
386+
"John",
387+
["operator", ":"],
388+
" Jolly good!"
389+
]

‎tests/languages/mermaid/full_statediagram.test

+430
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
A -.s .- C
2+
A -. s .- C
3+
A -. "asdasd" .- C
4+
A -- "asdasd" --> C
5+
A -- "asdasd" --> C
6+
A -- "asdasd" .- C
7+
A -- "asdasd" === C
8+
A -- "asdasd" ==> C
9+
10+
----------------------------------------------------
11+
12+
[
13+
"A ",
14+
["inter-arrow-label", [
15+
["arrow-head", "-."],
16+
["label", "s"],
17+
["arrow", ".-"]
18+
]],
19+
" C\r\nA ",
20+
["inter-arrow-label", [
21+
["arrow-head", "-."],
22+
["label", "s"],
23+
["arrow", ".-"]
24+
]],
25+
" C\r\nA ",
26+
["inter-arrow-label", [
27+
["arrow-head", "-."],
28+
["label", "\"asdasd\""],
29+
["arrow", ".-"]
30+
]],
31+
" C\r\nA ",
32+
["inter-arrow-label", [
33+
["arrow-head", "--"],
34+
["label", "\"asdasd\""],
35+
["arrow", "-->"]
36+
]],
37+
" C\r\nA ",
38+
["inter-arrow-label", [
39+
["arrow-head", "--"],
40+
["label", "\"asdasd\""],
41+
["arrow", "-->"]
42+
]],
43+
" C\r\nA ",
44+
["inter-arrow-label", [
45+
["arrow-head", "--"],
46+
["label", "\"asdasd\""],
47+
["arrow", ".-"]
48+
]],
49+
" C\r\nA ",
50+
["inter-arrow-label", [
51+
["arrow-head", "--"],
52+
["label", "\"asdasd\""],
53+
["arrow", "==="]
54+
]],
55+
" C\r\nA ",
56+
["inter-arrow-label", [
57+
["arrow-head", "--"],
58+
["label", "\"asdasd\""],
59+
["arrow", "==>"]
60+
]],
61+
" C"
62+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A & B
2+
3+
: :::
4+
5+
----------------------------------------------------
6+
7+
[
8+
"A ", ["operator", "&"], " B\r\n\r\n",
9+
10+
["operator", ":"], ["operator", ":::"]
11+
]

0 commit comments

Comments
 (0)
Please sign in to comment.