Repository: tree-sitter/tree-sitter-html (language: python)

Issue:
Rust tree_sitter::Language error
Seems to have a different definition that is expected by the main parser.

```
error[E0308]: mismatched types
   --> src/svelte/parser.rs:30:29
    |
30  |         parser.set_language(tree_sitter_html::language()).expect("Error loading html grammar");
    |                ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `tree_sitter::Language`, found a different `tree_sitter::Language`
    |                |
    |                arguments to this method are incorrect
    |
    = note: `tree_sitter::Language` and `tree_sitter::Language` have similar names, but are actually distinct types
note: `tree_sitter::Language` is defined in crate `tree_sitter`
   --> /Users/koomen/.cargo/registry/src/github.com-1ecc6299db9ec823/tree-sitter-0.19.5/binding_rust/lib.rs:37:1
    |
37  | pub struct Language(*const ffi::TSLanguage);
    | ^^^^^^^^^^^^^^^^^^^
note: `tree_sitter::Language` is defined in crate `tree_sitter`
   --> /Users/koomen/.cargo/registry/src/github.com-1ecc6299db9ec823/tree-sitter-0.20.10/binding_rust/lib.rs:43:1
    |
43  | pub struct Language(*const ffi::TSLanguage);
    | ^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `tree_sitter` are being used?
note: method defined here
   --> /Users/koomen/.cargo/registry/src/github.com-1ecc6299db9ec823/tree-sitter-0.20.10/binding_rust/lib.rs:357:12
    |
357 |     pub fn set_language(&mut self, language: Language) -> Result<(), LanguageError> {
    |            ^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.
```

When I use tree-sitter-php, the `Language` is defined in:
```
/Users/koomen/.cargo/registry/src/github.com-1ecc6299db9ec823/tree-sitter-0.20.10/binding_rust/lib.rs
```

where as the tree-sitter-html Language type is defined in:
```
/Users/koomen/.cargo/registry/src/github.com-1ecc6299db9ec823/tree-sitter-0.19.5/binding_rust/lib.rs
```

so, it should be updated to use the latest tree-sitter parser.


Discussion / hints:
sure I'll create a new release soon

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 327630a..76b8879 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,7 +2,11 @@ name: CI
 on:
   workflow_dispatch:
   pull_request:
+    branches:
+      - "**"
   push:
+    branches:
+      - "master"
 
 jobs:
   test:
diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml
index 72bb0b8..16e04dc 100644
--- a/.github/workflows/fuzz.yml
+++ b/.github/workflows/fuzz.yml
@@ -1,10 +1,14 @@
 name: Fuzz Parser
 
 on:
-  push:
+  pull_request:
+    branches:
+      - "**"
     paths:
       - src/scanner.c
