@willbooster/tree-sitter-html 4.0.1 → 6.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 +10 -5
- package/grammar.js +4 -3
- package/package.json +3 -3
- 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 `0x57420006`, so it loads with the WillBooster runtime, version 7.0.5 or later in the 7.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
|
|
@@ -29,7 +29,11 @@ and instructions stay `text`, while character references remain `entity` nodes.
|
|
|
29
29
|
`noembed`, and `noframes` also stays `text` up to the element's own closing tag. `plaintext` retains all remaining
|
|
30
30
|
input as `text`, including closing tags. The grammar's scanner requires an HTML tag-name boundary after
|
|
31
31
|
`</script` and `</style`, so longer names and overlapping prefixes remain raw text. Closing-name comparisons
|
|
32
|
-
fold only ASCII letters, and embedded NUL characters remain part of raw-text content.
|
|
32
|
+
fold only ASCII letters, and embedded NUL characters remain part of raw-text content. In the HTML namespace, a trailing
|
|
33
|
+
slash on a `script` or `style` opening tag remains part of its `start_tag`; it does not close the element, so subsequent
|
|
34
|
+
content remains raw text until the matching end tag. Self-closing foreign-namespace `script` and `style` use ordinary element nodes. Complete foreign
|
|
35
|
+
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`
|
|
36
|
+
uses HTML parsing for its children. Encoding comparisons ignore ASCII case and decode character references. Script content follows
|
|
33
37
|
HTML escaped and double-escaped states, so closing-tag text inside a double escape remains raw text. A script that reaches
|
|
34
38
|
EOF while scanning raw content closes implicitly without an error: its `script_element` has no `end_tag` child, and its
|
|
35
39
|
remaining content stays available for JavaScript injection. Incomplete closing tags such as `</script` still report
|
|
@@ -51,7 +55,8 @@ between attributes. Comment-shaped text inside a quoted value remains part of th
|
|
|
51
55
|
## Usage
|
|
52
56
|
|
|
53
57
|
The npm package ships `tree-sitter-html.wasm` for
|
|
54
|
-
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version
|
|
58
|
+
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 7.0.5 or later in the 7.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
|
|
59
|
+
In Node.js and Bun, load the grammar from its path:
|
|
55
60
|
|
|
56
61
|
```js
|
|
57
62
|
import { fileURLToPath } from 'node:url';
|
|
@@ -97,8 +102,8 @@ fuzzed with:
|
|
|
97
102
|
|
|
98
103
|
```toml
|
|
99
104
|
[dependencies]
|
|
100
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
101
|
-
tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "
|
|
105
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
|
|
106
|
+
tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "5" }
|
|
102
107
|
```
|
|
103
108
|
|
|
104
109
|
```rust
|
package/grammar.js
CHANGED
|
@@ -56,6 +56,7 @@ module.exports = grammar({
|
|
|
56
56
|
$.comment,
|
|
57
57
|
$.entity,
|
|
58
58
|
$.text,
|
|
59
|
+
alias('&', $.text),
|
|
59
60
|
$.element,
|
|
60
61
|
$.script_element,
|
|
61
62
|
$.style_element,
|
|
@@ -94,14 +95,14 @@ module.exports = grammar({
|
|
|
94
95
|
'<',
|
|
95
96
|
alias($._script_start_tag_name, $.tag_name),
|
|
96
97
|
repeat($.attribute),
|
|
97
|
-
'>',
|
|
98
|
+
choice('>', '/>'),
|
|
98
99
|
),
|
|
99
100
|
|
|
100
101
|
style_start_tag: $ => seq(
|
|
101
102
|
'<',
|
|
102
103
|
alias($._style_start_tag_name, $.tag_name),
|
|
103
104
|
repeat($.attribute),
|
|
104
|
-
'>',
|
|
105
|
+
choice('>', '/>'),
|
|
105
106
|
),
|
|
106
107
|
|
|
107
108
|
self_closing_tag: $ => seq(
|
|
@@ -164,6 +165,6 @@ module.exports = grammar({
|
|
|
164
165
|
)), $.attribute_value)), '"'),
|
|
165
166
|
),
|
|
166
167
|
|
|
167
|
-
text: _ => token
|
|
168
|
+
text: _ => token(prec(1, /[^<&]+/)),
|
|
168
169
|
},
|
|
169
170
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "HTML grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
49
|
"@willbooster/wb": "22.26.1",
|
|
50
|
-
"@willbooster/web-tree-sitter": "
|
|
50
|
+
"@willbooster/web-tree-sitter": "7.0.5",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
52
52
|
"lefthook": "2.2.1",
|
|
53
53
|
"oxfmt": "0.72.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"wrangler": "4.149.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@willbooster/web-tree-sitter": "^
|
|
63
|
+
"@willbooster/web-tree-sitter": "^7.0.5"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"@willbooster/web-tree-sitter": {
|
package/tree-sitter-html.wasm
CHANGED
|
Binary file
|