@willbooster/tree-sitter-html 9.0.0 → 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 +15 -10
- package/grammar.js +15 -15
- package/package.json +3 -3
- package/queries/highlights.scm +4 -1
- package/src/node-types.json +51 -17
- package/tree-sitter-html.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ to its authors and contributors. This is not an official release of that project
|
|
|
14
14
|
|
|
15
15
|
This fork is based on upstream's version 0.23.2 grammar and external scanner and generates the parser with the
|
|
16
16
|
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries that fork's own ABI
|
|
17
|
-
number `
|
|
17
|
+
number `0x5742000b`, so it loads with the WillBooster runtime, version 15.0.0 or later in the 15.x series
|
|
18
18
|
([willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter),
|
|
19
19
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter)); upstream's runtime rejects
|
|
20
20
|
it. Input that contains NUL characters can parse to a different tree than with upstream's 0.23.2 parser, because the
|
|
@@ -54,17 +54,22 @@ runs. Custom tag names are retained in full when they fit the remaining buffer.
|
|
|
54
54
|
omitted along with older tags. Lost tag identities can still produce recovery errors when those tags close.
|
|
55
55
|
Malformed input after a void element can replace its enclosing element with an `ERROR` node during recovery.
|
|
56
56
|
|
|
57
|
-
Attribute values
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
Attribute values use distinct `unquoted_attribute_value`, `singlequoted_attribute_value`, and
|
|
58
|
+
`doublequoted_attribute_value` nodes directly inside `attribute`. Quoted nodes include both delimiters and retain an
|
|
59
|
+
`attribute_value` child for nonempty content; empty quoted values have no content child. Unquoted nodes cover the value
|
|
60
|
+
without surrounding whitespace. Recognized named and numeric character references are `entity` children of the content
|
|
61
|
+
node. Other content, including literal ampersands, has no child nodes. Injections that need quote-free value content can
|
|
62
|
+
capture `attribute_value` and `unquoted_attribute_value`; set `injection.include-children` when they need the original
|
|
63
|
+
reference spellings as well. The highlight query captures those same content nodes, excluding quote delimiters.
|
|
64
|
+
Legacy names without a semicolon remain literal before an ASCII letter, digit, or `=`; unknown names and incomplete
|
|
65
|
+
numeric prefixes remain literal. Comments are document or element content and are not accepted between attributes.
|
|
66
|
+
Comment-shaped text inside a quoted value remains part of that value. Whitespace after `=` separates the operator from
|
|
67
|
+
the value, so `noval= bool` remains one attribute with the unquoted value `bool`.
|
|
63
68
|
|
|
64
69
|
## Usage
|
|
65
70
|
|
|
66
71
|
The npm package ships `tree-sitter-html.wasm` for
|
|
67
|
-
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version
|
|
72
|
+
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 15.0.0 or later in the 15.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
|
|
68
73
|
In Node.js and Bun, load the grammar from its path:
|
|
69
74
|
|
|
70
75
|
```js
|
|
@@ -112,8 +117,8 @@ fuzzed with:
|
|
|
112
117
|
|
|
113
118
|
```toml
|
|
114
119
|
[dependencies]
|
|
115
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
116
|
-
tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "
|
|
120
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "15.0.0" }
|
|
121
|
+
tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "11" }
|
|
117
122
|
```
|
|
118
123
|
|
|
119
124
|
```rust
|
package/grammar.js
CHANGED
|
@@ -141,15 +141,16 @@ module.exports = grammar({
|
|
|
141
141
|
optional(seq(
|
|
142
142
|
'=',
|
|
143
143
|
choice(
|
|
144
|
-
$.
|
|
145
|
-
$.
|
|
144
|
+
$.unquoted_attribute_value,
|
|
145
|
+
$.singlequoted_attribute_value,
|
|
146
|
+
$.doublequoted_attribute_value,
|
|
146
147
|
),
|
|
147
148
|
)),
|
|
148
149
|
),
|
|
149
150
|
|
|
150
151
|
attribute_name: _ => /[^<>"'/=\s]+/,
|
|
151
152
|
|
|
152
|
-
|
|
153
|
+
unquoted_attribute_value: $ => seq(
|
|
153
154
|
choice(
|
|
154
155
|
alias($._unquoted_attribute_entity, $.entity),
|
|
155
156
|
/[^<>"'=\s&]+/,
|
|
@@ -164,18 +165,17 @@ module.exports = grammar({
|
|
|
164
165
|
|
|
165
166
|
entity: _ => token(/&(#([xX][0-9a-fA-F]+|[0-9]+)|[A-Za-z][A-Za-z0-9]*);?/),
|
|
166
167
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
),
|
|
168
|
+
singlequoted_attribute_value: $ => seq('\'', optional(alias(repeat1(choice(
|
|
169
|
+
alias($._attribute_entity, $.entity),
|
|
170
|
+
token.immediate(/[^'&]+/),
|
|
171
|
+
$._attribute_ampersand,
|
|
172
|
+
)), $.attribute_value)), '\''),
|
|
173
|
+
|
|
174
|
+
doublequoted_attribute_value: $ => seq('"', optional(alias(repeat1(choice(
|
|
175
|
+
alias($._attribute_entity, $.entity),
|
|
176
|
+
token.immediate(/[^"&]+/),
|
|
177
|
+
$._attribute_ampersand,
|
|
178
|
+
)), $.attribute_value)), '"'),
|
|
179
179
|
|
|
180
180
|
text: _ => token(prec(1, /[^<&]+/)),
|
|
181
181
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "HTML grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@vitest/browser-playwright": "5.0.5",
|
|
51
51
|
"@willbooster/oxlint-config": "1.4.9",
|
|
52
52
|
"@willbooster/wb": "22.29.3",
|
|
53
|
-
"@willbooster/web-tree-sitter": "
|
|
53
|
+
"@willbooster/web-tree-sitter": "15.0.0",
|
|
54
54
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
55
55
|
"lefthook": "2.2.2",
|
|
56
56
|
"oxlint": "1.88.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"wrangler": "4.151.1"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^
|
|
64
|
+
"@willbooster/web-tree-sitter": "^15.0.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@willbooster/web-tree-sitter": {
|
package/queries/highlights.scm
CHANGED
package/src/node-types.json
CHANGED
|
@@ -12,11 +12,15 @@
|
|
|
12
12
|
"named": true
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
"type": "
|
|
15
|
+
"type": "doublequoted_attribute_value",
|
|
16
|
+
"named": true
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "singlequoted_attribute_value",
|
|
16
20
|
"named": true
|
|
17
21
|
},
|
|
18
22
|
{
|
|
19
|
-
"type": "
|
|
23
|
+
"type": "unquoted_attribute_value",
|
|
20
24
|
"named": true
|
|
21
25
|
}
|
|
22
26
|
]
|
|
@@ -109,6 +113,21 @@
|
|
|
109
113
|
]
|
|
110
114
|
}
|
|
111
115
|
},
|
|
116
|
+
{
|
|
117
|
+
"type": "doublequoted_attribute_value",
|
|
118
|
+
"named": true,
|
|
119
|
+
"fields": {},
|
|
120
|
+
"children": {
|
|
121
|
+
"multiple": false,
|
|
122
|
+
"required": false,
|
|
123
|
+
"types": [
|
|
124
|
+
{
|
|
125
|
+
"type": "attribute_value",
|
|
126
|
+
"named": true
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
112
131
|
{
|
|
113
132
|
"type": "element",
|
|
114
133
|
"named": true,
|
|
@@ -202,21 +221,6 @@
|
|
|
202
221
|
]
|
|
203
222
|
}
|
|
204
223
|
},
|
|
205
|
-
{
|
|
206
|
-
"type": "quoted_attribute_value",
|
|
207
|
-
"named": true,
|
|
208
|
-
"fields": {},
|
|
209
|
-
"children": {
|
|
210
|
-
"multiple": false,
|
|
211
|
-
"required": false,
|
|
212
|
-
"types": [
|
|
213
|
-
{
|
|
214
|
-
"type": "attribute_value",
|
|
215
|
-
"named": true
|
|
216
|
-
}
|
|
217
|
-
]
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
224
|
{
|
|
221
225
|
"type": "script_element",
|
|
222
226
|
"named": true,
|
|
@@ -259,6 +263,21 @@
|
|
|
259
263
|
]
|
|
260
264
|
}
|
|
261
265
|
},
|
|
266
|
+
{
|
|
267
|
+
"type": "singlequoted_attribute_value",
|
|
268
|
+
"named": true,
|
|
269
|
+
"fields": {},
|
|
270
|
+
"children": {
|
|
271
|
+
"multiple": false,
|
|
272
|
+
"required": false,
|
|
273
|
+
"types": [
|
|
274
|
+
{
|
|
275
|
+
"type": "attribute_value",
|
|
276
|
+
"named": true
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
},
|
|
262
281
|
{
|
|
263
282
|
"type": "start_tag",
|
|
264
283
|
"named": true,
|
|
@@ -301,6 +320,21 @@
|
|
|
301
320
|
]
|
|
302
321
|
}
|
|
303
322
|
},
|
|
323
|
+
{
|
|
324
|
+
"type": "unquoted_attribute_value",
|
|
325
|
+
"named": true,
|
|
326
|
+
"fields": {},
|
|
327
|
+
"children": {
|
|
328
|
+
"multiple": true,
|
|
329
|
+
"required": false,
|
|
330
|
+
"types": [
|
|
331
|
+
{
|
|
332
|
+
"type": "entity",
|
|
333
|
+
"named": true
|
|
334
|
+
}
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
},
|
|
304
338
|
{
|
|
305
339
|
"type": "void_element",
|
|
306
340
|
"named": true,
|
package/tree-sitter-html.wasm
CHANGED
|
Binary file
|