@mermanjs/tree-sitter-mermaid 0.3.3 → 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 +11 -0
- package/CMakeLists.txt +1 -1
- package/Makefile +1 -1
- package/README.md +6 -6
- package/grammar/families/class.js +4 -2
- package/grammar/families/flowchart.js +46 -24
- package/grammar/families/swimlane.js +1 -0
- package/grammar.js +3 -0
- package/metadata/derivations.json +19 -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 +508 -193
- package/src/node-types.json +34 -5
- package/src/parser.c +190916 -185540
- package/src/scanner.c +168 -0
- package/tree-sitter-mermaid.wasm +0 -0
- package/tree-sitter.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.3.4 - 2026-11-12
|
|
10
|
+
|
|
11
|
+
- Keep generic suffixes attached to backtick-quoted Class names in declarations and compact relationship endpoints.
|
|
12
|
+
- Recognize compact Class relationship operators without consuming their hyphens or dots as part of the source name. Ordinary and trailing hyphens remain valid in class names.
|
|
13
|
+
|
|
3
14
|
## 0.3.3 - 2026-11-06
|
|
4
15
|
|
|
5
16
|
- Refresh the npm development-tool lockfile to semver 7.8.6 and undici 8.12.4.
|
package/CMakeLists.txt
CHANGED
package/Makefile
CHANGED
package/README.md
CHANGED
|
@@ -29,8 +29,8 @@ 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
|
-
|
|
33
|
-
|
|
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
|
+
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
|
|
36
36
|
documentation. Custom query consumers should review the
|
|
@@ -39,7 +39,7 @@ documentation. Custom query consumers should review the
|
|
|
39
39
|
## Node.js
|
|
40
40
|
|
|
41
41
|
```console
|
|
42
|
-
npm install tree-sitter@0.25.1 @mermanjs/tree-sitter-mermaid@0.3.
|
|
42
|
+
npm install tree-sitter@0.25.1 @mermanjs/tree-sitter-mermaid@0.3.4
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
With npm 12 or later, review and approve the native install scripts, then rebuild:
|
|
@@ -76,7 +76,7 @@ import Mermaid from '@mermanjs/tree-sitter-mermaid';
|
|
|
76
76
|
## Browser and Workers
|
|
77
77
|
|
|
78
78
|
```console
|
|
79
|
-
npm install web-tree-sitter@0.27.1 @mermanjs/tree-sitter-mermaid@0.3.
|
|
79
|
+
npm install web-tree-sitter@0.27.1 @mermanjs/tree-sitter-mermaid@0.3.4
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
The package exports `@mermanjs/tree-sitter-mermaid/tree-sitter-mermaid.wasm`. Copy that asset to a
|
|
@@ -97,7 +97,7 @@ A no-build browser prototype can pin the exact grammar version on jsDelivr:
|
|
|
97
97
|
|
|
98
98
|
```js
|
|
99
99
|
const language = await Language.load(
|
|
100
|
-
'https://cdn.jsdelivr.net/npm/@mermanjs/tree-sitter-mermaid@0.3.
|
|
100
|
+
'https://cdn.jsdelivr.net/npm/@mermanjs/tree-sitter-mermaid@0.3.4/tree-sitter-mermaid.wasm',
|
|
101
101
|
);
|
|
102
102
|
```
|
|
103
103
|
|
|
@@ -151,7 +151,7 @@ int main(void) {
|
|
|
151
151
|
}
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
The
|
|
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
|
|
|
@@ -403,8 +403,9 @@ const classRules = {
|
|
|
403
403
|
|
|
404
404
|
_class_identifier: ($) => choice(
|
|
405
405
|
$.identifier,
|
|
406
|
+
alias($._class_compact_identifier, $.identifier),
|
|
406
407
|
token(prec(5, choice(
|
|
407
|
-
seq('`', /[^`]+/, '`'),
|
|
408
|
+
seq('`', /[^`]+/, '`', optional(/~[^~\r\n]+~/)),
|
|
408
409
|
/[0-9][A-Za-z0-9_.\-\u00c0-\uffff]*(?:~[^~\r\n]+~)?/,
|
|
409
410
|
/[A-Za-z_\u00c0-\uffff][A-Za-z0-9_\-\u00c0-\uffff]*\.[A-Za-z0-9_.\-\u00c0-\uffff]+(?:~[^~\r\n]+~)?/,
|
|
410
411
|
/[A-Za-z_\u00c0-\uffff][A-Za-z0-9_.\-\u00c0-\uffff]*~[^~\r\n]+~/,
|
|
@@ -416,8 +417,9 @@ const classRules = {
|
|
|
416
417
|
token.immediate(/[A-Za-z_\u00c0-\uffff][A-Za-z0-9_\-\u00c0-\uffff]*/),
|
|
417
418
|
$.identifier,
|
|
418
419
|
),
|
|
420
|
+
alias($._class_compact_identifier, $.identifier),
|
|
419
421
|
token.immediate(prec(5, choice(
|
|
420
|
-
seq('`', /[^`]+/, '`'),
|
|
422
|
+
seq('`', /[^`]+/, '`', optional(/~[^~\r\n]+~/)),
|
|
421
423
|
/[0-9][A-Za-z0-9_.\-\u00c0-\uffff]*(?:~[^~\r\n]+~)?/,
|
|
422
424
|
/[A-Za-z_\u00c0-\uffff][A-Za-z0-9_\-\u00c0-\uffff]*\.[A-Za-z0-9_.\-\u00c0-\uffff]+(?:~[^~\r\n]+~)?/,
|
|
423
425
|
/[A-Za-z_\u00c0-\uffff][A-Za-z0-9_.\-\u00c0-\uffff]*~[^~\r\n]+~/,
|
|
@@ -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
|
@@ -461,6 +461,25 @@
|
|
|
461
461
|
}
|
|
462
462
|
]
|
|
463
463
|
},
|
|
464
|
+
{
|
|
465
|
+
"localPaths": [
|
|
466
|
+
"src/scanner.c",
|
|
467
|
+
"grammar/families/class.js"
|
|
468
|
+
],
|
|
469
|
+
"localSymbols": [
|
|
470
|
+
"scan_class_compact_identifier",
|
|
471
|
+
"_class_compact_identifier"
|
|
472
|
+
],
|
|
473
|
+
"sources": [
|
|
474
|
+
{
|
|
475
|
+
"sourceId": "mermaid",
|
|
476
|
+
"relationship": "translated",
|
|
477
|
+
"sourcePaths": [
|
|
478
|
+
"packages/mermaid/src/diagrams/class/parser/classDiagram.jison:1-440"
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
]
|
|
482
|
+
},
|
|
464
483
|
{
|
|
465
484
|
"localPaths": [
|
|
466
485
|
"src/scanner.c",
|
package/metadata/provenance.json
CHANGED
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|