@mermanjs/tree-sitter-mermaid 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CMakeLists.txt +44 -0
  2. package/LICENSE +22 -0
  3. package/Makefile +80 -0
  4. package/README.md +201 -0
  5. package/THIRD_PARTY_LICENSES/mermaid/LICENSE +21 -0
  6. package/THIRD_PARTY_LICENSES/monaqa-tree-sitter-mermaid/LICENSE +21 -0
  7. package/THIRD_PARTY_LICENSES/pappasam-tree-sitter-mermaid/LICENSE +21 -0
  8. package/THIRD_PARTY_LICENSES/singularity-tree-sitter-mermaid/LICENSE +22 -0
  9. package/THIRD_PARTY_LICENSES/tree-sitter/LICENSE +21 -0
  10. package/THIRD_PARTY_LICENSES/zenuml-core/LICENSE +21 -0
  11. package/THIRD_PARTY_NOTICES.md +47 -0
  12. package/binding.gyp +56 -0
  13. package/bindings/c/tree-sitter-mermaid.pc.in +10 -0
  14. package/bindings/c/tree_sitter/tree-sitter-mermaid.h +16 -0
  15. package/bindings/node/binding.cc +25 -0
  16. package/bindings/node/index.d.ts +5 -0
  17. package/bindings/node/index.js +10 -0
  18. package/grammar/families/architecture.js +361 -0
  19. package/grammar/families/block.js +370 -0
  20. package/grammar/families/c4.js +394 -0
  21. package/grammar/families/class.js +441 -0
  22. package/grammar/families/cynefin.js +127 -0
  23. package/grammar/families/entity-relationship.js +408 -0
  24. package/grammar/families/event-modeling.js +307 -0
  25. package/grammar/families/flowchart.js +690 -0
  26. package/grammar/families/gantt.js +445 -0
  27. package/grammar/families/git-graph.js +326 -0
  28. package/grammar/families/info.js +77 -0
  29. package/grammar/families/ishikawa.js +103 -0
  30. package/grammar/families/journey.js +221 -0
  31. package/grammar/families/kanban.js +264 -0
  32. package/grammar/families/mindmap.js +221 -0
  33. package/grammar/families/packet.js +108 -0
  34. package/grammar/families/pie.js +118 -0
  35. package/grammar/families/quadrant-chart.js +385 -0
  36. package/grammar/families/radar.js +286 -0
  37. package/grammar/families/railroad-abnf.js +124 -0
  38. package/grammar/families/railroad-ebnf.js +179 -0
  39. package/grammar/families/railroad-peg.js +128 -0
  40. package/grammar/families/railroad-shared.js +114 -0
  41. package/grammar/families/railroad.js +143 -0
  42. package/grammar/families/requirement.js +475 -0
  43. package/grammar/families/sankey.js +139 -0
  44. package/grammar/families/sequence.js +437 -0
  45. package/grammar/families/state.js +400 -0
  46. package/grammar/families/swimlane.js +25 -0
  47. package/grammar/families/timeline.js +251 -0
  48. package/grammar/families/tree-view.js +189 -0
  49. package/grammar/families/treemap.js +146 -0
  50. package/grammar/families/venn.js +256 -0
  51. package/grammar/families/wardley.js +530 -0
  52. package/grammar/families/xy-chart.js +460 -0
  53. package/grammar/families/zenuml.js +725 -0
  54. package/grammar/shared/common.js +78 -0
  55. package/grammar/shared/header.js +16 -0
  56. package/grammar/shared/indentation.js +22 -0
  57. package/grammar/shared/langium.js +166 -0
  58. package/grammar/shared/preamble.js +26 -0
  59. package/grammar.js +188 -0
  60. package/metadata/derivations.json +519 -0
  61. package/metadata/provenance.json +98 -0
  62. package/package.json +107 -0
  63. package/prebuilds/darwin-arm64/@mermanjs+tree-sitter-mermaid.node +0 -0
  64. package/prebuilds/darwin-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
  65. package/prebuilds/linux-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
  66. package/prebuilds/win32-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
  67. package/queries/helix/highlights.scm +960 -0
  68. package/queries/helix/indents.scm +45 -0
  69. package/queries/helix/injections.scm +15 -0
  70. package/queries/helix/locals.scm +134 -0
  71. package/queries/helix/textobjects.scm +264 -0
  72. package/queries/neovim/README.md +28 -0
  73. package/queries/neovim/brackets.scm +65 -0
  74. package/queries/neovim/folds.scm +53 -0
  75. package/queries/neovim/highlights.scm +121 -0
  76. package/queries/neovim/indents.scm +110 -0
  77. package/queries/neovim/injections.scm +86 -0
  78. package/queries/neovim/locals.scm +277 -0
  79. package/queries/neovim/outline.scm +117 -0
  80. package/queries/neovim/tags.scm +149 -0
  81. package/queries/neovim/textobjects.scm +97 -0
  82. package/queries/portable/highlights.scm +961 -0
  83. package/queries/portable/injections.scm +45 -0
  84. package/queries/portable/locals.scm +290 -0
  85. package/queries/portable/tags.scm +182 -0
  86. package/queries/zed/README.md +48 -0
  87. package/queries/zed/brackets.scm +111 -0
  88. package/queries/zed/highlights.scm +961 -0
  89. package/queries/zed/indents.scm +111 -0
  90. package/queries/zed/injections.scm +11 -0
  91. package/queries/zed/outline.scm +167 -0
  92. package/queries/zed/textobjects.scm +68 -0
  93. package/src/grammar.json +71138 -0
  94. package/src/node-types.json +34871 -0
  95. package/src/parser.c +321353 -0
  96. package/src/scanner.c +462 -0
  97. package/src/tree_sitter/alloc.h +54 -0
  98. package/src/tree_sitter/array.h +336 -0
  99. package/src/tree_sitter/parser.h +286 -0
  100. package/tree-sitter-mermaid.wasm +0 -0
  101. package/tree-sitter.json +40 -0