-  pull_request:
+  push:
+    branches:
+      - "master"
     paths:
       - src/scanner.c
   workflow_dispatch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..c2020e9
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,103 @@
+name: Release
+
+on:
+  workflow_run:
+    workflows: ["CI"]
+    branches:
+      - master
+    types:
+      - completed
+
+jobs:
+  release:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+
+      - name: Get previous commit SHA
+        id: get_previous_commit
+        run: |
+          LATEST_TAG=$(git describe --tags --abbrev=0)
+          if [[ -z "$LATEST_TAG" ]]; then
+            echo "No tag found. Failing..."
+            exit 1
+          fi
+          echo "latest_tag=${LATEST_TAG#v}" >> "$GITHUB_ENV" # Remove 'v' prefix from the tag
+
+      - name: Check if version changed and is greater than the previous
+        id: version_check
+        run: |
+          # Compare the current version with the version from the previous commit
+          PREVIOUS_NPM_VERSION=${{ env.latest_tag }}
+          CURRENT_NPM_VERSION=$(jq -r '.version' package.json)
+          CURRENT_CARGO_VERSION=$(awk -F '"' '/^version/ {print $2}' Cargo.toml)
+          if [[ "$CURRENT_NPM_VERSION" != "$CURRENT_CARGO_VERSION" ]]; then # Cargo.toml and package.json versions must match
+            echo "Mismatch: NPM version ($CURRENT_NPM_VERSION) and Cargo.toml version ($CURRENT_CARGO_VERSION)"
+            echo "version_changed=false" >> "$GITHUB_ENV"
+          else
+            if [[ "$PREVIOUS_NPM_VERSION" ==  "$CURRENT_NPM_VERSION" ]]; then
+              echo "version_changed=" >> "$GITHUB_ENV"
+            else
+              IFS='.' read -ra PREVIOUS_VERSION_PARTS <<< "$PREVIOUS_NPM_VERSION"
+              IFS='.' read -ra CURRENT_VERSION_PARTS <<< "$CURRENT_NPM_VERSION"
+              VERSION_CHANGED=false
+              for i in "${!PREVIOUS_VERSION_PARTS[@]}"; do
+                if [[ ${CURRENT_VERSION_PARTS[i]} -gt ${PREVIOUS_VERSION_PARTS[i]} ]]; then
+                  VERSION_CHANGED=true
+                  break
+                elif [[ ${CURRENT_VERSION_PARTS[i]} -lt ${PREVIOUS_VERSION_PARTS[i]} ]]; then
+                  break
+                fi
+              done
+
+              echo "version_changed=$VERSION_CHANGED" >> "$GITHUB_ENV"
+              echo "current_version=${CURRENT_NPM_VERSION}" >> "$GITHUB_ENV"
+            fi
+          fi
+
+      - name: Display result
+        run: |
+          echo "Version bump detected: ${{ env.version_changed }}"
+
+      - name: Fail if version is lower
+        if: env.version_changed == 'false'
+        run: exit 1
+
+      - name: Setup Node
+        if: env.version_changed == 'true'
+        uses: actions/setup-node@v3
+        with:
+          node-version: 18
+          registry-url: "https://registry.npmjs.org"
+      - name: Publish to NPM
+        if: env.version_changed == 'true'
+        env:
+          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
+        run: npm publish
+
+      - name: Setup Rust
+        if: env.version_changed == 'true'
+        uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - name: Publish to Crates.io
+        if: env.version_changed == 'true'
+        uses: katyo/publish-crates@v2
+        with:
+          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
+
+      - name: Tag versions
+        if: env.version_changed == 'true'
+        run: |
+          git checkout master
+          git config user.name github-actions[bot]
+          git config user.email github-actions[bot]@users.noreply.github.com
+          git tag -d "v${{ env.current_version }}" || true
+          git push origin --delete "v${{ env.current_version }}" || true
+          git tag -a "v${{ env.current_version }}" -m "Version ${{ env.current_version }}"
+          git push origin "v${{ env.current_version }}"
diff --git a/Cargo.toml b/Cargo.toml
index e65e954..2424917 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,25 +1,27 @@
 [package]
 name = "tree-sitter-html"
-description = "html grammar for the tree-sitter parsing library"
+description = "HTML grammar for tree-sitter"
 version = "0.19.0"
+authors = [
+	"Max Brunsfeld <maxbrunsfeld@gmail.com>",
+	"Amaan Qureshi <amaanq12@gmail.com>",
+]
+license = "MIT"
+readme = "bindings/rust/README.md"
 keywords = ["incremental", "parsing", "html"]
 categories = ["parsing", "text-editors"]
 repository = "https://github.com/tree-sitter/tree-sitter-html"
-edition = "2018"
+edition = "2021"
+autoexamples = false
 
 build = "bindings/rust/build.rs"
-include = [
-  "bindings/rust/*",
-  "grammar.js",
-  "queries/*",
-  "src/*",
-]
+include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
 
 [lib]
 path = "bindings/rust/lib.rs"
 
 [dependencies]
-tree-sitter = "0.19"
+tree-sitter = "~0.20.10"
 
 [build-dependencies]
-cc = "1.0"
+cc = "~1.0.83"
diff --git a/README.md b/README.md
index d06f73a..c2981f4 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,8 @@
-tree-sitter-html
-================
+# tree-sitter-html
 
