@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 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 `0x57420009`, so it loads with the WillBooster runtime, version 13.0.0 or later in the 13.x series
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 retain their complete `attribute_value` range and expose recognized named and numeric character
58
- references as `entity` children. Quoted values retain their `quoted_attribute_value` wrapper. Other value content,
59
- including literal ampersands, has no child nodes, so injections targeting `attribute_value` retain it by default. Set `injection.include-children` when the injected language needs the original reference
60
- spellings. Legacy names without a semicolon remain literal before an ASCII letter, digit, or `=`; unknown
61
- names and incomplete numeric prefixes remain literal. Comments are document or element content, and are not accepted
62
- between attributes. Comment-shaped text inside a quoted value remains part of that value.
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 13.0.0 or later in the 13.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
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 = "13.0.0" }
116
- tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "8" }
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
- $.attribute_value,
145
- $.quoted_attribute_value,
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
- attribute_value: $ => seq(
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
- quoted_attribute_value: $ => choice(
168
- seq('\'', optional(alias(repeat1(choice(
169
- alias($._attribute_entity, $.entity),
170
- token.immediate(/[^'&]+/),
171
- $._attribute_ampersand,
172
- )), $.attribute_value)), '\''),
173
- seq('"', optional(alias(repeat1(choice(
174
- alias($._attribute_entity, $.entity),
175
- token.immediate(/[^"&]+/),
176
- $._attribute_ampersand,
177
- )), $.attribute_value)), '"'),
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": "9.0.0",
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": "13.0.0",
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": "^13.0.0"
64
+ "@willbooster/web-tree-sitter": "^15.0.0"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@willbooster/web-tree-sitter": {
@@ -3,7 +3,10 @@
3
3
  (doctype) @constant
4
4
  (processing_instruction) @keyword.directive
5
5
  (attribute_name) @attribute
6
- (attribute_value) @string
6
+ [
7
+ (attribute_value)
8
+ (unquoted_attribute_value)
9
+ ] @string
7
10
  (comment) @comment
8
11
 
9
12
  [
@@ -12,11 +12,15 @@
12
12
  "named": true
13
13
  },
14
14
  {
15
- "type": "attribute_value",
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": "quoted_attribute_value",
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,
Binary file
package/tree-sitter.json CHANGED
@@ -20,7 +20,7 @@
20
20
  }
21
21
  ],
22
22
  "metadata": {
23
- "version": "9.0.0",
23
+ "version": "11.0.0",
24
24
  "license": "MIT",
25
25
  "description": "HTML grammar for tree-sitter",
26
26
  "authors": [