Add numbered comment and raw block variants (1-22)

This commit is contained in:
Michael Netshipise 2026-01-19 22:02:08 +02:00
parent 9562d988be
commit 600c0eeff4
3 changed files with 452 additions and 5 deletions

View File

@ -567,14 +567,62 @@ module.exports = grammar({
// Comments
comment: ($) => choice($.template_comment, $.html_comment),
// Template comments: @* ... *@
template_comment: ($) => /@\*([^*]|\*[^@])*\*@/,
// Template comments: @* ... *@ with varying asterisk counts
template_comment: ($) => choice(
...Array.from({ length: 22 }, (_, i) => $[`template_comment_${i + 1}`])
),
template_comment_1: ($) => /@\*([^*]|\*[^@])*\*@/,
template_comment_2: ($) => /@\*\*([^*]|\*[^*]|\*\*[^@])*\*\*@/,
template_comment_3: ($) => /@\*\*\*([^*]|\*[^*]|\*\*[^*]|\*\*\*[^@])*\*\*\*@/,
template_comment_4: ($) => /@\*{4}([^*]|\*{1,3}[^*]|\*{4}[^@])*\*{4}@/,
template_comment_5: ($) => /@\*{5}([^*]|\*{1,4}[^*]|\*{5}[^@])*\*{5}@/,
template_comment_6: ($) => /@\*{6}([^*]|\*{1,5}[^*]|\*{6}[^@])*\*{6}@/,
template_comment_7: ($) => /@\*{7}([^*]|\*{1,6}[^*]|\*{7}[^@])*\*{7}@/,
template_comment_8: ($) => /@\*{8}([^*]|\*{1,7}[^*]|\*{8}[^@])*\*{8}@/,
template_comment_9: ($) => /@\*{9}([^*]|\*{1,8}[^*]|\*{9}[^@])*\*{9}@/,
template_comment_10: ($) => /@\*{10}([^*]|\*{1,9}[^*]|\*{10}[^@])*\*{10}@/,
template_comment_11: ($) => /@\*{11}([^*]|\*{1,10}[^*]|\*{11}[^@])*\*{11}@/,
template_comment_12: ($) => /@\*{12}([^*]|\*{1,11}[^*]|\*{12}[^@])*\*{12}@/,
template_comment_13: ($) => /@\*{13}([^*]|\*{1,12}[^*]|\*{13}[^@])*\*{13}@/,
template_comment_14: ($) => /@\*{14}([^*]|\*{1,13}[^*]|\*{14}[^@])*\*{14}@/,
template_comment_15: ($) => /@\*{15}([^*]|\*{1,14}[^*]|\*{15}[^@])*\*{15}@/,
template_comment_16: ($) => /@\*{16}([^*]|\*{1,15}[^*]|\*{16}[^@])*\*{16}@/,
template_comment_17: ($) => /@\*{17}([^*]|\*{1,16}[^*]|\*{17}[^@])*\*{17}@/,
template_comment_18: ($) => /@\*{18}([^*]|\*{1,17}[^*]|\*{18}[^@])*\*{18}@/,
template_comment_19: ($) => /@\*{19}([^*]|\*{1,18}[^*]|\*{19}[^@])*\*{19}@/,
template_comment_20: ($) => /@\*{20}([^*]|\*{1,19}[^*]|\*{20}[^@])*\*{20}@/,
template_comment_21: ($) => /@\*{21}([^*]|\*{1,20}[^*]|\*{21}[^@])*\*{21}@/,
template_comment_22: ($) => /@\*{22}([^*]|\*{1,21}[^*]|\*{22}[^@])*\*{22}@/,
// HTML comment: <!-- ... -->
html_comment: ($) => /<!--([^-]|-[^-]|--[^>])*-->/,
// Raw blocks: @# ... #@
raw_block: ($) => /@#([^#]|#[^@])*#@/,
// Raw blocks: @# ... #@ with varying hash counts
raw_block: ($) => choice(
...Array.from({ length: 22 }, (_, i) => $[`raw_block_${i + 1}`])
),
raw_block_1: ($) => /@#([^#]|#[^@])*#@/,
raw_block_2: ($) => /@##([^#]|#[^#]|##[^@])*##@/,
raw_block_3: ($) => /@###([^#]|#{1,2}[^#]|###[^@])*###@/,
raw_block_4: ($) => /@#{4}([^#]|#{1,3}[^#]|#{4}[^@])*#{4}@/,
raw_block_5: ($) => /@#{5}([^#]|#{1,4}[^#]|#{5}[^@])*#{5}@/,
raw_block_6: ($) => /@#{6}([^#]|#{1,5}[^#]|#{6}[^@])*#{6}@/,
raw_block_7: ($) => /@#{7}([^#]|#{1,6}[^#]|#{7}[^@])*#{7}@/,
raw_block_8: ($) => /@#{8}([^#]|#{1,7}[^#]|#{8}[^@])*#{8}@/,
raw_block_9: ($) => /@#{9}([^#]|#{1,8}[^#]|#{9}[^@])*#{9}@/,
raw_block_10: ($) => /@#{10}([^#]|#{1,9}[^#]|#{10}[^@])*#{10}@/,
raw_block_11: ($) => /@#{11}([^#]|#{1,10}[^#]|#{11}[^@])*#{11}@/,
raw_block_12: ($) => /@#{12}([^#]|#{1,11}[^#]|#{12}[^@])*#{12}@/,
raw_block_13: ($) => /@#{13}([^#]|#{1,12}[^#]|#{13}[^@])*#{13}@/,
raw_block_14: ($) => /@#{14}([^#]|#{1,13}[^#]|#{14}[^@])*#{14}@/,
raw_block_15: ($) => /@#{15}([^#]|#{1,14}[^#]|#{15}[^@])*#{15}@/,
raw_block_16: ($) => /@#{16}([^#]|#{1,15}[^#]|#{16}[^@])*#{16}@/,
raw_block_17: ($) => /@#{17}([^#]|#{1,16}[^#]|#{17}[^@])*#{17}@/,
raw_block_18: ($) => /@#{18}([^#]|#{1,17}[^#]|#{18}[^@])*#{18}@/,
raw_block_19: ($) => /@#{19}([^#]|#{1,18}[^#]|#{19}[^@])*#{19}@/,
raw_block_20: ($) => /@#{20}([^#]|#{1,19}[^#]|#{20}[^@])*#{20}@/,
raw_block_21: ($) => /@#{21}([^#]|#{1,20}[^#]|#{21}[^@])*#{21}@/,
raw_block_22: ($) => /@#{22}([^#]|#{1,21}[^#]|#{22}[^@])*#{22}@/,
// Embedded language blocks: @```lang ... ```@
embedded_language: ($) =>

View File

@ -1,9 +1,54 @@
; Waltzing Template Highlights
; Comments
(template_comment) @comment
(template_comment_1) @comment
(template_comment_2) @comment
(template_comment_3) @comment
(template_comment_4) @comment
(template_comment_5) @comment
(template_comment_6) @comment
(template_comment_7) @comment
(template_comment_8) @comment
(template_comment_9) @comment
(template_comment_10) @comment
(template_comment_11) @comment
(template_comment_12) @comment
(template_comment_13) @comment
(template_comment_14) @comment
(template_comment_15) @comment
(template_comment_16) @comment
(template_comment_17) @comment
(template_comment_18) @comment
(template_comment_19) @comment
(template_comment_20) @comment
(template_comment_21) @comment
(template_comment_22) @comment
(html_comment) @comment
; Raw blocks
(raw_block_1) @string.special
(raw_block_2) @string.special
(raw_block_3) @string.special
(raw_block_4) @string.special
(raw_block_5) @string.special
(raw_block_6) @string.special
(raw_block_7) @string.special
(raw_block_8) @string.special
(raw_block_9) @string.special
(raw_block_10) @string.special
(raw_block_11) @string.special
(raw_block_12) @string.special
(raw_block_13) @string.special
(raw_block_14) @string.special
(raw_block_15) @string.special
(raw_block_16) @string.special
(raw_block_17) @string.special
(raw_block_18) @string.special
(raw_block_19) @string.special
(raw_block_20) @string.special
(raw_block_21) @string.special
(raw_block_22) @string.special
; Keywords
"@use" @keyword
"@import" @keyword

View File

@ -2757,17 +2757,371 @@
]
},
"template_comment": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "template_comment_1"
},
{
"type": "SYMBOL",
"name": "template_comment_2"
},
{
"type": "SYMBOL",
"name": "template_comment_3"
},
{
"type": "SYMBOL",
"name": "template_comment_4"
},
{
"type": "SYMBOL",
"name": "template_comment_5"
},
{
"type": "SYMBOL",
"name": "template_comment_6"
},
{
"type": "SYMBOL",
"name": "template_comment_7"
},
{
"type": "SYMBOL",
"name": "template_comment_8"
},
{
"type": "SYMBOL",
"name": "template_comment_9"
},
{
"type": "SYMBOL",
"name": "template_comment_10"
},
{
"type": "SYMBOL",
"name": "template_comment_11"
},
{
"type": "SYMBOL",
"name": "template_comment_12"
},
{
"type": "SYMBOL",
"name": "template_comment_13"
},
{
"type": "SYMBOL",
"name": "template_comment_14"
},
{
"type": "SYMBOL",
"name": "template_comment_15"
},
{
"type": "SYMBOL",
"name": "template_comment_16"
},
{
"type": "SYMBOL",
"name": "template_comment_17"
},
{
"type": "SYMBOL",
"name": "template_comment_18"
},
{
"type": "SYMBOL",
"name": "template_comment_19"
},
{
"type": "SYMBOL",
"name": "template_comment_20"
},
{
"type": "SYMBOL",
"name": "template_comment_21"
},
{
"type": "SYMBOL",
"name": "template_comment_22"
}
]
},
"template_comment_1": {
"type": "PATTERN",
"value": "@\\*([^*]|\\*[^@])*\\*@"
},
"template_comment_2": {
"type": "PATTERN",
"value": "@\\*\\*([^*]|\\*[^*]|\\*\\*[^@])*\\*\\*@"
},
"template_comment_3": {
"type": "PATTERN",
"value": "@\\*\\*\\*([^*]|\\*[^*]|\\*\\*[^*]|\\*\\*\\*[^@])*\\*\\*\\*@"
},
"template_comment_4": {
"type": "PATTERN",
"value": "@\\*{4}([^*]|\\*{1,3}[^*]|\\*{4}[^@])*\\*{4}@"
},
"template_comment_5": {
"type": "PATTERN",
"value": "@\\*{5}([^*]|\\*{1,4}[^*]|\\*{5}[^@])*\\*{5}@"
},
"template_comment_6": {
"type": "PATTERN",
"value": "@\\*{6}([^*]|\\*{1,5}[^*]|\\*{6}[^@])*\\*{6}@"
},
"template_comment_7": {
"type": "PATTERN",
"value": "@\\*{7}([^*]|\\*{1,6}[^*]|\\*{7}[^@])*\\*{7}@"
},
"template_comment_8": {
"type": "PATTERN",
"value": "@\\*{8}([^*]|\\*{1,7}[^*]|\\*{8}[^@])*\\*{8}@"
},
"template_comment_9": {
"type": "PATTERN",
"value": "@\\*{9}([^*]|\\*{1,8}[^*]|\\*{9}[^@])*\\*{9}@"
},
"template_comment_10": {
"type": "PATTERN",
"value": "@\\*{10}([^*]|\\*{1,9}[^*]|\\*{10}[^@])*\\*{10}@"
},
"template_comment_11": {
"type": "PATTERN",
"value": "@\\*{11}([^*]|\\*{1,10}[^*]|\\*{11}[^@])*\\*{11}@"
},
"template_comment_12": {
"type": "PATTERN",
"value": "@\\*{12}([^*]|\\*{1,11}[^*]|\\*{12}[^@])*\\*{12}@"
},
"template_comment_13": {
"type": "PATTERN",
"value": "@\\*{13}([^*]|\\*{1,12}[^*]|\\*{13}[^@])*\\*{13}@"
},
"template_comment_14": {
"type": "PATTERN",
"value": "@\\*{14}([^*]|\\*{1,13}[^*]|\\*{14}[^@])*\\*{14}@"
},
"template_comment_15": {
"type": "PATTERN",
"value": "@\\*{15}([^*]|\\*{1,14}[^*]|\\*{15}[^@])*\\*{15}@"
},
"template_comment_16": {
"type": "PATTERN",
"value": "@\\*{16}([^*]|\\*{1,15}[^*]|\\*{16}[^@])*\\*{16}@"
},
"template_comment_17": {
"type": "PATTERN",
"value": "@\\*{17}([^*]|\\*{1,16}[^*]|\\*{17}[^@])*\\*{17}@"
},
"template_comment_18": {
"type": "PATTERN",
"value": "@\\*{18}([^*]|\\*{1,17}[^*]|\\*{18}[^@])*\\*{18}@"
},
"template_comment_19": {
"type": "PATTERN",
"value": "@\\*{19}([^*]|\\*{1,18}[^*]|\\*{19}[^@])*\\*{19}@"
},
"template_comment_20": {
"type": "PATTERN",
"value": "@\\*{20}([^*]|\\*{1,19}[^*]|\\*{20}[^@])*\\*{20}@"
},
"template_comment_21": {
"type": "PATTERN",
"value": "@\\*{21}([^*]|\\*{1,20}[^*]|\\*{21}[^@])*\\*{21}@"
},
"template_comment_22": {
"type": "PATTERN",
"value": "@\\*{22}([^*]|\\*{1,21}[^*]|\\*{22}[^@])*\\*{22}@"
},
"html_comment": {
"type": "PATTERN",
"value": "<!--([^-]|-[^-]|--[^>])*-->"
},
"raw_block": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "raw_block_1"
},
{
"type": "SYMBOL",
"name": "raw_block_2"
},
{
"type": "SYMBOL",
"name": "raw_block_3"
},
{
"type": "SYMBOL",
"name": "raw_block_4"
},
{
"type": "SYMBOL",
"name": "raw_block_5"
},
{
"type": "SYMBOL",
"name": "raw_block_6"
},
{
"type": "SYMBOL",
"name": "raw_block_7"
},
{
"type": "SYMBOL",
"name": "raw_block_8"
},
{
"type": "SYMBOL",
"name": "raw_block_9"
},
{
"type": "SYMBOL",
"name": "raw_block_10"
},
{
"type": "SYMBOL",
"name": "raw_block_11"
},
{
"type": "SYMBOL",
"name": "raw_block_12"
},
{
"type": "SYMBOL",
"name": "raw_block_13"
},
{
"type": "SYMBOL",
"name": "raw_block_14"
},
{
"type": "SYMBOL",
"name": "raw_block_15"
},
{
"type": "SYMBOL",
"name": "raw_block_16"
},
{
"type": "SYMBOL",
"name": "raw_block_17"
},
{
"type": "SYMBOL",
"name": "raw_block_18"
},
{
"type": "SYMBOL",
"name": "raw_block_19"
},
{
"type": "SYMBOL",
"name": "raw_block_20"
},
{
"type": "SYMBOL",
"name": "raw_block_21"
},
{
"type": "SYMBOL",
"name": "raw_block_22"
}
]
},
"raw_block_1": {
"type": "PATTERN",
"value": "@#([^#]|#[^@])*#@"
},
"raw_block_2": {
"type": "PATTERN",
"value": "@##([^#]|#[^#]|##[^@])*##@"
},
"raw_block_3": {
"type": "PATTERN",
"value": "@###([^#]|#{1,2}[^#]|###[^@])*###@"
},
"raw_block_4": {
"type": "PATTERN",
"value": "@#{4}([^#]|#{1,3}[^#]|#{4}[^@])*#{4}@"
},
"raw_block_5": {
"type": "PATTERN",
"value": "@#{5}([^#]|#{1,4}[^#]|#{5}[^@])*#{5}@"
},
"raw_block_6": {
"type": "PATTERN",
"value": "@#{6}([^#]|#{1,5}[^#]|#{6}[^@])*#{6}@"
},
"raw_block_7": {
"type": "PATTERN",
"value": "@#{7}([^#]|#{1,6}[^#]|#{7}[^@])*#{7}@"
},
"raw_block_8": {
"type": "PATTERN",
"value": "@#{8}([^#]|#{1,7}[^#]|#{8}[^@])*#{8}@"
},
"raw_block_9": {
"type": "PATTERN",
"value": "@#{9}([^#]|#{1,8}[^#]|#{9}[^@])*#{9}@"
},
"raw_block_10": {
"type": "PATTERN",
"value": "@#{10}([^#]|#{1,9}[^#]|#{10}[^@])*#{10}@"
},
"raw_block_11": {
"type": "PATTERN",
"value": "@#{11}([^#]|#{1,10}[^#]|#{11}[^@])*#{11}@"
},
"raw_block_12": {
"type": "PATTERN",
"value": "@#{12}([^#]|#{1,11}[^#]|#{12}[^@])*#{12}@"
},
"raw_block_13": {
"type": "PATTERN",
"value": "@#{13}([^#]|#{1,12}[^#]|#{13}[^@])*#{13}@"
},
"raw_block_14": {
"type": "PATTERN",
"value": "@#{14}([^#]|#{1,13}[^#]|#{14}[^@])*#{14}@"
},
"raw_block_15": {
"type": "PATTERN",
"value": "@#{15}([^#]|#{1,14}[^#]|#{15}[^@])*#{15}@"
},
"raw_block_16": {
"type": "PATTERN",
"value": "@#{16}([^#]|#{1,15}[^#]|#{16}[^@])*#{16}@"
},
"raw_block_17": {
"type": "PATTERN",
"value": "@#{17}([^#]|#{1,16}[^#]|#{17}[^@])*#{17}@"
},
"raw_block_18": {
"type": "PATTERN",
"value": "@#{18}([^#]|#{1,17}[^#]|#{18}[^@])*#{18}@"
},
"raw_block_19": {
"type": "PATTERN",
"value": "@#{19}([^#]|#{1,18}[^#]|#{19}[^@])*#{19}@"
},
"raw_block_20": {
"type": "PATTERN",
"value": "@#{20}([^#]|#{1,19}[^#]|#{20}[^@])*#{20}@"
},
"raw_block_21": {
"type": "PATTERN",
"value": "@#{21}([^#]|#{1,20}[^#]|#{21}[^@])*#{21}@"
},
"raw_block_22": {
"type": "PATTERN",
"value": "@#{22}([^#]|#{1,21}[^#]|#{22}[^@])*#{22}@"
},
"embedded_language": {
"type": "SEQ",
"members": [