@mermanjs/tree-sitter-mermaid 0.3.4 → 0.3.5
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.
- package/CHANGELOG.md +6 -0
- package/CMakeLists.txt +1 -1
- package/Makefile +1 -1
- package/README.md +2 -2
- package/grammar/families/flowchart.js +46 -24
- package/grammar/families/swimlane.js +1 -0
- package/grammar.js +2 -0
- package/metadata/provenance.json +1 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/darwin-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/linux-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/win32-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/src/grammar.json +462 -193
- package/src/node-types.json +34 -5
- package/src/parser.c +191361 -186070
- package/src/scanner.c +118 -0
- package/tree-sitter-mermaid.wasm +0 -0
- package/tree-sitter.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.5 - Unreleased
|
|
4
|
+
|
|
5
|
+
- Highlight node IDs that start with a dot, including `...`, in Flowchart, Swimlane, and Agentflow. Compact edges such as `.a-.->.b` in Flowchart keep the full operator highlighted.
|
|
6
|
+
- Preserve literal ampersands in Flowchart node IDs and keep surrounding whitespace outside arrow and edge-label captures. Recognize compact arrows in additional endpoint and label forms.
|
|
7
|
+
- Parse and highlight `direction` as a node ID in Flowchart, Swimlane, and Agentflow. Direction statements recognize value prefixes such as `LR` in `LRfoo` across line breaks and whole-line comments. When a statement contains several `direction` pairs, highlight the last pair at the highest matching priority (`TB`, `BT`, `RL`, `LR`, `TD`).
|
|
8
|
+
|
|
3
9
|
## 0.3.4 - 2026-11-12
|
|
4
10
|
|
|
5
11
|
- Keep generic suffixes attached to backtick-quoted Class names in declarations and compact relationship endpoints.
|
package/CMakeLists.txt
CHANGED
package/Makefile
CHANGED
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ The grammar has its own version line, independent of Merman. Its npm and Cargo a
|
|
|
29
29
|
grammar version, but their registry names differ: the npm package is scoped under `@mermanjs`, while
|
|
30
30
|
the Rust crate and C library retain the standard `tree-sitter-mermaid` name.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Version `0.3.5` improves highlighting for dot-prefixed node IDs and compact Flowchart-style edges. The installation examples below use the published `0.3.4` packages. Check [Publish Order](https://github.com/Latias94/merman/blob/main/docs/release/PUBLISH_ORDER.md) for current registry availability.
|
|
33
33
|
Portable queries, Mermaid/ZenUML baselines, language ABI 15, runtime versions, and the Rust
|
|
34
34
|
`cc` minimum of `1.10.0` remain unchanged. See [CHANGELOG.md](CHANGELOG.md) for package changes.
|
|
35
35
|
Match the examples to the version installed in your project; earlier versions have their own tagged
|
|
@@ -151,7 +151,7 @@ int main(void) {
|
|
|
151
151
|
}
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
The grammar pairs with Tree-sitter CLI, Rust, and Web runtime 0.27.1. The Rust language adapter uses compatible `^0.1.9` and the generated language ABI remains 15. See [query migration](docs/query-migration.md) when upgrading queries and the [grammar release guide](../../docs/release/TREE_SITTER_MERMAID.md) when maintaining the package.
|
|
155
155
|
|
|
156
156
|
## Compatibility
|
|
157
157
|
|
|
@@ -26,16 +26,30 @@ const statementKeyword = ($, prefix, keyword) => field(
|
|
|
26
26
|
|
|
27
27
|
const optionalInlineGap = () => optional(token.immediate(/[ \t]+/));
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
)
|
|
29
|
+
const identifierPrecedence = -5;
|
|
30
|
+
|
|
31
|
+
// At identifier precedence, a longer name such as `directionLR` wins the whole token.
|
|
32
|
+
const directionKeyword = () => token(prec(identifierPrecedence, /direction/));
|
|
33
|
+
|
|
34
|
+
const identifier = (flowchartLexing) => {
|
|
35
|
+
const unicode = String.raw`\u00c0-\uffff`;
|
|
36
|
+
const head = flowchartLexing ? 'A-Za-z_./&' : 'A-Za-z0-9_.';
|
|
37
|
+
const part = (flowchartLexing ? 'A-Za-z0-9_/&' : 'A-Za-z0-9_') + unicode;
|
|
38
|
+
const tail = `(?:[${part}.!?$%#]|-[${part}])+`;
|
|
39
|
+
const variants = [
|
|
40
|
+
token(prec(60, new RegExp(`classDef${tail}`))),
|
|
41
|
+
token(prec(40, new RegExp(
|
|
42
|
+
`(?:subgraph|class|style|linkStyle|click|accTitle|accDescr|end)${tail}`,
|
|
43
|
+
))),
|
|
44
|
+
directionKeyword(),
|
|
45
|
+
token(prec(identifierPrecedence, new RegExp(`[${head}${unicode}](?:${tail})?`))),
|
|
46
|
+
];
|
|
47
|
+
if (flowchartLexing) {
|
|
48
|
+
// Jison lexes NUM first, so a dashless dotted arrow can follow it immediately.
|
|
49
|
+
variants.push(seq(/[0-9]+/, optional(token.immediate(prec(identifierPrecedence, new RegExp(tail))))));
|
|
50
|
+
}
|
|
51
|
+
return choice(...variants);
|
|
52
|
+
};
|
|
39
53
|
|
|
40
54
|
const headerDirection = ($) => seq(
|
|
41
55
|
token.immediate(/[ \t]+/),
|
|
@@ -112,6 +126,7 @@ const createFlowFamilyRules = ({
|
|
|
112
126
|
header,
|
|
113
127
|
headerEof,
|
|
114
128
|
keywords,
|
|
129
|
+
flowchartLexing = false,
|
|
115
130
|
}) => ({
|
|
116
131
|
[diagram]: ($) => choice(
|
|
117
132
|
seq(
|
|
@@ -219,14 +234,21 @@ const createFlowFamilyRules = ({
|
|
|
219
234
|
|
|
220
235
|
[familyRule(prefix, 'subgraph_end')]: (_) => token(prec(30, 'end')),
|
|
221
236
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
237
|
+
// flow.jison matches a value by prefix. Keep the selected pair and any
|
|
238
|
+
// whole-line comments that Mermaid removes between its keyword and value.
|
|
239
|
+
[familyRule(prefix, 'direction_statement')]: ($) => prec.dynamic(1, seq(
|
|
240
|
+
repeat($._flow_direction_prefix),
|
|
241
|
+
field('keyword', alias(directionKeyword(), ref($, prefix, 'statement_keyword'))),
|
|
242
|
+
repeat(seq(
|
|
243
|
+
$._line_ending,
|
|
244
|
+
optional(alias(token(/%%[^{\r\n][^\r\n]*/), $.comment)),
|
|
245
|
+
)),
|
|
225
246
|
field('direction', alias(
|
|
226
|
-
token
|
|
247
|
+
token(prec(1, /(?:LR|RL|TB|BT|TD)/)),
|
|
227
248
|
ref($, prefix, 'direction'),
|
|
228
249
|
)),
|
|
229
|
-
|
|
250
|
+
optional(token.immediate(/[^;\r\n]+/)),
|
|
251
|
+
)),
|
|
230
252
|
|
|
231
253
|
[familyRule(prefix, 'edge_statement')]: ($) => prec.right(60, seq(
|
|
232
254
|
field('source', ref($, prefix, 'node')),
|
|
@@ -253,7 +275,7 @@ const createFlowFamilyRules = ({
|
|
|
253
275
|
[familyRule(prefix, 'node')]: ($) => seq(
|
|
254
276
|
field('vertex', ref($, prefix, 'vertex')),
|
|
255
277
|
repeat(seq(
|
|
256
|
-
field('separator', '&'),
|
|
278
|
+
field('separator', flowchartLexing ? alias($._flowchart_group_separator, '&') : '&'),
|
|
257
279
|
field('vertex', ref($, prefix, 'vertex')),
|
|
258
280
|
)),
|
|
259
281
|
),
|
|
@@ -450,7 +472,10 @@ const createFlowFamilyRules = ({
|
|
|
450
472
|
token.immediate('='),
|
|
451
473
|
token.immediate('.'),
|
|
452
474
|
)),
|
|
453
|
-
|
|
475
|
+
// A trailing x, o, or < can belong to the closing arrow.
|
|
476
|
+
[familyRule(prefix, 'middle_edge_label_fragment')]: (_) => token.immediate(flowchartLexing
|
|
477
|
+
? /(?:[xo<]?[^-=.xo<\r\n])+|[xo<]/
|
|
478
|
+
: /[^-=.\r\n]+/),
|
|
454
479
|
|
|
455
480
|
[familyRule(prefix, 'arrow_start')]: (_) => token(prec(
|
|
456
481
|
20,
|
|
@@ -652,16 +677,12 @@ const createFlowFamilyRules = ({
|
|
|
652
677
|
|
|
653
678
|
[familyRule(prefix, 'accessibility_block_text')]: (_) => token.immediate(/[^}]+/),
|
|
654
679
|
|
|
655
|
-
[familyRule(prefix, 'identifier')]: (_) =>
|
|
656
|
-
keywordPrefixedIdentifier(),
|
|
657
|
-
token(prec(
|
|
658
|
-
-5,
|
|
659
|
-
/[A-Za-z0-9_\u00c0-\uffff][A-Za-z0-9_.!?$%#\u00c0-\uffff]*(?:-[A-Za-z0-9_\u00c0-\uffff][A-Za-z0-9_.!?$%#\u00c0-\uffff]*)*/,
|
|
660
|
-
)),
|
|
661
|
-
),
|
|
680
|
+
[familyRule(prefix, 'identifier')]: (_) => identifier(flowchartLexing),
|
|
662
681
|
});
|
|
663
682
|
|
|
664
683
|
const createFlowFamilyConflicts = ($, prefix) => [
|
|
684
|
+
// A newline after `direction` can terminate a node or precede a direction value.
|
|
685
|
+
[ref($, prefix, 'direction_statement'), ref($, prefix, 'identifier')],
|
|
665
686
|
[
|
|
666
687
|
privateRef($, prefix, 'labeled_edge'),
|
|
667
688
|
privateRef($, prefix, 'unlabeled_edge'),
|
|
@@ -678,6 +699,7 @@ const flowchartRules = createFlowFamilyRules({
|
|
|
678
699
|
header: 'flowchart_header',
|
|
679
700
|
headerEof: '_flowchart_header_eof',
|
|
680
701
|
keywords: ['flowchart-elk', 'flowchart', 'graph'],
|
|
702
|
+
flowchartLexing: true,
|
|
681
703
|
});
|
|
682
704
|
|
|
683
705
|
const flowchartConflicts = ($) => createFlowFamilyConflicts($, 'flow');
|
package/grammar.js
CHANGED
package/metadata/provenance.json
CHANGED
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|