@@ -0,0 +1,221 @@
1
+ // Source translation: Mermaid 11.16.1
2
+ // packages/mermaid/src/diagrams/user-journey/parser/journey.jison and
3
+ // packages/mermaid/src/diagrams/user-journey/journeyDb.js
4
+ // commit 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf.
5
+
6
+ const diagramKeyword = ($) => field(
7
+ 'keyword',
8
+ alias(token(prec(20, /journey/i)), $.diagram_keyword),
9
+ );
10
+
11
+ const statementKeyword = ($, keyword) => field(
12
+ 'keyword',
13
+ alias(token(prec(20, keyword)), $.statement_keyword),
14
+ );
15
+
16
+ const trailingTrivia = ($) => optional(choice(
17
+ $.comment,
18
+ $.directive,
19
+ $.journey_hash_comment,
20
+ ));
21
+
22
+ const taskName = ($) => field('task', choice(
23
+ $.journey_task_name,
24
+ alias($._journey_keyword_prefixed_task_name, $.journey_task_name),
25
+ ));
26
+
27
+ const journeyRules = {
28
+ journey_diagram: ($) => choice(
29
+ seq(
30
+ field('header', $.journey_header),
31
+ optional(field('body', $.journey_body)),
32
+ ),
33
+ seq(
34
+ field('header', alias($._journey_inline_header, $.journey_header)),
35
+ field('body', $.journey_body),
36
+ ),
37
+ field('header', alias($._journey_header_eof, $.journey_header)),
38
+ ),
39
+
40
+ journey_header: ($) => seq(
41
+ diagramKeyword($),
42
+ field('terminator', $._line_ending),
43
+ ),
44
+
45
+ _journey_inline_header: ($) => seq(
46
+ diagramKeyword($),
47
+ token.immediate(/[ \t]+/),
48
+ ),
49
+
50
+ _journey_header_eof: ($) => diagramKeyword($),
51
+
52
+ journey_body: ($) => choice(
53
+ repeat1($._journey_line_item),
54
+ seq(
55
+ repeat($._journey_line_item),
56
+ $._journey_eof_item,
57
+ ),
58
+ ),
59
+
60
+ _journey_line_item: ($) => choice(
61
+ seq($._journey_statement, trailingTrivia($), $._line_ending),
62
+ seq(choice($.comment, $.directive, $.journey_hash_comment), $._line_ending),
63
+ $._blank_line,
64
+ ),
65
+
66
+ _journey_eof_item: ($) => choice(
67
+ seq($._journey_statement, trailingTrivia($)),
68
+ $.comment,
69
+ $.directive,
70
+ $.journey_hash_comment,
71
+ ),
72
+
73
+ _journey_statement: ($) => choice(
74
+ $.journey_title_statement,
75
+ $.journey_accessibility_title_statement,
76
+ $.journey_accessibility_description_statement,
77
+ $.journey_section_statement,
78
+ $.journey_task_statement,
79
+ $.journey_incomplete_section_statement,
80
+ $.journey_incomplete_task_statement,
81
+ $.journey_malformed_statement,
82
+ ),
83
+
84
+ journey_title_statement: ($) => prec(30, seq(
85
+ statementKeyword($, /title/i),
86
+ token.immediate(/[ \t]+/),
87
+ field('text', $.journey_title_text),
88
+ )),
89
+
90
+ journey_accessibility_title_statement: ($) => prec(30, seq(
91
+ statementKeyword($, /accTitle/i),
92
+ optional(token.immediate(/[ \t]+/)),
93
+ field('delimiter', token.immediate(':')),
94
+ optional(token.immediate(/[ \t]+/)),
95
+ optional(field('text', $.journey_accessibility_line_text)),
96
+ )),
97
+
98
+ journey_accessibility_description_statement: ($) => prec(30, seq(
99
+ statementKeyword($, /accDescr/i),
100
+ optional(token.immediate(/[ \t]+/)),
101
+ choice(
102
+ seq(
103
+ field('delimiter', token.immediate(':')),
104
+ optional(token.immediate(/[ \t]+/)),
105
+ optional(field('text', $.journey_accessibility_line_text)),
106
+ ),
107
+ field('description', choice(
108
+ $.journey_accessibility_description_block,
109
+ $.journey_unclosed_accessibility_description_block,
110
+ )),
111
+ ),
112
+ )),
113
+
114
+ journey_section_statement: ($) => prec(30, seq(
115
+ statementKeyword($, /section/i),
116
+ token.immediate(/[ \t]+/),
117
+ field('section', $.journey_section_name),
118
+ )),
119
+
120
+ journey_task_statement: ($) => prec(20, seq(
121
+ taskName($),
122
+ field('delimiter', alias(':', $.journey_task_delimiter)),
123
+ optional(token.immediate(/[ \t]+/)),
124
+ field('score', $.journey_score),
125
+ optional(field('score_suffix', $.journey_score_suffix)),
126
+ optional(seq(
127
+ field('actors_delimiter', alias(':', $.journey_actor_delimiter)),
128
+ optional(token.immediate(/[ \t]+/)),
129
+ optional(field('actors', $.journey_actor_list)),
130
+ )),
131
+ )),
132
+
133
+ journey_actor_list: ($) => seq(
134
+ field('actor', $.journey_actor),
135
+ repeat(seq(
136
+ field('delimiter', ','),
137
+ optional(token.immediate(/[ \t]+/)),
138
+ field('actor', $.journey_actor),
139
+ )),
140
+ ),
141
+
142
+ journey_incomplete_section_statement: ($) => prec(-10, seq(
143
+ statementKeyword($, /section/i),
144
+ )),
145
+
146
+ journey_incomplete_task_statement: ($) => prec(-20, seq(
147
+ taskName($),
148
+ field('delimiter', alias(':', $.journey_task_delimiter)),
149
+ optional(field('recovery', $.journey_task_recovery_text)),
150
+ )),
151
+
152
+ journey_malformed_statement: ($) => prec(-100, field(
153
+ 'text',
154
+ choice(
155
+ alias($.journey_task_name, $.journey_malformed_text),
156
+ alias($._journey_keyword_prefixed_task_name, $.journey_malformed_text),
157
+ ),
158
+ )),
159
+
160
+ journey_accessibility_description_block: (_) => token(seq(
161
+ '{',
162
+ /[^}]*/,
163
+ '}',
164
+ )),
165
+
166
+ journey_unclosed_accessibility_description_block: (_) => token(prec(-10, seq(
167
+ '{',
168
+ /[^}\r\n]*/,
169
+ ))),
170
+
171
+ journey_score: (_) => token.immediate(prec(
172
+ 20,
173
+ /[+-]?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)/,
174
+ )),
175
+
176
+ journey_score_suffix: (_) => token.immediate(/[A-Za-z_][A-Za-z0-9_.-]*/),
177
+
178
+ journey_title_text: (_) => token(prec(
179
+ -5,
180
+ /(?:[^#%;\r\n]|%[^%\r\n])+/
181
+ )),
182
+
183
+ journey_accessibility_line_text: (_) => token(prec(
184
+ -5,
185
+ /(?:[^#%;\r\n]|%[^%\r\n])+/
186
+ )),
187
+
188
+ journey_section_name: (_) => token(prec(
189
+ 5,
190
+ /(?:[^#:%;\r\n]|%[^%\r\n])+/
191
+ )),
192
+
193
+ journey_task_name: (_) => token(prec(
194
+ 5,
195
+ /[^\s#:%;\r\n](?:[^#:%;\r\n]*[^\s#:%;\r\n])?/
196
+ )),
197
+
198
+ _journey_keyword_prefixed_task_name: (_) => seq(
199
+ token(prec(30, choice(
200
+ seq(/title/i, /[^\s#:%;\r\n]/),
201
+ seq(/accTitle/i, /[^\s#:%;\r\n]/),
202
+ seq(/accDescr/i, /[^\s#:%;\r\n]/),
203
+ seq(/section/i, /[^\s#:%;\r\n]/),
204
+ ))),
205
+ optional(token.immediate(/[^#:%;\r\n]+/)),
206
+ ),
207
+
208
+ journey_actor: (_) => token.immediate(prec(
209
+ 5,
210
+ /[^\s#,:%;\r\n](?:[^#,:%;\r\n]*[^\s#,:%;\r\n])?/,
211
+ )),
212
+
213
+ journey_task_recovery_text: (_) => token(prec(
214
+ -50,
215
+ /(?:[^#%\r\n]|%[^%\r\n])+/
216
+ )),
217
+
218
+ journey_hash_comment: (_) => token(prec(10, seq('#', /[^\r\n]*/))),
219
+ };
220
+
221
+ module.exports = { journeyRules };
@@ -0,0 +1,264 @@
1
+ // Source translation: Mermaid 11.16.1
2
+ // packages/mermaid/src/diagrams/kanban/parser/kanban.jison and
3
+ // packages/mermaid/src/docs/syntax/kanban.md
4
+ // commit 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf.
5
+
6
+ const { indentationTransition } = require('../shared/indentation');
7
+
8
+ const diagramKeyword = ($) => field(
9
+ 'keyword',
10
+ alias(token(prec(20, /kanban/i)), $.diagram_keyword),
11
+ );
12
+
13
+ const trailingTrivia = ($) => optional(choice($.comment, $.directive));
14
+
15
+ const shapeDelimiter = ($, delimiter) => alias(
16
+ delimiter,
17
+ $.kanban_shape_delimiter,
18
+ );
19
+
20
+ const metadataDelimiter = ($, delimiter) => alias(
21
+ delimiter,
22
+ $.kanban_metadata_delimiter,
23
+ );
24
+
25
+ const metadataSeparator = ($, separator) => alias(
26
+ separator,
27
+ $.kanban_metadata_separator,
28
+ );
29
+
30
+ const inlineShape = ($, open, close, text) => seq(
31
+ field('open', shapeDelimiter($, open)),
32
+ optional(field('label', choice(
33
+ $.kanban_markdown_string,
34
+ $.kanban_quoted_string,
35
+ alias(text, $.kanban_label_text),
36
+ ))),
37
+ field('close', shapeDelimiter($, close)),
38
+ );
39
+
40
+ const multilineShape = ($, open, close) => seq(
41
+ field('open', shapeDelimiter($, open)),
42
+ $._line_ending,
43
+ repeat1(choice(
44
+ seq(
45
+ optional(field('indentation', $.kanban_continuation_indentation)),
46
+ field(
47
+ 'label',
48
+ alias($._kanban_multiline_label_line, $.kanban_multiline_label_text),
49
+ ),
50
+ $._line_ending,
51
+ ),
52
+ $._blank_line,
53
+ )),
54
+ optional(field('indentation', $.kanban_continuation_indentation)),
55
+ field('close', shapeDelimiter($, close)),
56
+ );
57
+
58
+ const kanbanRules = {
59
+ kanban_diagram: ($) => seq(
60
+ field('header', $.kanban_header),
61
+ optional(field('body', $.kanban_body)),
62
+ ),
63
+
64
+ kanban_header: ($) => seq(
65
+ diagramKeyword($),
66
+ field('terminator', $._line_ending),
67
+ ),
68
+
69
+ kanban_body: ($) => choice(
70
+ repeat1($._kanban_line_item),
71
+ seq(
72
+ repeat($._kanban_line_item),
73
+ $._kanban_eof_item,
74
+ ),
75
+ ),
76
+
77
+ _kanban_line_item: ($) => choice(
78
+ $.kanban_incomplete_item_statement,
79
+ seq($._kanban_statement, trailingTrivia($), $._line_ending),
80
+ seq(choice($.comment, $.directive), $._line_ending),
81
+ $._blank_line,
82
+ ),
83
+
84
+ _kanban_eof_item: ($) => choice(
85
+ seq($._kanban_statement, trailingTrivia($)),
86
+ $.comment,
87
+ $.directive,
88
+ ),
89
+
90
+ _kanban_statement: ($) => choice(
91
+ $.kanban_icon_statement,
92
+ $.kanban_class_statement,
93
+ $.kanban_item_statement,
94
+ ),
95
+
96
+ kanban_item_statement: ($) => prec.right(20, seq(
97
+ optional(indentationTransition($, 'kanban')),
98
+ field('item', $.kanban_item),
99
+ optional(field('metadata', $.kanban_metadata)),
100
+ )),
101
+
102
+ kanban_incomplete_item_statement: ($) => prec.dynamic(50, prec.right(seq(
103
+ optional(indentationTransition($, 'kanban')),
104
+ field('item', $.kanban_incomplete_item),
105
+ ))),
106
+
107
+ kanban_item: ($) => choice(
108
+ prec(20, seq(
109
+ optional(field('id', $.kanban_item_id)),
110
+ field('shape', $.kanban_shape),
111
+ )),
112
+ field('label', $.kanban_plain_label),
113
+ ),
114
+
115
+ kanban_incomplete_item: ($) => seq(
116
+ optional(field('id', $.kanban_item_id)),
117
+ field('shape', $.kanban_unclosed_square_shape),
118
+ ),
119
+
120
+ kanban_item_id: ($) => $._kanban_item_text,
121
+
122
+ kanban_plain_label: ($) => $._kanban_item_text,
123
+
124
+ kanban_shape: ($) => choice(
125
+ $.kanban_square_shape,
126
+ $.kanban_round_shape,
127
+ $.kanban_circle_shape,
128
+ $.kanban_bang_shape,
129
+ $.kanban_cloud_shape,
130
+ $.kanban_hexagon_shape,
131
+ ),
132
+
133
+ kanban_square_shape: ($) => choice(
134
+ inlineShape($, '[', ']', $._kanban_square_label_text),
135
+ multilineShape($, '[', ']'),
136
+ ),
137
+
138
+ kanban_round_shape: ($) => choice(
139
+ inlineShape($, '(', ')', $._kanban_round_label_text),
140
+ multilineShape($, '(', ')'),
141
+ ),
142
+
143
+ kanban_circle_shape: ($) => choice(
144
+ inlineShape($, '((', '))', $._kanban_round_label_text),
145
+ multilineShape($, '((', '))'),
146
+ ),
147
+
148
+ kanban_bang_shape: ($) => choice(
149
+ inlineShape($, '))', '((', $._kanban_bang_label_text),
150
+ multilineShape($, '))', '(('),
151
+ ),
152
+
153
+ kanban_cloud_shape: ($) => choice(
154
+ inlineShape($, ')', '(', $._kanban_bang_label_text),
155
+ multilineShape($, ')', '('),
156
+ ),
157
+
158
+ kanban_hexagon_shape: ($) => choice(
159
+ inlineShape($, '{{', '}}', $._kanban_hexagon_label_text),
160
+ multilineShape($, '{{', '}}'),
161
+ ),
162
+
163
+ kanban_unclosed_square_shape: ($) => seq(
164
+ field('open', shapeDelimiter($, '[')),
165
+ field(
166
+ 'label',
167
+ alias($._kanban_unclosed_square_tail, $.kanban_unclosed_label_text),
168
+ ),
169
+ ),
170
+
171
+ kanban_metadata: ($) => seq(
172
+ field('open', metadataDelimiter($, '@{')),
173
+ repeat(choice(
174
+ $.kanban_metadata_pair,
175
+ metadataSeparator($, ','),
176
+ $._line_ending,
177
+ )),
178
+ field('close', metadataDelimiter($, '}')),
179
+ ),
180
+
181
+ kanban_metadata_pair: ($) => seq(
182
+ field('key', $.kanban_metadata_key),
183
+ field('separator', metadataSeparator($, ':')),
184
+ field('value', $.kanban_metadata_value),
185
+ ),
186
+
187
+ kanban_metadata_value: ($) => choice(
188
+ $.kanban_markdown_string,
189
+ $.kanban_quoted_string,
190
+ $.kanban_metadata_bare_value,
191
+ ),
192
+
193
+ kanban_icon_statement: ($) => prec(30, seq(
194
+ field('marker', alias('::icon', $.kanban_icon_marker)),
195
+ field('open', alias('(', $.kanban_decorator_delimiter)),
196
+ optional(field('name', $.kanban_icon_name)),
197
+ field('close', alias(')', $.kanban_decorator_delimiter)),
198
+ )),
199
+
200
+ kanban_class_statement: ($) => prec(30, seq(
201
+ field('marker', alias(':::', $.kanban_class_marker)),
202
+ field('classes', $.kanban_class_list),
203
+ )),
204
+
205
+ kanban_continuation_indentation: (_) => token(prec(30, /[ \t]+/)),
206
+
207
+ _kanban_item_text: (_) => token(prec(
208
+ 5,
209
+ /[^\s%@:()\[\]{}\r\n](?:[^%@()\[\]{}\r\n]|%[^%\r\n])*/,
210
+ )),
211
+
212
+ _kanban_square_label_text: (_) => token.immediate(prec(
213
+ -5,
214
+ /[^\]"\r\n][^\]\r\n]*/,
215
+ )),
216
+
217
+ _kanban_round_label_text: (_) => token.immediate(prec(
218
+ -5,
219
+ /[^\)"\r\n][^\)\r\n]*/,
220
+ )),
221
+
222
+ _kanban_bang_label_text: (_) => token.immediate(prec(
223
+ -5,
224
+ /[^\("\r\n][^\(\r\n]*/,
225
+ )),
226
+
227
+ _kanban_hexagon_label_text: (_) => token.immediate(prec(
228
+ -5,
229
+ /[^\}"\r\n][^\}\r\n]*/,
230
+ )),
231
+
232
+ _kanban_multiline_label_line: (_) => token(prec(-10, /[^\r\n]+/)),
233
+
234
+ _kanban_unclosed_square_tail: (_) => token.immediate(prec(
235
+ 50,
236
+ seq(/[^\]\r\n]+/, choice('\r\n', '\n', '\r')),
237
+ )),
238
+
239
+ kanban_quoted_string: (_) => token(prec(40, choice(
240
+ seq('"', /(?:[^"\\\r\n]|\\.)*/, '"'),
241
+ seq("'", /(?:[^'\\\r\n]|\\.)*/, "'"),
242
+ ))),
243
+
244
+ kanban_markdown_string: (_) => token(prec(50, choice(
245
+ /"`[^`]*`"/,
246
+ /`[^`]*`/,
247
+ ))),
248
+
249
+ kanban_metadata_key: (_) => token(prec(
250
+ 20,
251
+ /[A-Za-z_\u00c0-\uffff][A-Za-z0-9_-\u00c0-\uffff]*/,
252
+ )),
253
+
254
+ kanban_metadata_bare_value: (_) => token(prec(
255
+ -5,
256
+ /[^\s,%}\r\n](?:(?:[^,%}\r\n]|%[^%\r\n])*[^\s,%}\r\n])?/,
257
+ )),
258
+
259
+ kanban_icon_name: (_) => token(prec(-5, /[^)\r\n]+/)),
260
+
261
+ kanban_class_list: (_) => token(prec(-5, /[^%\r\n]+/)),
262
+ };
263
+
264
+ module.exports = { kanbanRules };
@@ -0,0 +1,221 @@
1
+ // Source translation: Mermaid 11.16.1
2
+ // packages/mermaid/src/diagrams/mindmap/parser/mindmap.jison and
3
+ // packages/mermaid/src/docs/syntax/mindmap.md
4
+ // commit 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf.
5
+
6
+ const { indentationTransition } = require('../shared/indentation');
7
+
8
+ const diagramKeyword = ($) => field(
9
+ 'keyword',
10
+ alias(token(prec(20, /mindmap/i)), $.diagram_keyword),
11
+ );
12
+
13
+ const trailingTrivia = ($) => optional(choice($.comment, $.directive));
14
+
15
+ const shapeDelimiter = ($, delimiter) => alias(
16
+ delimiter,
17
+ $.mindmap_shape_delimiter,
18
+ );
19
+
20
+ const inlineShape = ($, open, close, text) => seq(
21
+ field('open', shapeDelimiter($, open)),
22
+ optional(field('label', choice(
23
+ $.mindmap_markdown_string,
24
+ $.mindmap_quoted_string,
25
+ alias(text, $.mindmap_label_text),
26
+ ))),
27
+ field('close', shapeDelimiter($, close)),
28
+ );
29
+
30
+ const multilineShape = ($, open, close) => seq(
31
+ field('open', shapeDelimiter($, open)),
32
+ $._line_ending,
33
+ repeat1(choice(
34
+ seq(
35
+ optional(field('indentation', $.mindmap_continuation_indentation)),
36
+ field(
37
+ 'label',
38
+ alias($._mindmap_multiline_label_line, $.mindmap_multiline_label_text),
39
+ ),
40
+ $._line_ending,
41
+ ),
42
+ $._blank_line,
43
+ )),
44
+ optional(field('indentation', $.mindmap_continuation_indentation)),
45
+ field('close', shapeDelimiter($, close)),
46
+ );
47
+
48
+ const mindmapRules = {
49
+ mindmap_diagram: ($) => seq(
50
+ field('header', $.mindmap_header),
51
+ optional(field('body', $.mindmap_body)),
52
+ ),
53
+
54
+ mindmap_header: ($) => seq(
55
+ diagramKeyword($),
56
+ field('terminator', $._line_ending),
57
+ ),
58
+
59
+ mindmap_body: ($) => choice(
60
+ repeat1($._mindmap_line_item),
61
+ seq(
62
+ repeat($._mindmap_line_item),
63
+ $._mindmap_eof_item,
64
+ ),
65
+ ),
66
+
67
+ _mindmap_line_item: ($) => choice(
68
+ $.mindmap_incomplete_node_statement,
69
+ seq($._mindmap_statement, trailingTrivia($), $._line_ending),
70
+ seq(choice($.comment, $.directive), $._line_ending),
71
+ $._blank_line,
72
+ ),
73
+
74
+ _mindmap_eof_item: ($) => choice(
75
+ seq($._mindmap_statement, trailingTrivia($)),
76
+ $.comment,
77
+ $.directive,
78
+ ),
79
+
80
+ _mindmap_statement: ($) => choice(
81
+ $.mindmap_icon_statement,
82
+ $.mindmap_class_statement,
83
+ $.mindmap_node_statement,
84
+ ),
85
+
86
+ mindmap_node_statement: ($) => prec.right(20, seq(
87
+ optional(indentationTransition($, 'mindmap')),
88
+ field('node', $.mindmap_node),
89
+ )),
90
+
91
+ mindmap_incomplete_node_statement: ($) => prec.dynamic(50, prec.right(seq(
92
+ optional(indentationTransition($, 'mindmap')),
93
+ field('node', $.mindmap_incomplete_node),
94
+ ))),
95
+
96
+ mindmap_node: ($) => choice(
97
+ prec(20, seq(
98
+ optional(field('id', $.mindmap_node_id)),
99
+ field('shape', $.mindmap_shape),
100
+ )),
101
+ field('label', $.mindmap_plain_label),
102
+ ),
103
+
104
+ mindmap_incomplete_node: ($) => seq(
105
+ optional(field('id', $.mindmap_node_id)),
106
+ field('shape', $.mindmap_unclosed_square_shape),
107
+ ),
108
+
109
+ mindmap_node_id: ($) => $._mindmap_node_text,
110
+
111
+ mindmap_plain_label: ($) => $._mindmap_node_text,
112
+
113
+ mindmap_shape: ($) => choice(
114
+ $.mindmap_square_shape,
115
+ $.mindmap_round_shape,
116
+ $.mindmap_circle_shape,
117
+ $.mindmap_bang_shape,
118
+ $.mindmap_cloud_shape,
119
+ $.mindmap_hexagon_shape,
120
+ ),
121
+
122
+ mindmap_square_shape: ($) => choice(
123
+ inlineShape($, '[', ']', $._mindmap_square_label_text),
124
+ multilineShape($, '[', ']'),
125
+ ),
126
+
127
+ mindmap_round_shape: ($) => choice(
128
+ inlineShape($, '(', ')', $._mindmap_round_label_text),
129
+ multilineShape($, '(', ')'),
130
+ ),
131
+
132
+ mindmap_circle_shape: ($) => choice(
133
+ inlineShape($, '((', '))', $._mindmap_round_label_text),
134
+ multilineShape($, '((', '))'),
135
+ ),
136
+
137
+ mindmap_bang_shape: ($) => choice(
138
+ inlineShape($, '))', '((', $._mindmap_bang_label_text),
139
+ multilineShape($, '))', '(('),
140
+ ),
141
+
142
+ mindmap_cloud_shape: ($) => choice(
143
+ inlineShape($, ')', '(', $._mindmap_bang_label_text),
144
+ multilineShape($, ')', '('),
145
+ ),
146
+
147
+ mindmap_hexagon_shape: ($) => choice(
148
+ inlineShape($, '{{', '}}', $._mindmap_hexagon_label_text),
149
+ multilineShape($, '{{', '}}'),
150
+ ),
151
+
152
+ mindmap_unclosed_square_shape: ($) => seq(
153
+ field('open', shapeDelimiter($, '[')),
154
+ field(
155
+ 'label',
156
+ alias($._mindmap_unclosed_square_tail, $.mindmap_unclosed_label_text),
157
+ ),
158
+ ),
159
+
160
+ mindmap_icon_statement: ($) => prec(30, seq(
161
+ field('marker', alias('::icon', $.mindmap_icon_marker)),
162
+ field('open', alias('(', $.mindmap_decorator_delimiter)),
163
+ optional(field('name', $.mindmap_icon_name)),
164
+ field('close', alias(')', $.mindmap_decorator_delimiter)),
165
+ )),
166
+
167
+ mindmap_class_statement: ($) => prec(30, seq(
168
+ field('marker', alias(':::', $.mindmap_class_marker)),
169
+ field('classes', $.mindmap_class_list),
170
+ )),
171
+
172
+ mindmap_continuation_indentation: (_) => token(prec(30, /[ \t]+/)),
173
+
174
+ _mindmap_node_text: (_) => token(prec(
175
+ 5,
176
+ /[^\s%:()\[\]{}\r\n](?:[^%()\[\]{}\r\n]|%[^%\r\n])*/,
177
+ )),
178
+
179
+ _mindmap_square_label_text: (_) => token.immediate(prec(
180
+ -5,
181
+ /[^\]"\r\n][^\]\r\n]*/,
182
+ )),
183
+
184
+ _mindmap_round_label_text: (_) => token.immediate(prec(
185
+ -5,
186
+ /[^\)"\r\n][^\)\r\n]*/,
187
+ )),
188
+
189
+ _mindmap_bang_label_text: (_) => token.immediate(prec(
190
+ -5,
191
+ /[^\("\r\n][^\(\r\n]*/,
192
+ )),
193
+
194
+ _mindmap_hexagon_label_text: (_) => token.immediate(prec(
195
+ -5,
196
+ /[^\}"\r\n][^\}\r\n]*/,
197
+ )),
198
+
199
+ _mindmap_multiline_label_line: (_) => token(prec(-10, /[^\r\n]+/)),
200
+
201
+ _mindmap_unclosed_square_tail: (_) => token.immediate(prec(
202
+ 50,
203
+ seq(/[^\]\r\n]+/, choice('\r\n', '\n', '\r')),
204
+ )),
205
+
206
+ mindmap_quoted_string: (_) => token(prec(40, choice(
207
+ seq('"', /(?:[^"\\\r\n]|\\.)*/, '"'),
208
+ seq("'", /(?:[^'\\\r\n]|\\.)*/, "'"),
209
+ ))),
210
+
211
+ mindmap_markdown_string: (_) => token(prec(50, choice(
212
+ /"`[^`]*`"/,
213
+ /`[^`]*`/,
214
+ ))),
215
+
216
+ mindmap_icon_name: (_) => token(prec(-5, /[^)\r\n]+/)),
217
+
218
+ mindmap_class_list: (_) => token(prec(-5, /[^%\r\n]+/)),
219
+ };
220
+
221
+ module.exports = { mindmapRules };