@willbooster/tree-sitter-html 11.0.0 → 12.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.48.9-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-21.0.0-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
@@ -21,7 +21,7 @@ it. Input that contains NUL characters can parse to a different tree than with u
21
21
  lexers that generator emits treat a NUL character as an ordinary character. This grammar also accepts literal `>`
22
22
  characters and bare `&` in text nodes, which upstream 0.23.2 rejects. A bare `&` becomes its own `text` node beside
23
23
  surrounding text, while character references remain `entity` nodes. Text nodes include leading, trailing, and whitespace-only content, including whitespace between markup and character references. A DOCTYPE declaration exposes its uninterpreted body as a `doctype_value` child, including legacy PUBLIC or SYSTEM identifiers. Processing instructions use source-preserving
24
- `processing_instruction` nodes and directive highlights. Delimited `xml` and `xml-stylesheet` targets in any ASCII
24
+ `processing_instruction` nodes. Delimited `xml` and `xml-stylesheet` targets in any ASCII
25
25
  case, including XML declarations, and malformed targets produce `comment` nodes. Valid targets start with an ASCII
26
26
  letter or `_` and continue with ASCII letters, digits, `-` or `_`. A valid-target instruction without a closing `>`
27
27
  reports an error. In HTML-namespace `title` and `textarea`, tags, comments,
@@ -36,11 +36,11 @@ name boundary instead of the HTML tokenizer's replacement-character behavior.
36
36
  In the HTML namespace, a trailing
37
37
  slash on a `script` or `style` opening tag remains part of its `start_tag`; it does not close the element, so subsequent
38
38
  content remains raw text until the matching end tag. Self-closing foreign-namespace `script` and `style` use ordinary element nodes. Complete foreign
39
- elements retain raw-text nodes and injection ranges, including CDATA delimiters. MathML `annotation-xml` with an `encoding` value of `text/html` or `application/xhtml+xml`
39
+ elements retain raw-text nodes, including CDATA delimiters. MathML `annotation-xml` with an `encoding` value of `text/html` or `application/xhtml+xml`
40
40
  uses HTML parsing for its children. Encoding comparisons ignore ASCII case and decode character references. Script content follows
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
- remaining content stays available for JavaScript injection. Incomplete closing tags such as `</script` still report
43
+ remaining content stays in its `raw_text` node. Incomplete closing tags such as `</script` still report
44
44
  recovery errors. Unterminated style elements still report an error. HTML-namespace void elements such as `<input>` and
45
45
  `<br/>` use `void_element` nodes with direct `tag_name` and `attribute` children. Following text, entities, comments,
46
46
  and processing instructions are siblings, and explicit void-element end tags are `erroneous_end_tag` siblings.
@@ -58,14 +58,20 @@ Attribute values use distinct `unquoted_attribute_value`, `singlequoted_attribut
58
58
  `doublequoted_attribute_value` nodes directly inside `attribute`. Quoted nodes include both delimiters and retain an
59
59
  `attribute_value` child for nonempty content; empty quoted values have no content child. Unquoted nodes cover the value
60
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.
61
+ node. Other content, including literal ampersands, has no child nodes. The quote-free content of a value is its
62
+ `attribute_value` or `unquoted_attribute_value` node.
64
63
  Legacy names without a semicolon remain literal before an ASCII letter, digit, or `=`; unknown names and incomplete
65
64
  numeric prefixes remain literal. Comments are document or element content and are not accepted between attributes.
66
65
  Comment-shaped text inside a quoted value remains part of that value. Whitespace after `=` separates the operator from
67
66
  the value, so `noval= bool` remains one attribute with the unquoted value `bool`.
68
67
 
68
+ ## Support Scope
69
+
70
+ This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
71
+ nodes without crashing, hanging, or taking more than linear time. Incremental parsing works as in upstream tree-sitter
72
+ but is not tested here, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and
73
+ the trees that error recovery produces may change; such changes are released as new major versions.
74
+
69
75
  ## Usage
70
76
 
71
77
  The npm package ships `tree-sitter-html.wasm` for
@@ -109,7 +115,7 @@ const parser = new Parser();
109
115
  parser.setLanguage(await Language.load(html));
110
116
  ```
111
117
 
112
- The package also ships `grammar.js`, the queries in `queries/`, and the node types in `src/node-types.json`.
118
+ The package also ships `grammar.js` and the node types in `src/node-types.json`.
113
119
 
114
120
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-html) and on
115
121
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
@@ -118,7 +124,7 @@ fuzzed with:
118
124
  ```toml
119
125
  [dependencies]
120
126
  tree-sitter = { package = "willbooster-tree-sitter", version = "15.0.0" }
121
- tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "11" }
127
+ tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "12" }
122
128
  ```
123
129
 
124
130
  ```rust
@@ -154,9 +160,6 @@ and the release build regenerate the parsers before compiling them.
154
160
  `bun run test` runs:
155
161
 
156
162
  - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
157
- - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
158
- edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
159
- `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
160
163
  - a check that the real-world HTML files in `examples/`, the checked-in ones and those of the cloned repositories, fail
161
164
  to parse exactly as listed in `script/known-failures.txt`. The first run clones the repositories. The example repositories are pinned to commits in
162
165
  `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites it;
@@ -171,8 +174,7 @@ and the release build regenerate the parsers before compiling them.
171
174
  Cloudflare Workers with and without Node.js compatibility (`test/e2e/workers.test.ts`).
172
175
 
173
176
  The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
174
- by every checkout; `script/fuzz-corpus` builds a parser of its own in `.tmp/fuzz` for each run and deletes it
175
- afterwards.
177
+ by every checkout.
176
178
 
177
179
  CI also runs these tests on Linux arm64 and macOS, where the CLI compiles the parser and the scanner natively, and fuzzes
178
180
  both with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-html",
3
- "version": "11.0.0",
3
+ "version": "12.0.0",
4
4
  "description": "HTML grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "html",
@@ -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.3",
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.29.3",
53
- "@willbooster/web-tree-sitter": "15.0.0",
51
+ "@willbooster/wb": "23.0.0",
52
+ "@willbooster/web-tree-sitter": "15.5.4",
54
53
  "conventional-changelog-conventionalcommits": "10.4.1",
55
54
  "lefthook": "2.2.2",
56
- "oxlint": "1.88.0",
57
- "oxlint-tsgolint": "7.0.2004",
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
@@ -14,13 +14,11 @@
14
14
  "file-types": [
15
15
  "html"
16
16
  ],
17
- "highlights": "queries/highlights.scm",
18
- "injections": "queries/injections.scm",
19
17
  "injection-regex": "html"
20
18
  }
21
19
  ],
22
20
  "metadata": {
23
- "version": "11.0.0",
21
+ "version": "12.0.0",
24
22
  "license": "MIT",
25
23
  "description": "HTML grammar for tree-sitter",
26
24
  "authors": [
@@ -1,17 +0,0 @@
1
- (tag_name) @tag
2
- (erroneous_end_tag_name) @tag.error
3
- (doctype) @constant
4
- (processing_instruction) @keyword.directive
5
- (attribute_name) @attribute
6
- [
7
- (attribute_value)
8
- (unquoted_attribute_value)
9
- ] @string
10
- (comment) @comment
11
-
12
- [
13
- "<"
14
- ">"
15
- "</"
16
- "/>"
17
- ] @punctuation.bracket
@@ -1,7 +0,0 @@
1
- ((script_element
2
- (raw_text) @injection.content)
3
- (#set! injection.language "javascript"))
4
-
5
- ((style_element
6
- (raw_text) @injection.content)
7
- (#set! injection.language "css"))