@willbooster/tree-sitter-embedded-template 9.0.1 → 11.0.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.
- package/README.md +11 -10
- package/grammar.js +5 -2
- package/package.json +3 -4
- package/tree-sitter-embedded_template.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -16,22 +16,22 @@ It parses templating languages such as ERB and EJS, in which scripting code is e
|
|
|
16
16
|
`<%` and `%>`. This fork extends upstream's version 0.25.0 grammar with EJS output-tag whitespace slurping,
|
|
17
17
|
trimming closers on comments, and the `=%>` closer on statements.
|
|
18
18
|
It generates the parser with the
|
|
19
|
-
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser loads only
|
|
20
|
-
fork's runtime
|
|
21
|
-
([willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter),
|
|
19
|
+
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator (ABI `0x5742000c`). The parser loads only
|
|
20
|
+
with that fork's runtime ([willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter),
|
|
22
21
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter)); upstream's runtime rejects it.
|
|
22
|
+
This package targets and is tested with version 20.0.0 or later in the 20.x series.
|
|
23
23
|
|
|
24
24
|
## Support Scope
|
|
25
25
|
|
|
26
26
|
This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
|
|
27
|
-
nodes without crashing, hanging, or taking more than linear time. Incremental parsing
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
nodes without crashing, hanging, or taking more than linear time. Incremental parsing is not supported, and no queries
|
|
28
|
+
(highlights, locals, injections, tags) are shipped. Node types, field names, and the trees that error recovery produces
|
|
29
|
+
may change; such changes are released as new major versions.
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
33
|
The npm package ships `tree-sitter-embedded_template.wasm` for
|
|
34
|
-
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version
|
|
34
|
+
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 20.0.0 or later in the 20.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
|
|
35
35
|
In Node.js and Bun, load the grammar from its path:
|
|
36
36
|
|
|
37
37
|
```js
|
|
@@ -80,7 +80,7 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
|
|
|
80
80
|
fuzzed with:
|
|
81
81
|
|
|
82
82
|
```sh
|
|
83
|
-
cargo add willbooster-tree-sitter@
|
|
83
|
+
cargo add willbooster-tree-sitter@20.0.0 --rename tree-sitter
|
|
84
84
|
cargo add willbooster-tree-sitter-embedded-template --rename tree-sitter-embedded-template
|
|
85
85
|
```
|
|
86
86
|
|
|
@@ -121,8 +121,9 @@ and the release build regenerate the parsers before compiling them.
|
|
|
121
121
|
`script/known-failures.txt`, which is empty now. The first run clones the repositories. The example repositories are pinned to commits in
|
|
122
122
|
`script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites it;
|
|
123
123
|
review its diff before committing;
|
|
124
|
-
-
|
|
125
|
-
|
|
124
|
+
- performance checks (`test/unit/performance.test.ts`) that templates ending in an unclosed directive or containing
|
|
125
|
+
long runs of delimiter prefix characters parse in linear time and that generated character-scanning lexer loops hoist
|
|
126
|
+
token marking outside the per-byte loop. It loads the Wasm build through
|
|
126
127
|
@willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating the parser;
|
|
127
128
|
- a check (`test/unit/runtimeVersion.test.ts`) that `@willbooster/web-tree-sitter` in `package.json` and
|
|
128
129
|
`willbooster-tree-sitter` in `Cargo.lock` are the same version, since the Wasm tests run on the former and the Rust
|
package/grammar.js
CHANGED
|
@@ -21,9 +21,12 @@ module.exports = grammar({
|
|
|
21
21
|
$.content,
|
|
22
22
|
)),
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
// Keep pure `[^%=_-]+` and `[^<]*` tails outside any outer `(...)+` so the generated lexer loops have no outgoing
|
|
25
|
+
// transitions to non-accepting states (avoiding per-byte `mark_end` calls), and bound delimiter prefixes (`[=_-]{1,3}`
|
|
26
|
+
// and `<`) so fallback before `%>`, `<%`, or EOF stays linear.
|
|
27
|
+
code: _ => repeat1(choice(/[^%=_-]+|[=_-]{1,3}[^%=_-]+|%[^>%=_-][^%=_-]*|[%=_-]/, '%%>')),
|
|
25
28
|
|
|
26
|
-
content: _ => prec.right(repeat1(choice(/[^<]
|
|
29
|
+
content: _ => prec.right(repeat1(choice(/[^<]+|<([^<%][^<]*)?/, '<%%'))),
|
|
27
30
|
|
|
28
31
|
directive: $ => seq(
|
|
29
32
|
choice('<%', '<%_', '<%|', '<%~'),
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-embedded-template",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Embedded template (ERB, EJS) grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embedded-template",
|
|
7
|
-
"incremental",
|
|
8
7
|
"parsing",
|
|
9
8
|
"tree-sitter"
|
|
10
9
|
],
|
|
@@ -49,7 +48,7 @@
|
|
|
49
48
|
"@vitest/browser-playwright": "5.0.5",
|
|
50
49
|
"@willbooster/oxlint-config": "1.4.9",
|
|
51
50
|
"@willbooster/wb": "23.3.0",
|
|
52
|
-
"@willbooster/web-tree-sitter": "
|
|
51
|
+
"@willbooster/web-tree-sitter": "20.0.0",
|
|
53
52
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
54
53
|
"lefthook": "2.2.2",
|
|
55
54
|
"oxlint": "1.90.0",
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"wrangler": "4.156.0"
|
|
61
60
|
},
|
|
62
61
|
"peerDependencies": {
|
|
63
|
-
"@willbooster/web-tree-sitter": "^
|
|
62
|
+
"@willbooster/web-tree-sitter": "^20.0.0"
|
|
64
63
|
},
|
|
65
64
|
"peerDependenciesMeta": {
|
|
66
65
|
"@willbooster/web-tree-sitter": {
|
|
Binary file
|