Simplify comment and raw block patterns to single regex

Remove alias() calls that referenced undefined rules, which
prevented proper node type generation. Use simple regex patterns
instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Michael Netshipise 2026-01-19 21:11:32 +02:00
parent 7a0e24fbd4
commit 530fbff65a
1 changed files with 4 additions and 19 deletions

View File

@ -568,32 +568,17 @@ module.exports = grammar({
comment: ($) => choice($.template_comment, $.html_comment), comment: ($) => choice($.template_comment, $.html_comment),
// Template comments: @* ... *@ // Template comments: @* ... *@
template_comment: ($) => template_comment: ($) => /@\*([^*]|\*[^@])*\*@/,
seq(
alias("@*", $.comment_start),
optional($.comment_content),
alias("*@", $.comment_end)
),
comment_content: ($) => /([^*]|\*[^@])*/,
// HTML comment: <!-- ... --> // HTML comment: <!-- ... -->
html_comment: ($) => seq("<!--", optional($.html_comment_content), "-->"), html_comment: ($) => /<!--([^-]|-[^-]|--[^>])*-->/,
html_comment_content: ($) => /([^-]|-[^-]|--[^>])*/,
// Raw blocks: @# ... #@ // Raw blocks: @# ... #@
raw_block: ($) => raw_block: ($) => /@#([^#]|#[^@])*#@/,
seq(
alias("@#", $.raw_start),
optional($.raw_content),
alias("#@", $.raw_end)
),
raw_content: ($) => /([^#]|#[^@])*/,
// Embedded language blocks: @```lang ... ```@ // Embedded language blocks: @```lang ... ```@
embedded_language: ($) => embedded_language: ($) =>
seq("@```", $.language_name, optional($.embedded_content), "```@"), seq("@```", $.language_name, /([^`]|`[^`]|``[^`]|```[^@])*/, "```@"),
embedded_content: ($) => /([^`]|`[^`]|``[^`]|```[^@])*/,
language_name: ($) => language_name: ($) =>
choice("html", "css", "js", "javascript", "json", "alpine", "style"), choice("html", "css", "js", "javascript", "json", "alpine", "style"),