@willbooster/tree-sitter-html 7.0.2 → 9.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
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-html/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-html/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-html/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-html/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.45.0-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.48.9-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-html.svg)](https://crates.io/crates/willbooster-tree-sitter-html)
10
10
 
11
11
  HTML grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -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 `0x57420007`, so it loads with the WillBooster runtime, version 10.0.2 or later in the 10.x series
17
+ number `0x57420009`, so it loads with the WillBooster runtime, version 13.0.0 or later in the 13.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
@@ -41,10 +41,14 @@ uses HTML parsing for its children. Encoding comparisons ignore ASCII case and d
41
41
  HTML escaped and double-escaped states, so closing-tag text inside a double escape remains raw text. A script that reaches
42
42
  EOF while scanning raw content closes implicitly without an error: its `script_element` has no `end_tag` child, and its
43
43
  remaining content stays available for JavaScript injection. Incomplete closing tags such as `</script` still report
44
- recovery errors. Unterminated style elements still report an error. Void elements close
45
- before following text, entities, complete comments, and processing instructions, which become siblings instead of children.
44
+ recovery errors. Unterminated style elements still report an error. HTML-namespace void elements such as `<input>` and
45
+ `<br/>` use `void_element` nodes with direct `tag_name` and `attribute` children. Following text, entities, comments,
46
+ and processing instructions are siblings, and explicit void-element end tags are `erroneous_end_tag` siblings.
47
+ In SVG/MathML content outside HTML integration points, HTML breakout start tags such as `<p>` and `<span>` implicitly
48
+ close the foreign ancestors. The same applies to `<font>` with a `color`, `face`, or `size` attribute and to `</br>` or
49
+ `</p>`. Later end tags for those foreign ancestors become `erroneous_end_tag` nodes.
46
50
  Scanner serialization stores the open-tag stack from its innermost tag, compressing runs of identical tags, so active
47
- void, script, and style elements retain their identities when deeply nested. When distinct tags exceed the fixed-size
51
+ script and style elements retain their identities when deeply nested. When distinct tags exceed the fixed-size
48
52
  buffer, serialization prioritizes inner tags and outer namespace boundaries, replacing ordinary outer tags with unknown
49
53
  runs. Custom tag names are retained in full when they fit the remaining buffer. Names that exceed the buffer are
50
54
  omitted along with older tags. Lost tag identities can still produce recovery errors when those tags close.
@@ -60,11 +64,12 @@ between attributes. Comment-shaped text inside a quoted value remains part of th
60
64
  ## Usage
61
65
 
62
66
  The npm package ships `tree-sitter-html.wasm` for
63
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 10.0.2 or later in the 10.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
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.
64
68
  In Node.js and Bun, load the grammar from its path:
65
69
 
66
70
  ```js
67
71
  import { fileURLToPath } from 'node:url';
72
+
68
73
  import { Language, Parser } from '@willbooster/web-tree-sitter';
69
74
 
70
75
  await Parser.init();
@@ -77,9 +82,9 @@ const tree = parser.parse('<!DOCTYPE html>\n<p>Hello</p>\n');
77
82
  In browsers, serve both `.wasm` files and load them by URL (the example uses Vite's `?url` imports):
78
83
 
79
84
  ```js
85
+ import htmlUrl from '@willbooster/tree-sitter-html/tree-sitter-html.wasm?url';
80
86
  import { Language, Parser } from '@willbooster/web-tree-sitter';
81
87
  import runtimeUrl from '@willbooster/web-tree-sitter/web-tree-sitter.wasm?url';
82
- import htmlUrl from '@willbooster/tree-sitter-html/tree-sitter-html.wasm?url';
83
88
 
84
89
  await Parser.init({ locateFile: () => runtimeUrl });
85
90
  const parser = new Parser();
@@ -90,9 +95,9 @@ Cloudflare Workers do not allow compiling Wasm at run time, so import both `.was
90
95
  Node.js compatibility:
91
96
 
92
97
  ```js
98
+ import html from '@willbooster/tree-sitter-html/tree-sitter-html.wasm';
93
99
  import { Language, Parser } from '@willbooster/web-tree-sitter';
94
100
  import runtime from '@willbooster/web-tree-sitter/web-tree-sitter.wasm';
95
- import html from '@willbooster/tree-sitter-html/tree-sitter-html.wasm';
96
101
 
97
102
  await Parser.init({ wasmModule: runtime });
98
103
  const parser = new Parser();
@@ -107,8 +112,8 @@ fuzzed with:
107
112
 
108
113
  ```toml
109
114
  [dependencies]
110
- tree-sitter = { package = "willbooster-tree-sitter", version = "10.0.2" }
111
- tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "7" }
115
+ tree-sitter = { package = "willbooster-tree-sitter", version = "13.0.0" }
116
+ tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "8" }
112
117
  ```
113
118
 
114
119
  ```rust
package/grammar.js CHANGED
@@ -34,6 +34,7 @@ module.exports = grammar({
34
34
  $._unquoted_attribute_fragment,
35
35
  $._discarded_start_tag,
36
36
  $._missing_start_tag_end,
37
+ $._void_start_tag_name,
37
38
  ],
38
39
 
39
40
  rules: {
@@ -61,6 +62,7 @@ module.exports = grammar({
61
62
  $.text,
62
63
  alias('&', $.text),
63
64
  $.element,
65
+ $.void_element,
64
66
  $.script_element,
65
67
  $.style_element,
66
68
  $.erroneous_end_tag,
@@ -75,6 +77,13 @@ module.exports = grammar({
75
77
  $.self_closing_tag,
76
78
  ),
77
79
 
80
+ void_element: $ => seq(
81
+ '<',
82
+ alias($._void_start_tag_name, $.tag_name),
83
+ repeat($.attribute),
84
+ choice(seq('>', $._implicit_end_tag), '/>'),
85
+ ),
86
+
78
87
  script_element: $ => seq(
79
88
  alias($.script_start_tag, $.start_tag),
80
89
  optional($.raw_text),
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-html",
3
- "version": "7.0.2",
3
+ "version": "9.0.0",
4
4
  "description": "HTML grammar for tree-sitter",
5
5
  "keywords": [
6
+ "html",
6
7
  "incremental",
7
8
  "parsing",
8
- "tree-sitter",
9
- "html"
9
+ "tree-sitter"
10
10
  ],
11
+ "license": "MIT",
12
+ "author": "WillBooster Inc.",
11
13
  "repository": {
12
14
  "type": "git",
13
15
  "url": "git+https://github.com/WillBooster/tree-sitter-html.git"
14
16
  },
15
- "license": "MIT",
16
- "author": "WillBooster Inc.",
17
17
  "files": [
18
18
  "grammar.js",
19
19
  "queries/*.scm",
@@ -21,6 +21,10 @@
21
21
  "tree-sitter.json",
22
22
  "*.wasm"
23
23
  ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
24
28
  "scripts": {
25
29
  "build-wasm": "script/generate --build-wasm",
26
30
  "build/ci": "bun run build-wasm",
@@ -43,32 +47,25 @@
43
47
  "devDependencies": {
44
48
  "@tsconfig/bun": "1.0.11",
45
49
  "@types/bun": "1.4.3",
46
- "@vitest/browser-playwright": "5.0.3",
47
- "@willbooster/oxfmt-config": "1.2.2",
48
- "@willbooster/oxlint-config": "1.4.8",
49
- "@willbooster/wb": "22.26.2",
50
- "@willbooster/web-tree-sitter": "10.0.2",
50
+ "@vitest/browser-playwright": "5.0.5",
51
+ "@willbooster/oxlint-config": "1.4.9",
52
+ "@willbooster/wb": "22.29.3",
53
+ "@willbooster/web-tree-sitter": "13.0.0",
51
54
  "conventional-changelog-conventionalcommits": "10.4.1",
52
55
  "lefthook": "2.2.2",
53
- "oxfmt": "0.73.0",
54
56
  "oxlint": "1.88.0",
55
57
  "oxlint-tsgolint": "7.0.2004",
56
- "playwright": "1.64.0",
58
+ "playwright": "1.64.1",
57
59
  "semantic-release": "25.0.9",
58
- "sort-package-json": "4.1.0",
59
- "vitest": "5.0.3",
60
- "wrangler": "4.149.0"
60
+ "vitest": "5.0.5",
61
+ "wrangler": "4.151.1"
61
62
  },
62
63
  "peerDependencies": {
63
- "@willbooster/web-tree-sitter": "^10.0.2"
64
+ "@willbooster/web-tree-sitter": "^13.0.0"
64
65
  },
65
66
  "peerDependenciesMeta": {
66
67
  "@willbooster/web-tree-sitter": {
67
68
  "optional": true
68
69
  }
69
- },
70
- "publishConfig": {
71
- "access": "public",
72
- "registry": "https://registry.npmjs.org/"
73
70
  }
74
71
  }
@@ -101,6 +101,10 @@
101
101
  {
102
102
  "type": "text",
103
103
  "named": true
104
+ },
105
+ {
106
+ "type": "void_element",
107
+ "named": true
104
108
  }
105
109
  ]
106
110
  }
@@ -160,6 +164,10 @@
160
164
  {
161
165
  "type": "text",
162
166
  "named": true
167
+ },
168
+ {
169
+ "type": "void_element",
170
+ "named": true
163
171
  }
164
172
  ]
165
173
  }
@@ -293,6 +301,25 @@
293
301
  ]
294
302
  }
295
303
  },
304
+ {
305
+ "type": "void_element",
306
+ "named": true,
307
+ "fields": {},
308
+ "children": {
309
+ "multiple": true,
310
+ "required": true,
311
+ "types": [
312
+ {
313
+ "type": "attribute",
314
+ "named": true
315
+ },
316
+ {
317
+ "type": "tag_name",
318
+ "named": true
319
+ }
320
+ ]
321
+ }
322
+ },
296
323
  {
297
324
  "type": "\"",
298
325
  "named": false
Binary file
package/tree-sitter.json CHANGED
@@ -20,7 +20,7 @@
20
20
  }
21
21
  ],
22
22
  "metadata": {
23
- "version": "7.0.2",
23
+ "version": "9.0.0",
24
24
  "license": "MIT",
25
25
  "description": "HTML grammar for tree-sitter",
26
26
  "authors": [