@willbooster/tree-sitter-html 3.0.0 → 4.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 +13 -6
- package/grammar.js +9 -1
- package/package.json +1 -1
- package/queries/highlights.scm +1 -0
- package/src/node-types.json +27 -0
- package/tree-sitter-html.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -20,18 +20,25 @@ number, so it loads only with the WillBooster runtime, version 2.x
|
|
|
20
20
|
it. Input that contains NUL characters can parse to a different tree than with upstream's 0.23.2 parser, because the
|
|
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
|
-
surrounding text, while character references remain `entity` nodes. Text nodes include leading, trailing, and whitespace-only content, including whitespace between markup and character references.
|
|
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
|
|
25
|
+
case, including XML declarations, and malformed targets produce `comment` nodes. Valid targets start with an ASCII
|
|
26
|
+
letter or `_` and continue with ASCII letters, digits, `-` or `_`. A valid-target instruction without a closing `>`
|
|
27
|
+
reports an error. In HTML-namespace `title` and `textarea`, tags, comments,
|
|
28
|
+
and instructions stay `text`, while character references remain `entity` nodes. Content inside `iframe`, `xmp`,
|
|
29
|
+
`noembed`, and `noframes` also stays `text` up to the element's own closing tag. `plaintext` retains all remaining
|
|
30
|
+
input as `text`, including closing tags. The grammar's scanner requires an HTML tag-name boundary after
|
|
24
31
|
`</script` and `</style`, so longer names and overlapping prefixes remain raw text. Closing-name comparisons
|
|
25
32
|
fold only ASCII letters, and embedded NUL characters remain part of raw-text content. Script content follows
|
|
26
33
|
HTML escaped and double-escaped states, so closing-tag text inside a double escape remains raw text. A script that reaches
|
|
27
34
|
EOF while scanning raw content closes implicitly without an error: its `script_element` has no `end_tag` child, and its
|
|
28
35
|
remaining content stays available for JavaScript injection. Incomplete closing tags such as `</script` still report
|
|
29
36
|
recovery errors. Unterminated style elements still report an error. Void elements close
|
|
30
|
-
before following text, entities,
|
|
37
|
+
before following text, entities, complete comments, and processing instructions, which become siblings instead of children.
|
|
31
38
|
Scanner serialization stores the open-tag stack from its innermost tag, compressing runs of identical tags, so active
|
|
32
|
-
void, script, and style elements retain their identities when deeply nested. When
|
|
33
|
-
|
|
34
|
-
tags close. Custom tag names longer than 255 bytes are truncated in serialized state.
|
|
39
|
+
void, script, and style elements retain their identities when deeply nested. When distinct tags exceed the fixed-size
|
|
40
|
+
buffer, serialization prioritizes inner tags and outer namespace boundaries, replacing ordinary outer tags with unknown
|
|
41
|
+
runs. Lost tag identities can still produce recovery errors when those tags close. Custom tag names longer than 255 bytes are truncated in serialized state.
|
|
35
42
|
Malformed input after a void element can replace its enclosing element with an `ERROR` node during recovery.
|
|
36
43
|
|
|
37
44
|
Attribute values retain their complete `attribute_value` range and expose recognized named and numeric character
|
|
@@ -91,7 +98,7 @@ fuzzed with:
|
|
|
91
98
|
```toml
|
|
92
99
|
[dependencies]
|
|
93
100
|
tree-sitter = { package = "willbooster-tree-sitter", version = "2.0.0" }
|
|
94
|
-
tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "
|
|
101
|
+
tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "4" }
|
|
95
102
|
```
|
|
96
103
|
|
|
97
104
|
```rust
|
package/grammar.js
CHANGED
|
@@ -25,6 +25,9 @@ module.exports = grammar({
|
|
|
25
25
|
$._implicit_end_tag,
|
|
26
26
|
$.raw_text,
|
|
27
27
|
$.comment,
|
|
28
|
+
$.processing_instruction,
|
|
29
|
+
$._element_text,
|
|
30
|
+
$._unfinished_processing_instruction,
|
|
28
31
|
$._attribute_entity,
|
|
29
32
|
$._unquoted_attribute_entity,
|
|
30
33
|
$._attribute_ampersand,
|
|
@@ -37,14 +40,19 @@ module.exports = grammar({
|
|
|
37
40
|
doctype: $ => seq(
|
|
38
41
|
'<!',
|
|
39
42
|
alias($._doctype, 'doctype'),
|
|
40
|
-
|
|
43
|
+
$.doctype_value,
|
|
41
44
|
'>',
|
|
42
45
|
),
|
|
43
46
|
|
|
44
47
|
_doctype: _ => /[Dd][Oo][Cc][Tt][Yy][Pp][Ee]/,
|
|
45
48
|
|
|
49
|
+
doctype_value: _ => repeat1(/[^>]+/),
|
|
50
|
+
|
|
46
51
|
_node: $ => choice(
|
|
47
52
|
$.doctype,
|
|
53
|
+
$.processing_instruction,
|
|
54
|
+
seq($._unfinished_processing_instruction, '>'),
|
|
55
|
+
alias($._element_text, $.text),
|
|
48
56
|
$.comment,
|
|
49
57
|
$.entity,
|
|
50
58
|
$.text,
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
package/src/node-types.json
CHANGED
|
@@ -40,6 +40,21 @@
|
|
|
40
40
|
{
|
|
41
41
|
"type": "doctype",
|
|
42
42
|
"named": true,
|
|
43
|
+
"fields": {},
|
|
44
|
+
"children": {
|
|
45
|
+
"multiple": false,
|
|
46
|
+
"required": true,
|
|
47
|
+
"types": [
|
|
48
|
+
{
|
|
49
|
+
"type": "doctype_value",
|
|
50
|
+
"named": true
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"type": "doctype_value",
|
|
57
|
+
"named": true,
|
|
43
58
|
"fields": {}
|
|
44
59
|
},
|
|
45
60
|
{
|
|
@@ -71,6 +86,10 @@
|
|
|
71
86
|
"type": "erroneous_end_tag",
|
|
72
87
|
"named": true
|
|
73
88
|
},
|
|
89
|
+
{
|
|
90
|
+
"type": "processing_instruction",
|
|
91
|
+
"named": true
|
|
92
|
+
},
|
|
74
93
|
{
|
|
75
94
|
"type": "script_element",
|
|
76
95
|
"named": true
|
|
@@ -118,6 +137,10 @@
|
|
|
118
137
|
"type": "erroneous_end_tag",
|
|
119
138
|
"named": true
|
|
120
139
|
},
|
|
140
|
+
{
|
|
141
|
+
"type": "processing_instruction",
|
|
142
|
+
"named": true
|
|
143
|
+
},
|
|
121
144
|
{
|
|
122
145
|
"type": "script_element",
|
|
123
146
|
"named": true
|
|
@@ -322,6 +345,10 @@
|
|
|
322
345
|
"type": "erroneous_end_tag_name",
|
|
323
346
|
"named": true
|
|
324
347
|
},
|
|
348
|
+
{
|
|
349
|
+
"type": "processing_instruction",
|
|
350
|
+
"named": true
|
|
351
|
+
},
|
|
325
352
|
{
|
|
326
353
|
"type": "raw_text",
|
|
327
354
|
"named": true
|
package/tree-sitter-html.wasm
CHANGED
|
Binary file
|