@willbooster/tree-sitter-html 1.0.6 → 2.0.1

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,13 +14,13 @@ 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, so it loads only with the WillBooster runtime, version 2.0.0 or later
17
+ number, so it loads only with the WillBooster runtime, version 2.0.0 or later in the 2.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
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. Its scanner requires an HTML tag-name boundary after
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. Its scanner requires an HTML tag-name boundary after
24
24
  `</script` and `</style`, so longer names and overlapping prefixes remain raw text. Closing-name comparisons
25
25
  fold only ASCII letters, and embedded NUL characters remain part of raw-text content. Script content follows
26
26
  HTML escaped and double-escaped states, so closing-tag text inside a double escape remains raw text. A script that reaches
@@ -37,7 +37,7 @@ Malformed input after a void element can replace its enclosing element with an `
37
37
  ## Usage
38
38
 
39
39
  The npm package ships `tree-sitter-html.wasm` for
40
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 2.0.0 or later, which runs in Node.js, Bun, browsers, and Cloudflare Workers. In Node.js and Bun, load the grammar from its path:
40
+ [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 2.0.0 or later in the 2.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers. In Node.js and Bun, load the grammar from its path:
41
41
 
42
42
  ```js
43
43
  import { fileURLToPath } from 'node:url';
@@ -84,7 +84,7 @@ fuzzed with:
84
84
  ```toml
85
85
  [dependencies]
86
86
  tree-sitter = { package = "willbooster-tree-sitter", version = "2.0.0" }
87
- tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "1" }
87
+ tree-sitter-html = { package = "willbooster-tree-sitter-html", version = "2" }
88
88
  ```
89
89
 
90
90
  ```rust
package/grammar.js CHANGED
@@ -126,14 +126,13 @@ module.exports = grammar({
126
126
 
127
127
  attribute_value: _ => /[^<>"'=\s]+/,
128
128
 
129
- // HTML fixes the named-reference set: https://html.spec.whatwg.org/multipage/named-characters.html
130
- entity: _ => /&(#([xX][0-9a-fA-F]{1,6}|[0-9]{1,5})|[A-Za-z]{1,30});?/,
129
+ entity: _ => token(/&(#([xX][0-9a-fA-F]+|[0-9]+)|[A-Za-z][A-Za-z0-9]*);?/),
131
130
 
132
131
  quoted_attribute_value: $ => choice(
133
132
  seq('\'', optional(alias(/[^']+/, $.attribute_value)), '\''),
134
133
  seq('"', optional(alias(/[^"]+/, $.attribute_value)), '"'),
135
134
  ),
136
135
 
137
- text: _ => /[^<&\s]([^<&]*[^<&\s])?|&/,
136
+ text: _ => token.immediate(/[^<&]+|&/),
138
137
  },
139
138
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-html",
3
- "version": "1.0.6",
3
+ "version": "2.0.1",
4
4
  "description": "HTML grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -18,7 +18,7 @@
18
18
  }
19
19
  ],
20
20
  "metadata": {
21
- "version": "1.0.6",
21
+ "version": "2.0.1",
22
22
  "license": "MIT",
23
23
  "description": "HTML grammar for tree-sitter",
24
24
  "authors": [