@willbooster/tree-sitter-embedded-template 6.0.0 → 7.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 +12 -26
- package/package.json +5 -6
- package/tree-sitter-embedded_template.wasm +0 -0
- package/tree-sitter.json +1 -5
- package/queries/highlights.scm +0 -12
- package/queries/injections-ejs.scm +0 -7
- package/queries/injections-ep.scm +0 -7
- package/queries/injections-erb.scm +0 -7
- package/queries/injections-etlua.scm +0 -7
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-embedded-template/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-embedded-template/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-embedded-template)
|
|
10
10
|
|
|
11
11
|
Embedded template grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
@@ -13,14 +13,20 @@ Embedded template grammar for [tree-sitter](https://github.com/tree-sitter/tree-
|
|
|
13
13
|
to its authors and contributors. This is not an official release of that project.
|
|
14
14
|
|
|
15
15
|
It parses templating languages such as ERB and EJS, in which scripting code is embedded in text with the delimiters
|
|
16
|
-
`<%` and `%>`. This fork extends upstream's version 0.25.0 grammar with EJS output-tag whitespace slurping
|
|
17
|
-
and HTML/Perl injections for angle-delimited Embedded Perl tags.
|
|
16
|
+
`<%` and `%>`. This fork extends upstream's version 0.25.0 grammar with EJS output-tag whitespace slurping.
|
|
18
17
|
It generates the parser with the
|
|
19
18
|
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser loads only with that
|
|
20
19
|
fork's runtime, version 15.0.0 or later in the 15.x series
|
|
21
20
|
([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.
|
|
23
22
|
|
|
23
|
+
## Support Scope
|
|
24
|
+
|
|
25
|
+
This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
|
|
26
|
+
nodes without crashing, hanging, or taking more than linear time. Incremental parsing works as in upstream tree-sitter
|
|
27
|
+
but is not tested here, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and
|
|
28
|
+
the trees that error recovery produces may change; such changes are released as new major versions.
|
|
29
|
+
|
|
24
30
|
## Usage
|
|
25
31
|
|
|
26
32
|
The npm package ships `tree-sitter-embedded_template.wasm` for
|
|
@@ -66,23 +72,7 @@ const parser = new Parser();
|
|
|
66
72
|
parser.setLanguage(await Language.load(grammar));
|
|
67
73
|
```
|
|
68
74
|
|
|
69
|
-
The package also ships `grammar.js
|
|
70
|
-
|
|
71
|
-
For HTML Embedded Perl templates, select `queries/injections-ep.scm` (or `INJECTIONS_EP_QUERY` in Rust).
|
|
72
|
-
CLI language discovery associates every `.ep` file with the `text.html.ep` scope, including non-HTML templates
|
|
73
|
-
such as `mail.txt.ep`. The query always treats template content as HTML; configure a different content injection
|
|
74
|
-
for non-HTML formats. The host must process combined injections and provide HTML and Perl parsers generated
|
|
75
|
-
with WillBooster/tree-sitter, matching this runtime's ABI. Use `@willbooster/tree-sitter-html` or
|
|
76
|
-
`willbooster-tree-sitter-html` for HTML. For Perl, check out this repository
|
|
77
|
-
and [tree-sitter-perl/tree-sitter-perl](https://github.com/tree-sitter-perl/tree-sitter-perl). From the Perl checkout
|
|
78
|
-
as the working directory, run `<embedded-template-checkout>/script/tree-sitter generate grammar.js`, replacing
|
|
79
|
-
`<embedded-template-checkout>` with this repository's absolute checkout path. Then build the generated parser for
|
|
80
|
-
your host and register it as `perl`. The npm package and Rust crate include neither this script nor a Perl parser.
|
|
81
|
-
Upstream-generated parsers cannot load in this runtime.
|
|
82
|
-
With these parsers configured, the query supports the existing angle-delimited tags, such as
|
|
83
|
-
`<% my $name = "World"; %><p><%= $name %></p>`; it is not a full Mojo::Template parser.
|
|
84
|
-
Perl lines beginning with `%`, template capture markers (`begin`/`end`), custom delimiters, and whitespace-trimming
|
|
85
|
-
`=%>` on non-output directives are not supported.
|
|
75
|
+
The package also ships `grammar.js` and the node types in `src/node-types.json`.
|
|
86
76
|
|
|
87
77
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-embedded-template) and on
|
|
88
78
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
@@ -91,7 +81,7 @@ fuzzed with:
|
|
|
91
81
|
```toml
|
|
92
82
|
[dependencies]
|
|
93
83
|
tree-sitter = { package = "willbooster-tree-sitter", version = "15.0.0" }
|
|
94
|
-
tree-sitter-embedded-template = { package = "willbooster-tree-sitter-embedded-template", version = "
|
|
84
|
+
tree-sitter-embedded-template = { package = "willbooster-tree-sitter-embedded-template", version = "7" }
|
|
95
85
|
```
|
|
96
86
|
|
|
97
87
|
```rust
|
|
@@ -127,9 +117,6 @@ and the release build regenerate the parsers before compiling them.
|
|
|
127
117
|
`bun run test` runs:
|
|
128
118
|
|
|
129
119
|
- the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
|
|
130
|
-
- an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
|
|
131
|
-
edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
|
|
132
|
-
`TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
|
|
133
120
|
- a check that the real-world ERB and EJS templates in `examples/` fail to parse exactly as listed in
|
|
134
121
|
`script/known-failures.txt`, which is empty now. The first run clones the repositories. The example repositories are pinned to commits in
|
|
135
122
|
`script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites it;
|
|
@@ -144,8 +131,7 @@ and the release build regenerate the parsers before compiling them.
|
|
|
144
131
|
Cloudflare Workers with and without Node.js compatibility (`test/e2e/workers.test.ts`).
|
|
145
132
|
|
|
146
133
|
The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
|
|
147
|
-
by every checkout
|
|
148
|
-
afterwards.
|
|
134
|
+
by every checkout.
|
|
149
135
|
|
|
150
136
|
CI also runs these tests on Linux arm64 and macOS, where the CLI compiles the parser natively, and fuzzes the parser
|
|
151
137
|
with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-embedded-template",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Embedded template (ERB, EJS) grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embedded-template",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"grammar.js",
|
|
19
|
-
"queries/*.scm",
|
|
20
19
|
"src/node-types.json",
|
|
21
20
|
"tree-sitter.json",
|
|
22
21
|
"*.wasm"
|
|
@@ -46,15 +45,15 @@
|
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@tsconfig/bun": "1.0.11",
|
|
49
|
-
"@types/bun": "1.4.
|
|
48
|
+
"@types/bun": "1.4.4",
|
|
50
49
|
"@vitest/browser-playwright": "5.0.5",
|
|
51
50
|
"@willbooster/oxlint-config": "1.4.9",
|
|
52
|
-
"@willbooster/wb": "22.
|
|
51
|
+
"@willbooster/wb": "22.32.3",
|
|
53
52
|
"@willbooster/web-tree-sitter": "15.0.0",
|
|
54
53
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
55
54
|
"lefthook": "2.2.2",
|
|
56
|
-
"oxlint": "1.
|
|
57
|
-
"oxlint-tsgolint": "7.0.
|
|
55
|
+
"oxlint": "1.89.0",
|
|
56
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
58
57
|
"playwright": "1.64.1",
|
|
59
58
|
"semantic-release": "25.0.9",
|
|
60
59
|
"vitest": "5.0.5",
|
|
Binary file
|
package/tree-sitter.json
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"file-types": [
|
|
10
10
|
"ejs"
|
|
11
11
|
],
|
|
12
|
-
"injections": "queries/injections-ejs.scm",
|
|
13
12
|
"injection-regex": "ejs"
|
|
14
13
|
},
|
|
15
14
|
{
|
|
@@ -20,7 +19,6 @@
|
|
|
20
19
|
"file-types": [
|
|
21
20
|
"erb"
|
|
22
21
|
],
|
|
23
|
-
"injections": "queries/injections-erb.scm",
|
|
24
22
|
"injection-regex": "erb"
|
|
25
23
|
},
|
|
26
24
|
{
|
|
@@ -31,7 +29,6 @@
|
|
|
31
29
|
"file-types": [
|
|
32
30
|
"etlua"
|
|
33
31
|
],
|
|
34
|
-
"injections": "queries/injections-etlua.scm",
|
|
35
32
|
"injection-regex": "etlua"
|
|
36
33
|
},
|
|
37
34
|
{
|
|
@@ -42,12 +39,11 @@
|
|
|
42
39
|
"file-types": [
|
|
43
40
|
"ep"
|
|
44
41
|
],
|
|
45
|
-
"injections": "queries/injections-ep.scm",
|
|
46
42
|
"injection-regex": "ep"
|
|
47
43
|
}
|
|
48
44
|
],
|
|
49
45
|
"metadata": {
|
|
50
|
-
"version": "
|
|
46
|
+
"version": "7.0.0",
|
|
51
47
|
"license": "MIT",
|
|
52
48
|
"description": "Embedded template (ERB, EJS) grammar for tree-sitter",
|
|
53
49
|
"authors": [
|
package/queries/highlights.scm
DELETED