squiffy-compiler 6.0.1 → 7.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +10 -2
  2. package/dist/analyse.d.ts +96 -0
  3. package/dist/analyse.js +951 -0
  4. package/dist/compiler.d.ts +32 -40
  5. package/dist/compiler.js +26 -691
  6. package/dist/css-urls.d.ts +4 -0
  7. package/dist/css-urls.js +59 -0
  8. package/dist/emit.d.ts +71 -0
  9. package/dist/emit.js +192 -0
  10. package/dist/helpers.d.ts +1 -0
  11. package/dist/helpers.js +14 -0
  12. package/dist/ignore.d.ts +8 -0
  13. package/dist/ignore.js +71 -0
  14. package/dist/infix-expressions.d.ts +19 -0
  15. package/dist/infix-expressions.js +713 -0
  16. package/dist/language-service.d.ts +90 -0
  17. package/dist/language-service.js +883 -0
  18. package/dist/node.d.ts +23 -0
  19. package/dist/node.js +122 -0
  20. package/dist/parse.d.ts +22 -0
  21. package/dist/parse.js +316 -0
  22. package/dist/project.d.ts +129 -0
  23. package/dist/project.js +488 -0
  24. package/dist/quest/aslx.d.ts +51 -0
  25. package/dist/quest/aslx.js +184 -0
  26. package/dist/quest/convert.d.ts +20 -0
  27. package/dist/quest/convert.js +552 -0
  28. package/dist/quest/script.d.ts +92 -0
  29. package/dist/quest/script.js +453 -0
  30. package/dist/quest/scripts.d.ts +24 -0
  31. package/dist/quest/scripts.js +506 -0
  32. package/dist/quest/text.d.ts +18 -0
  33. package/dist/quest/text.js +323 -0
  34. package/dist/section-labels.d.ts +4 -0
  35. package/dist/section-labels.js +64 -0
  36. package/dist/setters.d.ts +49 -0
  37. package/dist/setters.js +477 -0
  38. package/dist/story-graph.d.ts +71 -0
  39. package/dist/story-graph.js +445 -0
  40. package/dist/syntax.d.ts +198 -0
  41. package/dist/syntax.js +8 -0
  42. package/dist/templates.d.ts +17 -0
  43. package/dist/templates.js +180 -0
  44. package/dist/text.d.ts +44 -0
  45. package/dist/text.js +348 -0
  46. package/dist/twine/audio.d.ts +21 -0
  47. package/dist/twine/audio.js +80 -0
  48. package/dist/twine/convert.d.ts +131 -0
  49. package/dist/twine/convert.js +1057 -0
  50. package/dist/twine/expression.d.ts +88 -0
  51. package/dist/twine/expression.js +318 -0
  52. package/dist/twine/harlowe.d.ts +27 -0
  53. package/dist/twine/harlowe.js +2341 -0
  54. package/dist/twine/settings.d.ts +9 -0
  55. package/dist/twine/settings.js +322 -0
  56. package/dist/twine/story.d.ts +24 -0
  57. package/dist/twine/story.js +231 -0
  58. package/dist/twine/sugarcube.d.ts +40 -0
  59. package/dist/twine/sugarcube.js +2172 -0
  60. package/dist/v5.js +2 -1
  61. package/package.json +35 -6
  62. package/syntaxes/squiffy.tmLanguage.json +1003 -0
