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:
parent
7a0e24fbd4
commit
530fbff65a
23
grammar.js
23
grammar.js
|
|
@ -568,32 +568,17 @@ module.exports = grammar({
|
|||
comment: ($) => choice($.template_comment, $.html_comment),
|
||||
|
||||
// Template comments: @* ... *@
|
||||
template_comment: ($) =>
|
||||
seq(
|
||||
alias("@*", $.comment_start),
|
||||
optional($.comment_content),
|
||||
alias("*@", $.comment_end)
|
||||
),
|
||||
comment_content: ($) => /([^*]|\*[^@])*/,
|
||||
template_comment: ($) => /@\*([^*]|\*[^@])*\*@/,
|
||||
|
||||
// HTML comment: <!-- ... -->
|
||||
html_comment: ($) => seq("<!--", optional($.html_comment_content), "-->"),
|
||||
|
||||
html_comment_content: ($) => /([^-]|-[^-]|--[^>])*/,
|
||||
html_comment: ($) => /<!--([^-]|-[^-]|--[^>])*-->/,
|
||||
|
||||
// Raw blocks: @# ... #@
|
||||
raw_block: ($) =>
|
||||
seq(
|
||||
alias("@#", $.raw_start),
|
||||
optional($.raw_content),
|
||||
alias("#@", $.raw_end)
|
||||
),
|
||||
raw_content: ($) => /([^#]|#[^@])*/,
|
||||
raw_block: ($) => /@#([^#]|#[^@])*#@/,
|
||||
|
||||
// Embedded language blocks: @```lang ... ```@
|
||||
embedded_language: ($) =>
|
||||
seq("@```", $.language_name, optional($.embedded_content), "```@"),
|
||||
embedded_content: ($) => /([^`]|`[^`]|``[^`]|```[^@])*/,
|
||||
seq("@```", $.language_name, /([^`]|`[^`]|``[^`]|```[^@])*/, "```@"),
|
||||
|
||||
language_name: ($) =>
|
||||
choice("html", "css", "js", "javascript", "json", "alpine", "style"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue