-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathsource.templ.js
611 lines (609 loc) · 27.9 KB
/
source.templ.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/templ-go/templ-vscode>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
dependencies: ['source.go'],
extensions: ['.templ'],
names: ['templ'],
patterns: [
{include: '#script-template'},
{include: '#css-template'},
{include: '#html-template'},
{include: 'source.go'}
],
repository: {
'block-element': {
begin:
'(</?)((?i:address|blockquote|dd|div|section|article|aside|header|footer|nav|menu|dl|dt|fieldset|form|frame|frameset|h1|h2|h3|h4|h5|h6|iframe|noframes|object|ol|p|ul|applet|center|dir|hr|pre)(?=\\s|\\\\|>))',
beginCaptures: {
1: {name: 'punctuation.definition.tag.begin.html'},
2: {name: 'entity.name.tag.block.any.html'}
},
end: '(>)',
endCaptures: {1: {name: 'punctuation.definition.tag.end.html'}},
name: 'meta.tag.block.any.html',
patterns: [{include: '#tag-stuff'}]
},
'call-expression': {
begin: '({\\!)\\s+',
beginCaptures: {
0: {name: 'start.call-expression.templ'},
1: {name: 'punctuation.brace.open'}
},
end: '(})',
endCaptures: {
0: {name: 'end.call-expression.templ'},
1: {name: 'punctuation.brace.close'}
},
name: 'call-expression.templ',
patterns: [{include: 'source.go'}]
},
'case-expression': {
begin: '^\\s*case .+?:$',
captures: {
0: {
name: 'case.switch.html-template.templ',
patterns: [{include: 'source.go'}]
}
},
end: '(^\\s*case .+?:$)|(^\\s*default:$)|(\\s*$)',
patterns: [{include: '#template-node'}]
},
'close-element': {
begin: '(</?)([a-zA-Z0-9:\\-]+)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.begin.html'},
2: {name: 'entity.name.tag.other.html'}
},
end: '(>)',
endCaptures: {1: {name: 'punctuation.definition.tag.end.html'}},
name: 'meta.tag.other.html',
patterns: [{include: '#tag-stuff'}]
},
'css-template': {
begin: '^(css) ([A-z_][A-z_0-9]*\\()',
beginCaptures: {
1: {name: 'keyword.control.go'},
2: {patterns: [{include: 'source.go'}]}
},
end: '(?<=^}$)',
name: 'css-template.templ',
patterns: [
{
begin: '(?<=\\()',
end: '(\\))',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.round.go'}
},
name: 'params.css-template.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<=\\)) ({)$',
beginCaptures: {
1: {name: 'punctuation.definition.begin.bracket.curly.go'}
},
end: '^(})$',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.curly.go'}
},
name: 'block.css-template.templ',
patterns: [
{
begin:
'\\s*((?:-(?:webkit|moz|o|ms|khtml)-)?(?:zoom|z-index|y|x|writing-mode|wrap|wrap-through|wrap-inside|wrap-flow|wrap-before|wrap-after|word-wrap|word-spacing|word-break|word|will-change|width|widows|white-space-collapse|white-space|white|weight|volume|voice-volume|voice-stress|voice-rate|voice-pitch-range|voice-pitch|voice-family|voice-duration|voice-balance|voice|visibility|vertical-align|vector-effect|variant|user-zoom|user-select|up|unicode-(bidi|range)|trim|translate|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform-box|transform|touch-action|top-width|top-style|top-right-radius|top-left-radius|top-color|top|timing-function|text-wrap|text-underline-position|text-transform|text-spacing|text-space-trim|text-space-collapse|text-size-adjust|text-shadow|text-replace|text-rendering|text-overflow|text-outline|text-orientation|text-justify|text-indent|text-height|text-emphasis-style|text-emphasis-skip|text-emphasis-position|text-emphasis-color|text-emphasis|text-decoration-style|text-decoration-stroke|text-decoration-skip|text-decoration-line|text-decoration-fill|text-decoration-color|text-decoration|text-combine-upright|text-anchor|text-align-last|text-align-all|text-align|text|target-position|target-new|target-name|target|table-layout|tab-size|system|symbols|suffix|style-type|style-position|style-image|style|stroke-width|stroke-opacity|stroke-miterlimit|stroke-linejoin|stroke-linecap|stroke-dashoffset|stroke-dasharray|stroke|string-set|stretch|stress|stop-opacity|stop-color|stacking-strategy|stacking-shift|stacking-ruby|stacking|src|speed|speech-rate|speech|speak-punctuation|speak-numeral|speak-header|speak-as|speak|span|spacing|space-collapse|space|solid-opacity|solid-color|sizing|size-adjust|size|shape-rendering|shape-padding|shape-outside|shape-margin|shape-inside|shape-image-threshold|shadow|scroll-snap-type|scroll-snap-points-y|scroll-snap-points-x|scroll-snap-destination|scroll-snap-coordinate|scroll-behavior|scale|ry|rx|respond-to|rule-width|rule-style|rule-color|rule|ruby-span|ruby-position|ruby-overhang|ruby-merge|ruby-align|ruby|rows|rotation-point|rotation|rotate|role|right-width|right-style|right-color|right|richness|rest-before|rest-after|rest|resource|resolution|resize|reset|replace|repeat|rendering-intent|region-fragment|rate|range|radius|r|quotes|punctuation-trim|punctuation|property|profile|presentation-level|presentation|prefix|position|pointer-events|point|play-state|play-during|play-count|pitch-range|pitch|phonemes|perspective-origin|perspective|pause-before|pause-after|pause|page-policy|page-break-inside|page-break-before|page-break-after|page|padding-top|padding-right|padding-left|padding-inline-start|padding-inline-end|padding-bottom|padding-block-start|padding-block-end|padding|pad|pack|overhang|overflow-y|overflow-x|overflow-wrap|overflow-style|overflow-inline|overflow-block|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|origin|orientation|orient|ordinal-group|order|opacity|offset-start|offset-inline-start|offset-inline-end|offset-end|offset-block-start|offset-block-end|offset-before|offset-after|offset|object-position|object-fit|numeral|new|negative|nav-up|nav-right|nav-left|nav-index|nav-down|nav|name|move-to|motion-rotation|motion-path|motion-offset|motion|model|mix-blend-mode|min-zoom|min-width|min-inline-size|min-height|min-block-size|min|max-zoom|max-width|max-lines|max-inline-size|max-height|max-block-size|max|mask-type|mask-size|mask-repeat|mask-position|mask-origin|mask-mode|mask-image|mask-composite|mask-clip|mask-border-width|mask-border-source|mask-border-slice|mask-border-repeat|mask-border-outset|mask-border-mode|mask-border|mask|marquee-style|marquee-speed|marquee-play-count|marquee-loop|marquee-direction|marquee|marks|marker-start|marker-side|marker-mid|marker-end|marker|margin-top|margin-right|margin-left|margin-inline-start|margin-inline-end|margin-bottom|margin-block-start|margin-block-end|margin|list-style-type|list-style-position|list-style-image|list-style|list|lines|line-stacking-strategy|line-stacking-shift|line-stacking-ruby|line-stacking|line-snap|line-height|line-grid|line-break|line|lighting-color|level|letter-spacing|length|left-width|left-style|left-color|left|label|kerning|justify-self|justify-items|justify-content|justify|iteration-count|isolation|inline-size|inline-box-align|initial-value|initial-size|initial-letter-wrap|initial-letter-align|initial-letter|initial-before-align|initial-before-adjust|initial-after-align|initial-after-adjust|index|indent|increment|image-rendering|image-resolution|image-orientation|image|icon|hyphens|hyphenate-limit-zone|hyphenate-limit-lines|hyphenate-limit-last|hyphenate-limit-chars|hyphenate-character|hyphenate|height|header|hanging-punctuation|grid-template-rows|grid-template-columns|grid-template-areas|grid-template|grid-row-start|grid-row-gap|grid-row-end|grid-row|grid-rows|grid-gap|grid-column-start|grid-column-gap|grid-column-end|grid-column|grid-columns|grid-auto-rows|grid-auto-flow|grid-auto-columns|grid-area|grid|glyph-orientation-vertical|glyph-orientation-horizontal|gap|font-weight|font-variant-position|font-variant-numeric|font-variant-ligatures|font-variant-east-asian|font-variant-caps|font-variant-alternates|font-variant|font-synthesis|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|flow-into|flow-from|flow|flood-opacity|flood-color|float-offset|float|flex-wrap|flex-shrink|flex-grow|flex-group|flex-flow|flex-direction|flex-basis|flex|fit-position|fit|filter|fill-rule|fill-opacity|fill|family|fallback|enable-background|empty-cells|emphasis|elevation|duration|drop-initial-value|drop-initial-size|drop-initial-before-align|drop-initial-before-adjust|drop-initial-after-align|drop-initial-after-adjust|drop|down|dominant-baseline|display-role|display-model|display|direction|delay|decoration-break|decoration|cy|cx|cursor|cue-before|cue-after|cue|crop|counter-set|counter-reset|counter-increment|counter|count|corner-shape|corners|continue|content|contain|columns|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|column-break-before|column-break-after|column|color-rendering|color-profile|color-interpolation-filters|color-interpolation|color-adjust|color|collapse|clip-rule|clip-path|clip|clear|character|caret-shape|caret-color|caret|caption-side|buffered-rendering|break-inside|break-before|break-after|break|box-suppress|box-snap|box-sizing|box-shadow|box-pack|box-orient|box-ordinal-group|box-lines|box-flex-group|box-flex|box-direction|box-decoration-break|box-align|box|bottom-width|bottom-style|bottom-right-radius|bottom-left-radius|bottom-color|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-limit|border-length|border-left-width|border-left-style|border-left-color|border-left|border-inline-start-width|border-inline-start-style|border-inline-start-color|border-inline-start|border-inline-end-width|border-inline-end-style|border-inline-end-color|border-inline-end|border-image-width|border-image-transform|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-clip-top|border-clip-right|border-clip-left|border-clip-bottom|border-clip|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border-block-start-width|border-block-start-style|border-block-start-color|border-block-start|border-block-end-width|border-block-end-style|border-block-end-color|border-block-end|border|bookmark-target|bookmark-level|bookmark-label|bookmark|block-size|binding|bidi|before|baseline-shift|baseline|balance|background-size|background-repeat|background-position-y|background-position-x|background-position-inline|background-position-block|background-position|background-origin|background-image|background-color|background-clip|background-blend-mode|background-attachment|background|backface-visibility|backdrop-filter|azimuth|attachment|appearance|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|alt|all|alignment-baseline|alignment-adjust|alignment|align-last|align-self|align-items|align-content|align|after|adjust|additive-symbols)):\\s+',
beginCaptures: {1: {name: 'support.type.property-name.css'}},
end: '(?<=;$)',
name: 'property.css-template.templ',
patterns: [
{
begin: '({)',
beginCaptures: {
1: {name: 'punctuation.definition.begin.bracket.curly.go'}
},
end: '(})(;)$',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.curly.go'},
2: {name: 'punctuation.terminator.rule.css'}
},
name: 'expression.property.css-template.templ',
patterns: [{include: 'source.go'}]
},
{
captures: {
1: {name: 'support.type.property-value.css'},
2: {name: 'punctuation.terminator.rule.css'}
},
match: '(.*)(;)$',
name: 'constant.property.css-template.templ'
}
]
}
]
}
]
},
'default-expression': {
begin: '^\\s*default:$',
captures: {
0: {
name: 'default.switch.html-template.templ',
patterns: [{include: 'source.go'}]
}
},
end: '(^\\s*case .+?:$)|(^\\s*default:$)|(\\s*$)',
patterns: [{include: '#template-node'}]
},
element: {
begin: '(<)([a-zA-Z0-9:\\-]++)(?=[^>]*></\\2>)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.html'},
2: {name: 'entity.name.tag.html'}
},
end: '(>(<)/)(\\2)(>)',
endCaptures: {
1: {name: 'punctuation.definition.tag.html'},
2: {name: 'meta.scope.between-tag-pair.html'},
3: {name: 'entity.name.tag.html'},
4: {name: 'punctuation.definition.tag.html'}
},
name: 'meta.tag.any.html',
patterns: [{include: '#tag-stuff'}]
},
'else-expression': {
begin: '\\s+(else)\\s+({)\\s*$',
beginCaptures: {
1: {name: 'keyword.control.go'},
2: {name: 'punctuation.definition.begin.bracket.curly.go'}
},
end: '^\\s*(})$',
endCaptures: {1: {name: 'punctuation.definition.end.bracket.curly.go'}},
name: 'else.html-template.templ',
patterns: [{include: '#template-node'}]
},
'else-if-expression': {
begin: '\\s(else if)\\s',
beginCaptures: {1: {name: 'keyword.control.go'}},
end: '(?<=})',
name: 'else-if.html-template.templ',
patterns: [
{
begin: '(?<=if\\s)',
end: '({)$',
endCaptures: {
1: {name: 'punctuation.definition.begin.bracket.curly.go'}
},
name: 'expression.else-if.html-template.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<={)$',
end: '^\\s*(})',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.curly.go'}
},
name: 'block.else-if.html-template.templ',
patterns: [{include: '#template-node'}]
}
]
},
entities: {
patterns: [
{
captures: {
1: {name: 'punctuation.definition.entity.html'},
3: {name: 'punctuation.definition.entity.html'}
},
match: '(&)([a-zA-Z0-9]+|#[0-9]+|#[xX][0-9a-fA-F]+)(;)',
name: 'constant.character.entity.html'
},
{match: '&', name: 'invalid.illegal.bad-ampersand.html'}
]
},
'for-expression': {
begin: '^\\s*for .+{',
captures: {
0: {name: 'meta.embedded.block.go', patterns: [{include: 'source.go'}]}
},
end: '\\s*}\\s*\n',
name: 'for.html-template.templ',
patterns: [{include: '#template-node'}]
},
'go-comment-block': {
begin: '(\\/\\*)',
beginCaptures: {1: {name: 'punctuation.definition.comment.go'}},
end: '(\\*\\/)',
endCaptures: {1: {name: 'punctuation.definition.comment.go'}},
name: 'comment.block.go'
},
'go-comment-double-slash': {
begin: '(\\/\\/)',
beginCaptures: {1: {name: 'punctuation.definition.comment.go'}},
end: '(?:\\n|$)',
name: 'comment.line.double-slash.go'
},
'html-comment': {
begin: '<!--',
beginCaptures: {0: {name: 'punctuation.definition.comment.html'}},
end: '-->',
endCaptures: {0: {name: 'punctuation.definition.comment.html'}},
name: 'comment.block.html'
},
'html-template': {
begin:
'^(templ) ((?:\\([A-z_][A-z_0-9]* \\*?[A-z_][A-z_0-9]*\\) )?[A-z_][A-z_0-9]*(\\(|\\[))',
beginCaptures: {
1: {name: 'keyword.control.go'},
2: {patterns: [{include: 'source.go'}]}
},
end: '(?<=^}$)',
name: 'html-template.templ',
patterns: [
{
begin: '(?<=\\()',
end: '(\\))',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.round.go'}
},
name: 'params.html-template.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<=\\[)',
end: '(\\])',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.square.go'}
},
name: 'type-params.html-template.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<=\\)) ({)$',
beginCaptures: {
1: {name: 'punctuation.definition.begin.bracket.curly.go'}
},
end: '^(})$',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.curly.go'}
},
name: 'block.html-template.templ',
patterns: [{include: '#template-node'}]
}
]
},
'if-expression': {
begin: '^\\s*(if)\\s',
beginCaptures: {1: {name: 'keyword.control.go'}},
end: '(?<=})',
name: 'if.html-template.templ',
patterns: [
{
begin: '(?<=if\\s)',
end: '({)$',
endCaptures: {
1: {name: 'punctuation.definition.begin.bracket.curly.go'}
},
name: 'expression.if.html-template.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<={)$',
end: '^\\s*(})',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.curly.go'}
},
name: 'block.if.html-template.templ',
patterns: [{include: '#template-node'}]
}
]
},
'import-expression': {
patterns: [
{
begin: '(@)((?:[A-z_][A-z_0-9]*\\.)?[A-z_][A-z_0-9]*(?:\\(|{|$))',
beginCaptures: {
1: {name: 'keyword.control.go'},
2: {patterns: [{include: 'source.go'}]}
},
end: '(?<=\\))$|(?<=})$|(?<=$)',
name: 'import-expression.templ',
patterns: [
{
begin: '(?<=[A-z_0-9]{)',
end: '\\s*(})(\\.[A-z_][A-z_0-9]*\\()',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.curly.go'},
2: {patterns: [{include: 'source.go'}]}
},
name: 'struct-method.import-expression.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<=\\()',
end: '(\\))',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.round.go'}
},
name: 'params.import-expression.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<=\\))\\s({)$',
beginCaptures: {1: {name: 'punctuation.brace.open'}},
end: '^\\s*(})$',
endCaptures: {1: {name: 'punctuation.brace.close'}},
name: 'children.import-expression.templ',
patterns: [{include: '#template-node'}]
}
]
}
]
},
'inline-element': {
begin:
'(</?)((?i:a|abbr|acronym|area|b|base|basefont|bdo|big|br|button|caption|cite|code|col|colgroup|del|dfn|em|font|head|html|i|img|input|ins|isindex|kbd|label|legend|li|link|map|meta|noscript|optgroup|option|param|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|var)(?=\\s|\\\\|>))',
beginCaptures: {
1: {name: 'punctuation.definition.tag.begin.html'},
2: {name: 'entity.name.tag.inline.any.html'}
},
end: '((?: ?/)?>)',
endCaptures: {1: {name: 'punctuation.definition.tag.end.html'}},
name: 'meta.tag.inline.any.html',
patterns: [{include: '#tag-stuff'}]
},
'script-element': {
begin: '(<)(script)([^>]*)(>)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.html'},
2: {name: 'entity.name.tag.html'},
3: {patterns: [{include: '#tag-stuff'}]},
4: {name: 'punctuation.definition.tag.html'}
},
end: '</script>',
endCaptures: {0: {patterns: [{include: '#close-element'}]}},
name: 'meta.tag.script.html',
patterns: [{include: 'source.js'}]
},
'script-template': {
begin: '^(script) ([A-z_][A-z_0-9]*\\()',
beginCaptures: {
1: {name: 'keyword.control.go'},
2: {patterns: [{include: 'source.go'}]}
},
end: '(?<=^}$)',
name: 'script-template.templ',
patterns: [
{
begin: '(?<=\\()',
end: '(\\))',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.round.go'}
},
name: 'params.script-template.templ',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<=\\)) ({)$',
beginCaptures: {
1: {name: 'punctuation.definition.begin.bracket.curly.go'}
},
end: '^(})$',
endCaptures: {
1: {name: 'punctuation.definition.end.bracket.curly.go'}
},
name: 'block.script-template.templ',
patterns: [{include: 'source.js'}]
}
]
},
sgml: {
begin: '<!',
captures: {0: {name: 'punctuation.definition.tag.html'}},
end: '>',
name: 'meta.tag.sgml.html',
patterns: [
{
begin: '(?i:DOCTYPE)',
captures: {1: {name: 'entity.name.tag.doctype.html'}},
end: '(?=>)',
name: 'meta.tag.sgml.doctype.html',
patterns: [
{
match: '"[^">]*"',
name: 'string.quoted.double.doctype.identifiers-and-DTDs.html'
}
]
},
{
begin: '\\[CDATA\\[',
end: ']](?=>)',
name: 'constant.other.inline-data.html'
},
{
match: '(\\s*)(?!--|>)\\S(\\s*)',
name: 'invalid.illegal.bad-comments-or-CDATA.html'
}
]
},
'string-double-quoted': {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.html'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.html'}},
name: 'string.quoted.double.html',
patterns: [{include: '#entities'}]
},
'string-expression': {
begin: '{\\s+',
beginCaptures: {0: {name: 'start.string-expression.templ'}},
end: '}',
endCaptures: {0: {name: 'end.string-expression.templ'}},
name: 'expression.html-template.templ',
patterns: [{include: 'source.go'}]
},
'style-element': {
begin: '(<)(style)([^>]*)(>)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.html'},
2: {name: 'entity.name.tag.html'},
3: {patterns: [{include: '#tag-stuff'}]},
4: {name: 'punctuation.definition.tag.html'}
},
end: '</style>',
endCaptures: {0: {patterns: [{include: '#close-element'}]}},
name: 'meta.tag.style.html',
patterns: [{include: 'source.css'}]
},
'switch-expression': {
begin: '^\\s*switch .+?{$',
captures: {
0: {name: 'meta.embedded.block.go', patterns: [{include: 'source.go'}]}
},
end: '^\\s*}$',
name: 'switch.html-template.templ',
patterns: [
{include: '#template-node'},
{include: '#case-expression'},
{include: '#default-expression'}
]
},
'tag-else-attribute': {
begin: '\\s(else)\\s({)$',
beginCaptures: {
1: {name: 'keyword.control.go'},
2: {name: 'punctuation.brace.open'}
},
end: '^\\s*(})$',
endCaptures: {1: {name: 'punctuation.brace.close'}},
name: 'else.attribute.html',
patterns: [{include: '#tag-stuff'}]
},
'tag-else-if-attribute': {
begin: '\\s(else if)\\s',
beginCaptures: {1: {name: 'keyword.control.go'}},
end: '(?<=})',
name: 'else-if.attribute.html',
patterns: [
{
begin: '(?<=if\\s)',
end: '({)$',
endCaptures: {1: {name: 'punctuation.brace.open'}},
name: 'expression.else-if.attribute.html',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<={)$',
end: '^\\s*(})',
endCaptures: {1: {name: 'punctuation.brace.close'}},
name: 'block.else-if.attribute.html',
patterns: [{include: '#tag-stuff'}]
}
]
},
'tag-generic-attribute': {
match: '(?<=[^=])\\b([a-zA-Z0-9:-]+)',
name: 'entity.other.attribute-name.html'
},
'tag-id-attribute': {
begin: '\\b(id)\\b\\s*(=)',
captures: {
1: {name: 'entity.other.attribute-name.id.html'},
2: {name: 'punctuation.separator.key-value.html'}
},
end: '(?!\\G)(?<=\'|"|[^\\s<>/])',
name: 'meta.attribute-with-value.id.html',
patterns: [
{
begin: '"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.html'}
},
contentName: 'meta.toc-list.id.html',
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.html'}},
name: 'string.quoted.double.html',
patterns: [{include: '#entities'}]
},
{
begin: "'",
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.html'}
},
contentName: 'meta.toc-list.id.html',
end: "'",
endCaptures: {0: {name: 'punctuation.definition.string.end.html'}},
name: 'string.quoted.single.html',
patterns: [{include: '#entities'}]
},
{
captures: {0: {name: 'meta.toc-list.id.html'}},
match: '(?<==)(?:[^\\s{}<>/\'"]|/(?!>))+',
name: 'string.unquoted.html'
}
]
},
'tag-if-attribute': {
begin: '^\\s*(if)\\s',
beginCaptures: {1: {name: 'keyword.control.go'}},
end: '(?<=})',
name: 'if.attribute.html',
patterns: [
{
begin: '(?<=if\\s)',
end: '({)$',
endCaptures: {1: {name: 'punctuation.brace.open'}},
name: 'expression.if.attribute.html',
patterns: [{include: 'source.go'}]
},
{
begin: '(?<={)$',
end: '^\\s*(})',
endCaptures: {1: {name: 'punctuation.brace.close'}},
name: 'block.if.attribute.html',
patterns: [{include: '#tag-stuff'}]
}
]
},
'tag-stuff': {
patterns: [
{include: '#tag-id-attribute'},
{include: '#tag-generic-attribute'},
{include: '#string-double-quoted'},
{include: '#string-expression'},
{include: '#tag-if-attribute'},
{include: '#tag-else-if-attribute'},
{include: '#tag-else-attribute'}
]
},
'template-node': {
patterns: [
{include: '#string-expression'},
{include: '#call-expression'},
{include: '#import-expression'},
{include: '#script-element'},
{include: '#style-element'},
{include: '#element'},
{include: '#html-comment'},
{include: '#go-comment-block'},
{include: '#go-comment-double-slash'},
{include: '#sgml'},
{include: '#block-element'},
{include: '#inline-element'},
{include: '#close-element'},
{include: '#else-if-expression'},
{include: '#if-expression'},
{include: '#else-expression'},
{include: '#for-expression'},
{include: '#switch-expression'}
]
}
},
scopeName: 'source.templ'
}
export default grammar