@@ -0,0 +1,1003 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
+ "name": "Squiffy",
4
+ "scopeName": "source.squiffy",
5
+ "fileTypes": [
6
+ "squiffy"
7
+ ],
8
+ "patterns": [
9
+ {
10
+ "include": "#preamble"
11
+ },
12
+ {
13
+ "include": "#block"
14
+ },
15
+ {
16
+ "include": "#text"
17
+ }
18
+ ],
19
+ "repository": {
20
+ "block": {
21
+ "comment": "Each header starts a block. Until the block's first line of text, lines indented by a tab or four spaces are JavaScript, as in the compiler (compiler/src/parse.ts).",
22
+ "patterns": [
23
+ {
24
+ "include": "#snippet"
25
+ },
26
+ {
27
+ "include": "#section-header"
28
+ },
29
+ {
30
+ "include": "#passage-header"
31
+ },
32
+ {
33
+ "include": "#continue"
34
+ },
35
+ {
36
+ "include": "#separator"
37
+ },
38
+ {
39
+ "include": "#ui-block"
40
+ }
41
+ ]
42
+ },
43
+ "preamble": {
44
+ "comment": "The top of the file works like the start of a section.",
45
+ "begin": "\\A(?=\\s*$|\\t| {4}|\\s*@)",
46
+ "end": "^(?!\\s*$|\\t| {4}|\\s*@)",
47
+ "patterns": [
48
+ {
49
+ "include": "#ui-block"
50
+ },
51
+ {
52
+ "include": "#js-line"
53
+ },
54
+ {
55
+ "include": "#directive"
56
+ }
57
+ ]
58
+ },
59
+ "section-header": {
60
+ "begin": "^\\s*(\\[\\[)(.*)(\\]\\])(:)\\s*$",
61
+ "beginCaptures": {
62
+ "0": {
63
+ "name": "markup.heading.section.squiffy"
64
+ },
65
+ "1": {
66
+ "name": "punctuation.definition.heading.begin.squiffy"
67
+ },
68
+ "2": {
69
+ "name": "entity.name.section.squiffy"
70
+ },
71
+ "3": {
72
+ "name": "punctuation.definition.heading.end.squiffy"
73
+ },
74
+ "4": {
75
+ "name": "punctuation.separator.key-value.squiffy"
76
+ }
77
+ },
78
+ "end": "^(?!\\s*$|\\t| {4}|\\s*@)",
79
+ "patterns": [
80
+ {
81
+ "include": "#ui-block"
82
+ },
83
+ {
84
+ "include": "#js-line"
85
+ },
86
+ {
87
+ "include": "#directive"
88
+ }
89
+ ]
90
+ },
91
+ "passage-header": {
92
+ "begin": "^\\s*(\\[)(?!\\[|snippet:)(.*)(\\])(:)\\s*$",
93
+ "beginCaptures": {
94
+ "0": {
95
+ "name": "markup.heading.passage.squiffy"
96
+ },
97
+ "1": {
98
+ "name": "punctuation.definition.heading.begin.squiffy"
99
+ },
100
+ "2": {
101
+ "name": "entity.name.function.passage.squiffy"
102
+ },
103
+ "3": {
104
+ "name": "punctuation.definition.heading.end.squiffy"
105
+ },
106
+ "4": {
107
+ "name": "punctuation.separator.key-value.squiffy"
108
+ }
109
+ },
110
+ "end": "^(?!\\s*$|\\t| {4}|\\s*@)",
111
+ "patterns": [
112
+ {
113
+ "include": "#ui-block"
114
+ },
115
+ {
116
+ "include": "#js-line"
117
+ },
118
+ {
119
+ "include": "#directive"
120
+ }
121
+ ]
122
+ },
123
+ "continue": {
124
+ "begin": "^\\s*(\\+\\+\\+)(.*)$",
125
+ "beginCaptures": {
126
+ "0": {
127
+ "name": "markup.heading.continue.squiffy"
128
+ },
129
+ "1": {
130
+ "name": "keyword.control.continue.squiffy"
131
+ },
132
+ "2": {
133
+ "name": "string.other.link.title.squiffy",
134
+ "patterns": [
135
+ {
136
+ "include": "#inline"
137
+ }
138
+ ]
139
+ }
140
+ },
141
+ "end": "^(?!\\s*$|\\t| {4}|\\s*@)",
142
+ "patterns": [
143
+ {
144
+ "include": "#ui-block"
145
+ },
146
+ {
147
+ "include": "#js-line"
148
+ },
149
+ {
150
+ "include": "#directive"
151
+ }
152
+ ]
153
+ },
154
+ "separator": {
155
+ "begin": "^\\s*(---)\\s*$",
156
+ "beginCaptures": {
157
+ "1": {
158
+ "name": "meta.separator.squiffy keyword.control.separator.squiffy"
159
+ }
160
+ },
161
+ "end": "^(?!\\s*$|\\t| {4}|\\s*@)",
162
+ "patterns": [
163
+ {
164
+ "include": "#ui-block"
165
+ },
166
+ {
167
+ "include": "#js-line"
168
+ },
169
+ {
170
+ "include": "#directive"
171
+ }
172
+ ]
173
+ },
174
+ "snippet": {
175
+ "comment": "A snippet's content is plain text up to the next section or snippet header. Passage headers inside it are just text.",
176
+ "begin": "^\\s*(\\[)(snippet)(:)\\s*(.+)(\\])(:)\\s*$",
177
+ "beginCaptures": {
178
+ "0": {
179
+ "name": "markup.heading.snippet.squiffy"
180
+ },
181
+ "1": {
182
+ "name": "punctuation.definition.heading.begin.squiffy"
183
+ },
184
+ "2": {
185
+ "name": "keyword.other.snippet.squiffy"
186
+ },
187
+ "3": {
188
+ "name": "punctuation.separator.squiffy"
189
+ },
190
+ "4": {
191
+ "name": "entity.name.type.snippet.squiffy"
192
+ },
193
+ "5": {
194
+ "name": "punctuation.definition.heading.end.squiffy"
195
+ },
196
+ "6": {
197
+ "name": "punctuation.separator.key-value.squiffy"
198
+ }
199
+ },
200
+ "end": "^(?=\\s*\\[\\[.*\\]\\]:\\s*$|\\s*\\[snippet:\\s*.+\\]:\\s*$)",
201
+ "contentName": "meta.snippet.body.squiffy",
202
+ "patterns": [
203
+ {
204
+ "include": "#markdown-block"
205
+ },
206
+ {
207
+ "include": "#inline"
208
+ }
209
+ ]
210
+ },
211
+ "ui-block": {
212
+ "comment": "@ui on its own starts a block of story-wide JavaScript and HTML, ended by ---.",
213
+ "begin": "^\\s*(@ui)\\s*$",
214
+ "beginCaptures": {
215
+ "1": {
216
+ "name": "keyword.control.directive.squiffy"
217
+ }
218
+ },
219
+ "end": "^(?=\\s*---\\s*$)",
220
+ "name": "meta.ui-block.squiffy",
221
+ "patterns": [
222
+ {
223
+ "include": "#js-line"
224
+ },
225
+ {
226
+ "include": "#inline"
227
+ }
228
+ ]
229
+ },
230
+ "js-line": {
231
+ "match": "^(\\t| {4})(.*)$",
232
+ "captures": {
233
+ "2": {
234
+ "name": "meta.embedded.block.javascript",
235
+ "patterns": [
236
+ {
237
+ "include": "source.js"
238
+ }
239
+ ]
240
+ }
241
+ }
242
+ },
243
+ "directive": {
244
+ "patterns": [
245
+ {
246
+ "comment": "One setter per line, so its value runs to the end of the line: @set score = 10, @set greeting := Hello, {{name}}!, @set not has_key",
247
+ "match": "^\\s*(@)(set|unset)\\s+(.*?)\\s*$",
248
+ "captures": {
249
+ "0": {
250
+ "name": "meta.directive.attribute.squiffy"
251
+ },
252
+ "1": {
253
+ "name": "punctuation.definition.directive.squiffy keyword.control.directive.squiffy"
254
+ },
255
+ "2": {
256
+ "name": "keyword.control.directive.squiffy"
257
+ },
258
+ "3": {
259
+ "patterns": [
260
+ {
261
+ "include": "#assignment"
262
+ }
263
+ ]
264
+ }
265
+ }
266
+ },
267
+ {
268
+ "match": "^\\s*(@)(inc|dec)\\s+(\\S+)(?:\\s+(\\d+))?\\s*$",
269
+ "captures": {
270
+ "0": {
271
+ "name": "meta.directive.attribute.squiffy"
272
+ },
273
+ "1": {
274
+ "name": "punctuation.definition.directive.squiffy keyword.control.directive.squiffy"
275
+ },
276
+ "2": {
277
+ "name": "keyword.control.directive.squiffy"
278
+ },
279
+ "3": {
280
+ "name": "variable.parameter.attribute.squiffy"
281
+ },
282
+ "4": {
283
+ "name": "constant.numeric.squiffy"
284
+ }
285
+ }
286
+ },
287
+ {
288
+ "match": "^\\s*(@)(title|start|import|ui|music|sound|class|tag|transition|leave)\\s+(.*?)\\s*$",
289
+ "captures": {
290
+ "0": {
291
+ "name": "meta.directive.squiffy"
292
+ },
293
+ "1": {
294
+ "name": "punctuation.definition.directive.squiffy keyword.control.directive.squiffy"
295
+ },
296
+ "2": {
297
+ "name": "keyword.control.directive.squiffy"
298
+ },
299
+ "3": {
300
+ "name": "string.unquoted.squiffy"
301
+ }
302
+ }
303
+ },
304
+ {
305
+ "match": "^\\s*(@)(clear|repeat|end)\\s*$",
306
+ "captures": {
307
+ "1": {
308
+ "name": "punctuation.definition.directive.squiffy keyword.control.directive.squiffy"
309
+ },
310
+ "2": {
311
+ "name": "keyword.control.directive.squiffy"
312
+ }
313
+ }
314
+ }
315
+ ]
316
+ },
317
+ "text": {
318
+ "patterns": [
319
+ {
320
+ "include": "#directive"
321
+ },
322
+ {
323
+ "include": "#markdown-block"
324
+ },
325
+ {
326
+ "include": "#inline"
327
+ }
328
+ ]
329
+ },
330
+ "inline": {
331
+ "patterns": [
332
+ {
333
+ "include": "#handlebars-comment"
334
+ },
335
+ {
336
+ "include": "#handlebars"
337
+ },
338
+ {
339
+ "include": "#html-comment"
340
+ },
341
+ {
342
+ "include": "#link"
343
+ },
344
+ {
345
+ "include": "#html-tag"
346
+ },
347
+ {
348
+ "include": "#markdown-inline"
349
+ }
350
+ ]
351
+ },
352
+ "link": {
353
+ "comment": "In the order the compiler tries them (compiler/src/text.ts).",
354
+ "patterns": [
355
+ {
356
+ "name": "meta.link.section.next.squiffy",
357
+ "match": "(\\[\\[)([^\\]]*?)(>)(\\]\\])",
358
+ "captures": {
359
+ "1": {
360
+ "name": "punctuation.definition.link.begin.squiffy"
361
+ },
362
+ "2": {
363
+ "name": "string.other.link.title.squiffy",
364
+ "patterns": [
365
+ {
366
+ "include": "#handlebars"
367
+ }
368
+ ]
369
+ },
370
+ "3": {
371
+ "name": "keyword.operator.next-section.squiffy"
372
+ },
373
+ "4": {
374
+ "name": "punctuation.definition.link.end.squiffy"
375
+ }
376
+ }
377
+ },
378
+ {
379
+ "name": "meta.link.section.squiffy",
380
+ "match": "(\\[\\[)([^\\]]*?)(\\]\\])(\\()((?:[^()]|\\((?:[^()]|\\((?:[^()]|\\([^()]*\\))*\\))*\\))*?)(\\))",
381
+ "captures": {
382
+ "1": {
383
+ "name": "punctuation.definition.link.begin.squiffy"
384
+ },
385
+ "2": {
386
+ "name": "string.other.link.title.squiffy",
387
+ "patterns": [
388
+ {
389
+ "include": "#handlebars"
390
+ }
391
+ ]
392
+ },
393
+ "3": {
394
+ "name": "punctuation.definition.link.end.squiffy"
395
+ },
396
+ "4": {
397
+ "name": "punctuation.definition.metadata.begin.squiffy"
398
+ },
399
+ "5": {
400
+ "patterns": [
401
+ {
402
+ "include": "#link-target"
403
+ }
404
+ ]
405
+ },
406
+ "6": {
407
+ "name": "punctuation.definition.metadata.end.squiffy"
408
+ }
409
+ }
410
+ },
411
+ {
412
+ "name": "meta.image.markdown.squiffy",
413
+ "match": "(!)(\\[)([^\\]]*?)(\\])(\\()(.*?)(\\))",
414
+ "captures": {
415
+ "1": {
416
+ "name": "punctuation.definition.link.image.squiffy"
417
+ },
418
+ "2": {
419
+ "name": "punctuation.definition.link.begin.squiffy"
420
+ },
421
+ "3": {
422
+ "name": "string.other.link.description.squiffy"
423
+ },
424
+ "4": {
425
+ "name": "punctuation.definition.link.end.squiffy"
426
+ },
427
+ "5": {
428
+ "name": "punctuation.definition.metadata.begin.squiffy"
429
+ },
430
+ "6": {
431
+ "name": "markup.underline.link.image.squiffy"
432
+ },
433
+ "7": {
434
+ "name": "punctuation.definition.metadata.end.squiffy"
435
+ }
436
+ }
437
+ },
438
+ {
439
+ "name": "meta.link.url.squiffy",
440
+ "match": "(\\[)([^\\]]*?)(\\])(\\()(https?://.*?)(\\))",
441
+ "captures": {
442
+ "1": {
443
+ "name": "punctuation.definition.link.begin.squiffy"
444
+ },
445
+ "2": {
446
+ "name": "string.other.link.title.squiffy"
447
+ },
448
+ "3": {
449
+ "name": "punctuation.definition.link.end.squiffy"
450
+ },
451
+ "4": {
452
+ "name": "punctuation.definition.metadata.begin.squiffy"
453
+ },
454
+ "5": {
455
+ "name": "markup.underline.link.squiffy"
456
+ },
457
+ "6": {
458
+ "name": "punctuation.definition.metadata.end.squiffy"
459
+ }
460
+ }
461
+ },
462
+ {
463
+ "name": "meta.link.passage.squiffy",
464
+ "match": "(\\[)([^\\]]*?)(\\])(\\()((?:[^()]|\\((?:[^()]|\\((?:[^()]|\\([^()]*\\))*\\))*\\))*?)(\\))",
465
+ "captures": {
466
+ "1": {
467
+ "name": "punctuation.definition.link.begin.squiffy"
468
+ },
469
+ "2": {
470
+ "name": "string.other.link.title.squiffy",
471
+ "patterns": [
472
+ {
473
+ "include": "#handlebars"
474
+ }
475
+ ]
476
+ },
477
+ "3": {
478
+ "name": "punctuation.definition.link.end.squiffy"
479
+ },
480
+ "4": {
481
+ "name": "punctuation.definition.metadata.begin.squiffy"
482
+ },
483
+ "5": {
484
+ "patterns": [
485
+ {
486
+ "include": "#link-target"
487
+ }
488
+ ]
489
+ },
490
+ "6": {
491
+ "name": "punctuation.definition.metadata.end.squiffy"
492
+ }
493
+ }
494
+ },
495
+ {
496
+ "name": "meta.link.section.squiffy",
497
+ "match": "(\\[\\[)(.*?)(\\]\\])",
498
+ "captures": {
499
+ "1": {
500
+ "name": "punctuation.definition.link.begin.squiffy"
501
+ },
502
+ "2": {
503
+ "name": "string.other.link.title.squiffy markup.underline.link.squiffy",
504
+ "patterns": [
505
+ {
506
+ "include": "#handlebars"
507
+ }
508
+ ]
509
+ },
510
+ "3": {
511
+ "name": "punctuation.definition.link.end.squiffy"
512
+ }
513
+ }
514
+ },
515
+ {
516
+ "name": "meta.link.passage.squiffy",
517
+ "match": "(\\[)([^\\]]*?)(\\])",
518
+ "captures": {
519
+ "1": {
520
+ "name": "punctuation.definition.link.begin.squiffy"
521
+ },
522
+ "2": {
523
+ "name": "string.other.link.title.squiffy markup.underline.link.squiffy",
524
+ "patterns": [
525
+ {
526
+ "include": "#handlebars"
527
+ }
528
+ ]
529
+ },
530
+ "3": {
531
+ "name": "punctuation.definition.link.end.squiffy"
532
+ }
533
+ }
534
+ }
535
+ ]
536
+ },
537
+ "link-target": {
538
+ "comment": "A link's target, then any attribute setters after a comma: [[text]](section, score=1, not visited).",
539
+ "match": "\\s*([^,]*?)\\s*(?:(,)(.*))?$",
540
+ "captures": {
541
+ "1": {
542
+ "name": "markup.underline.link.squiffy",
543
+ "patterns": [
544
+ {
545
+ "match": ">",
546
+ "name": "keyword.operator.next-section.squiffy"
547
+ }
548
+ ]
549
+ },
550
+ "2": {
551
+ "name": "punctuation.separator.squiffy"
552
+ },
553
+ "3": {
554
+ "patterns": [
555
+ {
556
+ "include": "#assignments"
557
+ }
558
+ ]
559
+ }
560
+ }
561
+ },
562
+ "assignments": {
563
+ "comment": "Comma-separated setters after a link's target: [[text]](section, score+=1, not visited, msg = \"Hi, there\"). A comma inside quotes or brackets doesn't separate them.",
564
+ "patterns": [
565
+ {
566
+ "match": "((?:\"[^\"]*\"?|'[^']*'?|\\([^)]*\\)?|[^,\"'(])+)|(,)",
567
+ "captures": {
568
+ "1": {
569
+ "patterns": [
570
+ {
571
+ "include": "#assignment"
572
+ }
573
+ ]
574
+ },
575
+ "2": {
576
+ "name": "punctuation.separator.squiffy"
577
+ }
578
+ }
579
+ }
580
+ ]
581
+ },
582
+ "assignment": {
583
+ "comment": "One setter (setAttribute in runtime/src/squiffy.runtime.ts): a = 1, a += 1 (or -=, *=, /=), a := text with {{...}}, not a, a. In a story with a squiffy.json the value is an expression, as in {{#if}}: a = \"text\", a = b + 1; without one, a = text and a = @b. Patterns inside a capture can't anchor to its start (^ and \\G never match there), but $ is its end, and the earliest match wins.",
584
+ "patterns": [
585
+ {
586
+ "match": "\\s*(\\w*)\\s*(:=)(.*)$",
587
+ "captures": {
588
+ "1": {
589
+ "name": "variable.parameter.attribute.squiffy"
590
+ },
591
+ "2": {
592
+ "name": "keyword.operator.assignment.squiffy"
593
+ },
594
+ "3": {
595
+ "name": "string.unquoted.squiffy",
596
+ "patterns": [
597
+ {
598
+ "include": "#handlebars"
599
+ }
600
+ ]
601
+ }
602
+ }
603
+ },
604
+ {
605
+ "match": "\\s*(\\w*)\\s*([+\\-*/]?=)\\s*(.*?)\\s*$",
606
+ "captures": {
607
+ "1": {
608
+ "name": "variable.parameter.attribute.squiffy"
609
+ },
610
+ "2": {
611
+ "name": "keyword.operator.assignment.squiffy"
612
+ },
613
+ "3": {
614
+ "patterns": [
615
+ {
616
+ "include": "#value"
617
+ }
618
+ ]
619
+ }
620
+ }
621
+ },
622
+ {
623
+ "match": "\\s*(?:(not)\\s+)?(.*?)\\s*$",
624
+ "captures": {
625
+ "1": {
626
+ "name": "keyword.operator.logical.squiffy"
627
+ },
628
+ "2": {
629
+ "name": "variable.parameter.attribute.squiffy"
630
+ }
631
+ }
632
+ }
633
+ ]
634
+ },
635
+ "value": {
636
+ "comment": "A setter's value. One with quotes, brackets, operators or and/or/not is an expression, as in {{#if}}. A single word is an attribute in a story with a squiffy.json, and anything else unquoted is text, as in a story without one. Of two matches at the start, the first listed wins.",
637
+ "patterns": [
638
+ {
639
+ "match": "(?=.*(?:[\"'()+*%<>!?]|\\s[-/]|\\b(?:and|or|not|contains)\\b)).+$",
640
+ "name": "meta.expression.squiffy",
641
+ "captures": {
642
+ "0": {
643
+ "patterns": [
644
+ {
645
+ "include": "#handlebars-expression"
646
+ }
647
+ ]
648
+ }
649
+ }
650
+ },
651
+ {
652
+ "match": "-?\\d+(?:\\.\\d+)?$",
653
+ "name": "constant.numeric.squiffy"
654
+ },
655
+ {
656
+ "match": "(?:true|false)$",
657
+ "name": "constant.language.boolean.squiffy"
658
+ },
659
+ {
660
+ "match": "@\\w+$",
661
+ "name": "variable.parameter.attribute.squiffy"
662
+ },
663
+ {
664
+ "match": "(?:[\\w-]+|\\[[^\\]]*\\])$",
665
+ "name": "variable.parameter.attribute.squiffy"
666
+ },
667
+ {
668
+ "match": ".+$",
669
+ "name": "string.unquoted.squiffy"
670
+ }
671
+ ]
672
+ },
673
+ "handlebars-comment": {
674
+ "patterns": [
675
+ {
676
+ "begin": "\\{\\{!--",
677
+ "end": "--\\}\\}",
678
+ "name": "comment.block.handlebars.squiffy"
679
+ },
680
+ {
681
+ "begin": "\\{\\{!",
682
+ "end": "\\}\\}",
683
+ "name": "comment.block.handlebars.squiffy"
684
+ }
685
+ ]
686
+ },
687
+ "handlebars": {
688
+ "patterns": [
689
+ {
690
+ "comment": "Block helper open {{#if ...}} and close {{/if}}",
691
+ "begin": "(\\{\\{~?)\\s*([#/][\\w-]+)",
692
+ "beginCaptures": {
693
+ "1": {
694
+ "name": "support.constant.handlebars.squiffy punctuation.section.embedded.begin.handlebars.squiffy"
695
+ },
696
+ "2": {
697
+ "name": "keyword.control.block.handlebars.squiffy"
698
+ }
699
+ },
700
+ "end": "~?\\}\\}",
701
+ "endCaptures": {
702
+ "0": {
703
+ "name": "support.constant.handlebars.squiffy punctuation.section.embedded.end.handlebars.squiffy"
704
+ }
705
+ },
706
+ "name": "meta.embedded.expression.handlebars.squiffy",
707
+ "patterns": [
708
+ {
709
+ "include": "#handlebars-expression"
710
+ }
711
+ ]
712
+ },
713
+ {
714
+ "comment": "{{else}} and {{else if ...}}",
715
+ "begin": "(\\{\\{~?)\\s*(else)\\b(?:\\s+(if|unless)\\b)?",
716
+ "beginCaptures": {
717
+ "1": {
718
+ "name": "support.constant.handlebars.squiffy punctuation.section.embedded.begin.handlebars.squiffy"
719
+ },
720
+ "2": {
721
+ "name": "keyword.control.block.handlebars.squiffy"
722
+ },
723
+ "3": {
724
+ "name": "keyword.control.block.handlebars.squiffy"
725
+ }
726
+ },
727
+ "end": "~?\\}\\}",
728
+ "endCaptures": {
729
+ "0": {
730
+ "name": "support.constant.handlebars.squiffy punctuation.section.embedded.end.handlebars.squiffy"
731
+ }
732
+ },
733
+ "name": "meta.embedded.expression.handlebars.squiffy",
734
+ "patterns": [
735
+ {
736
+ "include": "#handlebars-expression"
737
+ }
738
+ ]
739
+ },
740
+ {
741
+ "comment": "{{helper args}}, {{attribute}} on its own, or {{= expression}}",
742
+ "begin": "(\\{\\{\\{?~?)\\s*(?:([\\w.-]+)(?=\\s)|([\\w.-]+)(?=\\s*~?\\})|(=))?",
743
+ "beginCaptures": {
744
+ "1": {
745
+ "name": "support.constant.handlebars.squiffy punctuation.section.embedded.begin.handlebars.squiffy"
746
+ },
747
+ "2": {
748
+ "name": "support.function.helper.handlebars.squiffy"
749
+ },
750
+ "3": {
751
+ "name": "variable.parameter.attribute.handlebars.squiffy"
752
+ },
753
+ "4": {
754
+ "name": "keyword.operator.display.handlebars.squiffy"
755
+ }
756
+ },
757
+ "end": "~?\\}\\}\\}?",
758
+ "endCaptures": {
759
+ "0": {
760
+ "name": "support.constant.handlebars.squiffy punctuation.section.embedded.end.handlebars.squiffy"
761
+ }
762
+ },
763
+ "name": "meta.embedded.expression.handlebars.squiffy",
764
+ "patterns": [
765
+ {
766
+ "include": "#handlebars-expression"
767
+ }
768
+ ]
769
+ }
770
+ ]
771
+ },
772
+ "handlebars-expression": {
773
+ "patterns": [
774
+ {
775
+ "begin": "(\\()\\s*([\\w.-]+)?",
776
+ "beginCaptures": {
777
+ "1": {
778
+ "name": "punctuation.section.parens.begin.handlebars.squiffy"
779
+ },
780
+ "2": {
781
+ "name": "support.function.helper.handlebars.squiffy"
782
+ }
783
+ },
784
+ "end": "\\)",
785
+ "endCaptures": {
786
+ "0": {
787
+ "name": "punctuation.section.parens.end.handlebars.squiffy"
788
+ }
789
+ },
790
+ "patterns": [
791
+ {
792
+ "include": "#handlebars-expression"
793
+ }
794
+ ]
795
+ },
796
+ {
797
+ "begin": "\"",
798
+ "end": "\"",
799
+ "name": "string.quoted.double.handlebars.squiffy"
800
+ },
801
+ {
802
+ "begin": "'",
803
+ "end": "'",
804
+ "name": "string.quoted.single.handlebars.squiffy"
805
+ },
806
+ {
807
+ "match": "-?\\b\\d+(?:\\.\\d+)?\\b",
808
+ "name": "constant.numeric.handlebars.squiffy"
809
+ },
810
+ {
811
+ "match": "\\b(?:true|false|null|undefined)\\b",
812
+ "name": "constant.language.handlebars.squiffy"
813
+ },
814
+ {
815
+ "match": "\\b(?:and|or|not)\\b",
816
+ "name": "keyword.operator.logical.handlebars.squiffy"
817
+ },
818
+ {
819
+ "match": "!=|>=|<=|=(?!=)|>|<|\\bcontains\\b",
820
+ "name": "keyword.operator.comparison.handlebars.squiffy"
821
+ },
822
+ {
823
+ "comment": "a ? b : c. A : with no space before it is in an object, as in { hp: 10 }",
824
+ "match": "\\?|(?<=\\s):(?=\\s)",
825
+ "name": "keyword.operator.ternary.handlebars.squiffy"
826
+ },
827
+ {
828
+ "comment": "- and / are operators only at the start of a word: a-b is an attribute name and a/b a path",
829
+ "match": "[+*%]|(?<![\\w.\\]-])[-/]",
830
+ "name": "keyword.operator.arithmetic.handlebars.squiffy"
831
+ },
832
+ {
833
+ "match": "([\\w-]+)(=)",
834
+ "captures": {
835
+ "1": {
836
+ "name": "entity.other.attribute-name.handlebars.squiffy"
837
+ },
838
+ "2": {
839
+ "name": "punctuation.separator.key-value.handlebars.squiffy"
840
+ }
841
+ }
842
+ },
843
+ {
844
+ "match": "\\bas\\s*\\|[^|]*\\|",
845
+ "name": "variable.parameter.block.handlebars.squiffy"
846
+ },
847
+ {
848
+ "match": "\\[[^\\]]*\\]",
849
+ "name": "variable.parameter.attribute.handlebars.squiffy"
850
+ },
851
+ {
852
+ "match": "@?[\\w.-]+",
853
+ "name": "variable.parameter.attribute.handlebars.squiffy"
854
+ }
855
+ ]
856
+ },
857
+ "html-comment": {
858
+ "begin": "<!--",
859
+ "end": "-->",
860
+ "name": "comment.block.html.squiffy"
861
+ },
862
+ "html-tag": {
863
+ "begin": "(</?)([A-Za-z][\\w:-]*)",
864
+ "beginCaptures": {
865
+ "1": {
866
+ "name": "punctuation.definition.tag.begin.html.squiffy"
867
+ },
868
+ "2": {
869
+ "name": "entity.name.tag.html.squiffy"
870
+ }
871
+ },
872
+ "end": "/?>",
873
+ "endCaptures": {
874
+ "0": {
875
+ "name": "punctuation.definition.tag.end.html.squiffy"
876
+ }
877
+ },
878
+ "name": "meta.tag.html.squiffy",
879
+ "patterns": [
880
+ {
881
+ "include": "#handlebars"
882
+ },
883
+ {
884
+ "match": "[\\w:-]+",
885
+ "name": "entity.other.attribute-name.html.squiffy"
886
+ },
887
+ {
888
+ "match": "=",
889
+ "name": "punctuation.separator.key-value.html.squiffy"
890
+ },
891
+ {
892
+ "begin": "\"",
893
+ "end": "\"",
894
+ "name": "string.quoted.double.html.squiffy",
895
+ "patterns": [
896
+ {
897
+ "include": "#handlebars"
898
+ }
899
+ ]
900
+ },
901
+ {
902
+ "begin": "'",
903
+ "end": "'",
904
+ "name": "string.quoted.single.html.squiffy",
905
+ "patterns": [
906
+ {
907
+ "include": "#handlebars"
908
+ }
909
+ ]
910
+ }
911
+ ]
912
+ },
913
+ "markdown-block": {
914
+ "patterns": [
915
+ {
916
+ "match": "^\\s*(#{1,6})\\s+(.*)$",
917
+ "captures": {
918
+ "0": {
919
+ "name": "markup.heading.markdown.squiffy"
920
+ },
921
+ "1": {
922
+ "name": "punctuation.definition.heading.markdown.squiffy"
923
+ },
924
+ "2": {
925
+ "name": "entity.name.section.markdown.squiffy",
926
+ "patterns": [
927
+ {
928
+ "include": "#inline"
929
+ }
930
+ ]
931
+ }
932
+ }
933
+ },
934
+ {
935
+ "match": "^\\s*([*+-]|\\d+\\.)(?=\\s)",
936
+ "captures": {
937
+ "1": {
938
+ "name": "punctuation.definition.list.begin.markdown.squiffy"
939
+ }
940
+ }
941
+ },
942
+ {
943
+ "match": "^\\s*(>)(?=\\s)",
944
+ "captures": {
945
+ "1": {
946
+ "name": "punctuation.definition.quote.begin.markdown.squiffy"
947
+ }
948
+ }
949
+ }
950
+ ]
951
+ },
952
+ "markdown-inline": {
953
+ "patterns": [
954
+ {
955
+ "match": "(\\*\\*|__)(?=\\S)(.+?)(?<=\\S)(\\1)",
956
+ "captures": {
957
+ "0": {
958
+ "name": "markup.bold.markdown.squiffy"
959
+ },
960
+ "1": {
961
+ "name": "punctuation.definition.bold.markdown.squiffy"
962
+ },
963
+ "3": {
964
+ "name": "punctuation.definition.bold.markdown.squiffy"
965
+ }
966
+ }
967
+ },
968
+ {
969
+ "match": "(?<![\\w*])(\\*)(?=[^\\s*])(.+?)(?<=[^\\s*])(\\*)(?![\\w*])",
970
+ "captures": {
971
+ "0": {
972
+ "name": "markup.italic.markdown.squiffy"
973
+ },
974
+ "1": {
975
+ "name": "punctuation.definition.italic.markdown.squiffy"
976
+ },
977
+ "3": {
978
+ "name": "punctuation.definition.italic.markdown.squiffy"
979
+ }
980
+ }
981
+ },
982
+ {
983
+ "match": "(?<!\\w)(_)(?=\\S)(.+?)(?<=\\S)(_)(?!\\w)",
984
+ "captures": {
985
+ "0": {
986
+ "name": "markup.italic.markdown.squiffy"
987
+ },
988
+ "1": {
989
+ "name": "punctuation.definition.italic.markdown.squiffy"
990
+ },
991
+ "3": {
992
+ "name": "punctuation.definition.italic.markdown.squiffy"
993
+ }
994
+ }
995
+ },
996
+ {
997
+ "match": "(`)([^`]+)(`)",
998
+ "name": "markup.inline.raw.markdown.squiffy"
999
+ }
1000
+ ]
1001
+ }
1002
+ }
1003
+ }