-[![Build Status](https://travis-ci.org/tree-sitter/tree-sitter-html.svg?branch=master)](https://travis-ci.org/tree-sitter/tree-sitter-html)
-[![Build status](https://ci.appveyor.com/api/projects/status/bv1i8f3yi2aoyonx/branch/master?svg=true)](https://ci.appveyor.com/project/maxbrunsfeld/tree-sitter-html/branch/master)
+[![build](https://github.com/tree-sitter/tree-sitter-html/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-html/actions/workflows/ci.yml)
 
-HTML grammar for [tree-sitter][].
-
-[tree-sitter]: https://github.com/tree-sitter/tree-sitter
+HTML grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
 
 References
 
diff --git a/bindings/node/index.js b/bindings/node/index.js
index 801b0d0..35d48f5 100644
--- a/bindings/node/index.js
+++ b/bindings/node/index.js
@@ -1,19 +1,19 @@
 try {
-  module.exports = require("../../build/Release/tree_sitter_html_binding");
+  module.exports = require('../../build/Release/tree_sitter_html_binding');
 } catch (error1) {
   if (error1.code !== 'MODULE_NOT_FOUND') {
     throw error1;
   }
   try {
-    module.exports = require("../../build/Debug/tree_sitter_html_binding");
+    module.exports = require('../../build/Debug/tree_sitter_html_binding');
   } catch (error2) {
     if (error2.code !== 'MODULE_NOT_FOUND') {
       throw error2;
     }
-    throw error1
+    throw error1;
   }
 }
 
 try {
-  module.exports.nodeTypeInfo = require("../../src/node-types.json");
+  module.exports.nodeTypeInfo = require('../../src/node-types.json');
 } catch (_) {}
diff --git a/bindings/rust/README.md b/bindings/rust/README.md
new file mode 100644
index 0000000..7b10b01
--- /dev/null
+++ b/bindings/rust/README.md
@@ -0,0 +1,35 @@
+# tree-sitter-html
+
+This crate provides a HTML grammar for the [tree-sitter][] parsing library.
+To use this crate, add it to the `[dependencies]` section of your `Cargo.toml`
+file. (Note that you will probably also need to depend on the
+[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful
+way.)
+
+```toml
+[dependencies]
+tree-sitter = "0.20.10"
+tree-sitter-html = "0.19.0"
+```
+
+Typically, you will use the [language][language func] function to add this
+grammar to a tree-sitter [Parser][], and then use the parser to parse some code:
+
+```rust
+let code = r#"
+    def double(x):
+        return x * 2
+"#;
+let mut parser = Parser::new();
+parser.set_language(tree_sitter_html::language()).expect("Error loading HTML grammar");
+let parsed = parser.parse(code, None);
+```
+
+If you have any questions, please reach out to us in the [tree-sitter
+discussions] page.
+
+[language func]: https://docs.rs/tree-sitter-html/*/tree_sitter_html/fn.language.html
+[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
+[tree-sitter]: https://tree-sitter.github.io/
+[tree-sitter crate]: https://crates.io/crates/tree-sitter
+[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions
diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs
index 88b6abd..25c69f9 100644
--- a/bindings/rust/lib.rs
+++ b/bindings/rust/lib.rs
@@ -1,4 +1,4 @@
-//! This crate provides html language support for the [tree-sitter][] parsing library.
+//! This crate provides HTML language support for the [tree-sitter][] parsing library.
 //!
 //! Typically, you will use the [language][language func] function to add this language to a
 //! tree-sitter [Parser][], and then use the parser to parse some code:
@@ -6,7 +6,7 @@
 //! ```
 //! let code = "";
 //! let mut parser = tree_sitter::Parser::new();
-//! parser.set_language(tree_sitter_html::language()).expect("Error loading html grammar");
+//! parser.set_language(tree_sitter_html::language()).expect("Error loading HTML grammar");
 //! let tree = parser.parse(code, None).unwrap();
 //! ```
 //!
@@ -31,12 +31,10 @@ pub fn language() -> Language {
 /// The content of the [`node-types.json`][] file for this grammar.
 ///
 /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
-pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
+pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");
 
-// Uncomment these to include any queries that this grammar contains
-
-// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
-// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
+pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm");
+pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm");
 // pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
 // pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
 
@@ -47,6 +45,6 @@ mod tests {
         let mut parser = tree_sitter::Parser::new();
         parser
             .set_language(super::language())
-            .expect("Error loading html language");
+            .expect("Error loading HTML grammar");
     }
 }
diff --git a/package.json b/package.json
index f48f6b3..6b979da 100644
--- a/package.json
+++ b/package.json
@@ -7,20 +7,25 @@
     "parser",
     "lexer"
   ],
+  "homepage": "https://github.com/tree-sitter/tree-sitter-html",
   "repository": {
     "type": "git",
     "url": "https://github.com/tree-sitter/tree-sitter-html.git"
   },
+  "bugs": {
+    "url": "https://github.com/tree-sitter/tree-sitter-html/issues"
+  },
   "authors": [
     "Max Brunsfeld <maxbrunsfeld@gmail.com>",
-    "Ashi Krishnan <queerviolet@github.com>"
+    "Ashi Krishnan <queerviolet@github.com>",
+    "Amaan Qureshi <amaanq12@gmail.com>"
   ],
   "license": "MIT",
   "dependencies": {
-    "nan": "^2.14.0"
+    "nan": "^2.18.0"
   },
   "devDependencies": {
-    "eslint": "^8.43.0",
+    "eslint": "^8.50.0",
     "eslint-config-google": "^0.14.0",
     "tree-sitter-cli": "^0.20.8"
   },
@@ -36,7 +41,13 @@
       "file-types": [
         "html"
       ],
-      "injection-regex": "html"
+      "injection-regex": "html",
+      "highlights": [
+        "queries/highlights.scm"
+      ],
+      "injections": [
+        "queries/injections.scm"
+      ]
     }
   ]
 }
diff --git a/src/parser.c b/src/parser.c
index 788fb40..a229d71 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1,4 +1,4 @@
-#include <tree_sitter/parser.h>
+#include "tree_sitter/parser.h"
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
@@ -16,7 +16,7 @@
 #define MAX_ALIAS_SEQUENCE_LENGTH 4
 #define PRODUCTION_ID_COUNT 1
 
-enum {
+enum ts_symbol_identifiers {
   anon_sym_LT_BANG = 1,
   aux_sym_doctype_token1 = 2,
   anon_sym_GT = 3,
@@ -421,7 +421,6 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
 
 static bool ts_lex(TSLexer *lexer, TSStateId state) {
   START_LEXER();
-  eof = lexer->eof(lexer);
   switch (state) {
     case 0:
       if (eof) ADVANCE(57);
@@ -434,26 +433,20 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       if (lookahead == '>') ADVANCE(61);
       if (lookahead == 'D' ||
           lookahead == 'd') ADVANCE(48);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') SKIP(0)
       END_STATE();
     case 1:
       if (lookahead == '"') ADVANCE(73);
       if (lookahead == '\'') ADVANCE(70);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') SKIP(1)
       if (lookahead != 0 &&
           (lookahead < '<' || '>' < lookahead)) ADVANCE(68);
       END_STATE();
     case 2:
       if (lookahead == '"') ADVANCE(73);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(74);
       if (lookahead != 0) ADVANCE(75);
       END_STATE();
@@ -464,9 +457,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       END_STATE();
     case 4:
       if (lookahead == '\'') ADVANCE(70);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(71);
       if (lookahead != 0) ADVANCE(72);
       END_STATE();
@@ -474,9 +465,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       if (lookahead == '/') ADVANCE(45);
       if (lookahead == '=') ADVANCE(66);
       if (lookahead == '>') ADVANCE(61);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') SKIP(5)
       if (lookahead != 0 &&
           lookahead != '"' &&
@@ -710,9 +699,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
           lookahead == 'y') ADVANCE(49);
       END_STATE();
     case 53:
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(53);
       if (lookahead != 0 &&
           lookahead != '&' &&
@@ -720,9 +707,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
           lookahead != '>') ADVANCE(76);
       END_STATE();
     case 54:
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(59);
       if (lookahead != 0 &&
           lookahead != '>') ADVANCE(60);
@@ -736,9 +721,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       if (eof) ADVANCE(57);
       if (lookahead == '&') ADVANCE(3);
       if (lookahead == '<') ADVANCE(63);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') SKIP(56)
       if (lookahead != 0 &&
           lookahead != '>') ADVANCE(76);
@@ -751,9 +734,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       END_STATE();
     case 59:
       ACCEPT_TOKEN(aux_sym_doctype_token1);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(59);
       if (lookahead != 0 &&
           lookahead != '>') ADVANCE(60);
@@ -786,9 +767,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
     case 67:
       ACCEPT_TOKEN(sym_attribute_name);
       if (lookahead != 0 &&
-          lookahead != '\t' &&
-          lookahead != '\n' &&
-          lookahead != '\r' &&
+          (lookahead < '\t' || '\r' < lookahead) &&
           lookahead != ' ' &&
           lookahead != '"' &&
           lookahead != '\'' &&
@@ -798,9 +777,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
     case 68:
       ACCEPT_TOKEN(sym_attribute_value);
       if (lookahead != 0 &&
-          lookahead != '\t' &&
-          lookahead != '\n' &&
-          lookahead != '\r' &&
+          (lookahead < '\t' || '\r' < lookahead) &&
           lookahead != ' ' &&
           lookahead != '"' &&
           lookahead != '\'' &&
@@ -814,9 +791,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       END_STATE();
     case 71:
       ACCEPT_TOKEN(aux_sym_quoted_attribute_value_token1);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(71);
       if (lookahead != 0 &&
           lookahead != '\'') ADVANCE(72);
@@ -831,9 +806,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       END_STATE();
     case 74:
       ACCEPT_TOKEN(aux_sym_quoted_attribute_value_token2);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(74);
       if (lookahead != 0 &&
           lookahead != '"') ADVANCE(75);
@@ -845,9 +818,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
       END_STATE();
     case 76:
       ACCEPT_TOKEN(sym_text);
-      if (lookahead == '\t' ||
-          lookahead == '\n' ||
-          lookahead == '\r' ||
+      if (('\t' <= lookahead && lookahead <= '\r') ||
           lookahead == ' ') ADVANCE(53);
       if (lookahead != 0 &&
           lookahead != '&' &&
@@ -956,78 +927,6 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = {
   [93] = {.lex_state = 0, .external_lex_state = 2},
 };
 
-enum {
-  ts_external_token__start_tag_name = 0,
-  ts_external_token__script_start_tag_name = 1,
-  ts_external_token__style_start_tag_name = 2,
-  ts_external_token__end_tag_name = 3,
-  ts_external_token_erroneous_end_tag_name = 4,
-  ts_external_token_SLASH_GT = 5,
-  ts_external_token__implicit_end_tag = 6,
-  ts_external_token_raw_text = 7,
-  ts_external_token_comment = 8,
-};
-
-static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
-  [ts_external_token__start_tag_name] = sym__start_tag_name,
-  [ts_external_token__script_start_tag_name] = sym__script_start_tag_name,
-  [ts_external_token__style_start_tag_name] = sym__style_start_tag_name,
-  [ts_external_token__end_tag_name] = sym__end_tag_name,
-  [ts_external_token_erroneous_end_tag_name] = sym_erroneous_end_tag_name,
-  [ts_external_token_SLASH_GT] = anon_sym_SLASH_GT,
-  [ts_external_token__implicit_end_tag] = sym__implicit_end_tag,
-  [ts_external_token_raw_text] = sym_raw_text,
-  [ts_external_token_comment] = sym_comment,
-};
-
-static const bool ts_external_scanner_states[10][EXTERNAL_TOKEN_COUNT] = {
-  [1] = {
-    [ts_external_token__start_tag_name] = true,
-    [ts_external_token__script_start_tag_name] = true,
-    [ts_external_token__style_start_tag_name] = true,
-    [ts_external_token__end_tag_name] = true,
-    [ts_external_token_erroneous_end_tag_name] = true,
-    [ts_external_token_SLASH_GT] = true,
-    [ts_external_token__implicit_end_tag] = true,
-    [ts_external_token_raw_text] = true,
-    [ts_external_token_comment] = true,
-  },
-  [2] = {
-    [ts_external_token_comment] = true,
-  },
-  [3] = {
-    [ts_external_token__implicit_end_tag] = true,
-    [ts_external_token_comment] = true,
-  },
-  [4] = {
-    [ts_external_token_SLASH_GT] = true,
-    [ts_external_token_comment] = true,
-  },
-  [5] = {
-    [ts_external_token__start_tag_name] = true,
-    [ts_external_token__script_start_tag_name] = true,
-    [ts_external_token__style_start_tag_name] = true,
-    [ts_external_token_comment] = true,
-  },
-  [6] = {
-    [ts_external_token_raw_text] = true,
-    [ts_external_token_comment] = true,
-  },
-  [7] = {
-    [ts_external_token__end_tag_name] = true,
-    [ts_external_token_erroneous_end_tag_name] = true,
-    [ts_external_token_comment] = true,
-  },
-  [8] = {
-    [ts_external_token_erroneous_end_tag_name] = true,
-    [ts_external_token_comment] = true,
-  },
-  [9] = {
-    [ts_external_token__end_tag_name] = true,
-    [ts_external_token_comment] = true,
-  },
-};
-
 static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
   [0] = {
     [ts_builtin_sym_end] = ACTIONS(1),
@@ -2230,6 +2129,78 @@ static const TSParseActionEntry ts_parse_actions[] = {
   [251] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90),
 };
 
+enum ts_external_scanner_symbol_identifiers {
+  ts_external_token__start_tag_name = 0,
+  ts_external_token__script_start_tag_name = 1,
+  ts_external_token__style_start_tag_name = 2,
+  ts_external_token__end_tag_name = 3,
+  ts_external_token_erroneous_end_tag_name = 4,
+  ts_external_token_SLASH_GT = 5,
+  ts_external_token__implicit_end_tag = 6,
+  ts_external_token_raw_text = 7,
+  ts_external_token_comment = 8,
+};
+
+static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
+  [ts_external_token__start_tag_name] = sym__start_tag_name,
+  [ts_external_token__script_start_tag_name] = sym__script_start_tag_name,
+  [ts_external_token__style_start_tag_name] = sym__style_start_tag_name,
+  [ts_external_token__end_tag_name] = sym__end_tag_name,
+  [ts_external_token_erroneous_end_tag_name] = sym_erroneous_end_tag_name,
+  [ts_external_token_SLASH_GT] = anon_sym_SLASH_GT,
+  [ts_external_token__implicit_end_tag] = sym__implicit_end_tag,
+  [ts_external_token_raw_text] = sym_raw_text,
+  [ts_external_token_comment] = sym_comment,
+};
+
+static const bool ts_external_scanner_states[10][EXTERNAL_TOKEN_COUNT] = {
+  [1] = {
+    [ts_external_token__start_tag_name] = true,
+    [ts_external_token__script_start_tag_name] = true,
+    [ts_external_token__style_start_tag_name] = true,
+    [ts_external_token__end_tag_name] = true,
+    [ts_external_token_erroneous_end_tag_name] = true,
+    [ts_external_token_SLASH_GT] = true,
+    [ts_external_token__implicit_end_tag] = true,
+    [ts_external_token_raw_text] = true,
+    [ts_external_token_comment] = true,
+  },
+  [2] = {
+    [ts_external_token_comment] = true,
+  },
+  [3] = {
+    [ts_external_token__implicit_end_tag] = true,
+    [ts_external_token_comment] = true,
+  },
+  [4] = {
+    [ts_external_token_SLASH_GT] = true,
+    [ts_external_token_comment] = true,
+  },
+  [5] = {
+    [ts_external_token__start_tag_name] = true,
+    [ts_external_token__script_start_tag_name] = true,
+    [ts_external_token__style_start_tag_name] = true,
+    [ts_external_token_comment] = true,
+  },
+  [6] = {
+    [ts_external_token_raw_text] = true,
+    [ts_external_token_comment] = true,
+  },
+  [7] = {
+    [ts_external_token__end_tag_name] = true,
+    [ts_external_token_erroneous_end_tag_name] = true,
+    [ts_external_token_comment] = true,
+  },
+  [8] = {
+    [ts_external_token_erroneous_end_tag_name] = true,
+    [ts_external_token_comment] = true,
+  },
+  [9] = {
+    [ts_external_token__end_tag_name] = true,
+    [ts_external_token_comment] = true,
+  },
+};
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/scanner.c b/src/scanner.c
index 0148702..9ec2915 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1,4 +1,5 @@
 #include "tag.h"
+
 #include <wctype.h>
 
 enum TokenType {
@@ -368,15 +369,15 @@ static bool scan_self_closing_tag_delimiter(Scanner *scanner, TSLexer *lexer) {
 }
 
 static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
-    while (iswspace(lexer->lookahead)) {
-        lexer->advance(lexer, true);
-    }
-
     if (valid_symbols[RAW_TEXT] && !valid_symbols[START_TAG_NAME] &&
         !valid_symbols[END_TAG_NAME]) {
         return scan_raw_text(scanner, lexer);
     }
 
+    while (iswspace(lexer->lookahead)) {
+        lexer->advance(lexer, true);
+    }
+
     switch (lexer->lookahead) {
         case '<':
             lexer->mark_end(lexer);
diff --git a/src/tag.h b/src/tag.h
index de2a9c6..f20591a 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -1,4 +1,5 @@
 #include "tree_sitter/parser.h"
+
 #include <assert.h>
 #include <string.h>
 
@@ -288,7 +289,7 @@ static const TagType TAG_TYPES_NOT_ALLOWED_IN_PARAGRAPHS[] = {
     NAV,      OL,         P,      PRE,        SECTION,
 };
 
-TagType get_tag_from_string(const char *tag_name) {
+static TagType get_tag_from_string(const char *tag_name) {
     for (int i = 0; i < 126; i++) {
         if (strcmp(TAG_TYPES_BY_TAG_NAME[i].tag_name, tag_name) == 0) {
             return TAG_TYPES_BY_TAG_NAME[i].tag_value;
@@ -306,7 +307,7 @@ static inline Tag new_tag() {
     return tag;
 }
 
-Tag make_tag(TagType type, const char *name) {
+static Tag make_tag(TagType type, const char *name) {
     Tag tag = new_tag();
     tag.type = type;
     if (type == CUSTOM) {
@@ -340,7 +341,7 @@ static inline bool tagcmp(const Tag *_tag1, const Tag *_tag2) {
                                   : true);
 }
 
-bool can_contain(Tag *self, const Tag *other) {
+static bool can_contain(Tag *self, const Tag *other) {
     TagType child = other->type;
 
     switch (self->type) {
diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h
index 2b14ac1..d210325 100644
--- a/src/tree_sitter/parser.h
+++ b/src/tree_sitter/parser.h
@@ -13,9 +13,8 @@ extern "C" {
 #define ts_builtin_sym_end 0
 #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
 
-typedef uint16_t TSStateId;
-
 #ifndef TREE_SITTER_API_H_
+typedef uint16_t TSStateId;
 typedef uint16_t TSSymbol;
 typedef uint16_t TSFieldId;
 typedef struct TSLanguage TSLanguage;
@@ -140,7 +139,8 @@ struct TSLanguage {
   lexer->advance(lexer, skip);  \
   start:                        \
   skip = false;                 \
-  lookahead = lexer->lookahead;
+  lookahead = lexer->lookahead; \
+  eof = lexer->eof(lexer);
 
 #define ADVANCE(state_value) \
   {                          \
@@ -166,7 +166,7 @@ struct TSLanguage {
  *  Parse Table Macros
  */
 
-#define SMALL_STATE(id) id - LARGE_STATE_COUNT
+#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
 
 #define STATE(id) id
 
@@ -176,7 +176,7 @@ struct TSLanguage {
   {{                                  \
     .shift = {                        \
       .type = TSParseActionTypeShift, \
-      .state = state_value            \
+      .state = (state_value)          \
     }                                 \
   }}
 
@@ -184,7 +184,7 @@ struct TSLanguage {
   {{                                  \
     .shift = {                        \
       .type = TSParseActionTypeShift, \
-      .state = state_value,           \
+      .state = (state_value),         \
       .repetition = true              \
     }                                 \
   }}


Test patch:
diff --git a/corpus/main.txt b/test/corpus/main.txt
similarity index 100%
rename from corpus/main.txt
rename to test/corpus/main.txt