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),
|
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"),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue