summaryrefslogtreecommitdiffstats
path: root/assets/syntaxes/02_Extra/Slim.sublime-syntax
blob: 3d492aca953a5f5cfdc3b079ae270e52ad94197b (plain)
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
%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: Ruby Slim
file_extensions:
  - slim
  - skim
scope: text.slim
contexts:
  main:
    - match: ^(\s*)(ruby):$
      captures:
        2: constant.language.name.ruby.filter.slim
      push:
        - meta_scope: text.ruby.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.ruby
    - match: ^(\s*)(javascript):$
      captures:
        2: constant.language.name.javascript.filter.slim
      push:
        - meta_scope: source.js.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.js
    - match: ^(---)\s*\n
      captures:
        1: storage.frontmatter.slim
      push:
        - meta_scope: source.yaml.meta.slim
        - match: ^(---)\s*\n
          captures:
            1: storage.frontmatter.slim
          pop: true
        - include: scope:source.yaml
    - match: ^(\s*)(coffee):$
      captures:
        2: constant.language.name.coffeescript.filter.slim
      push:
        - meta_scope: text.coffeescript.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.coffee
    - match: ^(\s*)(markdown):$
      captures:
        2: constant.language.name.markdown.filter.slim
      push:
        - meta_scope: text.markdown.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:text.html.markdown
    - match: ^(\s*)(css):$
      captures:
        2: constant.language.name.css.filter.slim
      push:
        - meta_scope: text.css.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.css
    - match: ^(\s*)(sass):$
      captures:
        2: constant.language.name.sass.filter.slim
      push:
        - meta_scope: text.sass.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.sass
    - match: ^(\s*)(scss):$
      captures:
        2: constant.language.name.scss.filter.slim
      push:
        - meta_scope: text.scss.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.scss
    - match: ^(\s*)(less):$
      captures:
        2: constant.language.name.less.filter.slim
      push:
        - meta_scope: text.less.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.less
    - match: ^(\s*)(erb):$
      captures:
        2: constant.language.name.erb.filter.slim
      push:
        - meta_scope: text.erb.filter.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:source.erb
    - match: ^(! )($|\s.*)
      scope: meta.prolog.slim
      captures:
        1: punctuation.definition.prolog.slim
    - match: ^(\s*)(/)\s*.*$
      captures:
        2: comment.line.slash.slim
      push:
        - meta_scope: comment.block.slim
        - match: ^(?!(\1\s)|\s*$)
          pop: true
    - match: ^\s*(?=-)
      push:
        - match: $
          pop: true
        - include: rubyline
    - match: (?==+|~)
      push:
        - match: $
          pop: true
        - include: rubyline
    - include: tag-attribute
    - include: embedded-ruby
    - match: ^(\s*)(\||')\s*
      comment: Verbatim text (can include HTML tags and copied lines)
      push:
        - match: ^(?!(\1\s)|\s*$)
          pop: true
        - include: scope:text.html.basic
        - include: embedded-ruby
    - match: '^\s*(\.|#|[-a-zA-Z0-9]+)([\w-]+)?'
      comment: '1 - dot OR hash OR any combination of word, number; 2 - OPTIONAL any combination of word, number, dash or underscore (following a . or'
      captures:
        1: entity.name.tag.slim
        2: entity.other.attribute-name.event.slim
      push:
        - meta_scope: meta.tag
        - match: '$|(?!\.|#|:|-|~|/|\}|\]|\*|\s?[\*\{])'
          captures:
            1: entity.name.tag.slim
            2: entity.other.attribute-name.event.slim
          pop: true
        - match: '(:[\w\d]+)+'
          comment: XML
          push:
            - meta_scope: entity.name.tag.slim
            - match: $|\s
              pop: true
        - match: '(:\s)(\.|#|[a-zA-Z0-9]+)([\w-]+)?'
          comment: Inline HTML / 1 - colon; 2 - dot OR hash OR any combination of word, number; 3 - OPTIONAL any combination of word, number, dash or underscore (following a . or
          captures:
            1: punctuation.definition.tag.end.slim
            2: entity.name.tag.slim
            3: entity.other.attribute-name.event.slim
          push:
            - match: '$|(?!\.|#|=|-|~|/|\}|\]|\*|\s?[\*\{])'
              captures:
                1: punctuation.definition.tag.end.slim
                2: entity.name.tag.slim
                3: entity.other.attribute-name.event.slim
              pop: true
            - include: root-class-id-tag
            - include: tag-attribute
        - match: '(\*\{)(?=.*\}|.*\|\s*$)'
          comment: Splat attributes
          captures:
            1: punctuation.section.embedded.ruby
          push:
            - meta_scope: source.ruby.embedded.slim
            - match: '(\})|$|^(?!.*\|\s*$)'
              captures:
                1: punctuation.section.embedded.ruby
              pop: true
            - include: embedded-ruby
        - include: root-class-id-tag
        - include: rubyline
        - match: /
          scope: punctuation.terminator.tag.slim
    - match: ^\s*(\\.)
      captures:
        1: meta.escape.slim
    - match: ^\s*(?=\||')
      push:
        - match: $
          pop: true
        - include: embedded-ruby
        - include: scope:text.html.basic
    - match: '(?=<[\w\d\:]+)'
      comment: Inline and root-level HTML tags
      push:
        - match: $|\/\>
          pop: true
        - include: scope:text.html.basic
  continuation:
    - match: '([\\,])\s*\n'
      captures:
        1: punctuation.separator.continuation.slim
  delimited-ruby-a:
    - match: '=\('
      push:
        - meta_scope: source.ruby.embedded.slim
        - match: \)(?=( \w|$))
          pop: true
        - include: scope:source.ruby.rails
  delimited-ruby-b:
    - match: '=\['
      push:
        - meta_scope: source.ruby.embedded.slim
        - match: '\](?=( \w|$))'
          pop: true
        - include: scope:source.ruby.rails
  delimited-ruby-c:
    - match: '=\{'
      push:
        - meta_scope: source.ruby.embedded.slim
        - match: '\}(?=( \w|$))'
          pop: true
        - include: scope:source.ruby.rails
  embedded-ruby:
    - match: '(?<!\\)#\{{1,2}'
      captures:
        0: punctuation.section.embedded.ruby
      push:
        - meta_scope: source.ruby.embedded.html
        - match: '\}{1,2}'
          captures:
            0: punctuation.section.embedded.ruby
          pop: true
        - include: scope:source.ruby.rails
  entities:
    - match: '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)'
      scope: constant.character.entity.html
      captures:
        1: punctuation.definition.entity.html
        3: punctuation.definition.entity.html
    - match: '&'
      scope: invalid.illegal.bad-ampersand.html
  interpolated-ruby:
    - match: '=(?=\b)'
      push:
        - meta_scope: source.ruby.embedded.html
        - match: \s|\w$
          pop: true
  root-class-id-tag:
    - match: '(\.|#)([\w\d\-]+)'
      captures:
        1: punctuation.separator.key-value.html
        2: entity.other.attribute-name.html
  rubyline:
    - match: (==|=)(<>|><|<'|'<|<|>)?|-
      comment: Hack to thwart Sublime's Ruby highlighter. It thinks do without a variable continues the next line (this can be muted with a / at the end of the line). For things like yields, do is unnecessary without an argument, so this hack will suffice
      push:
        - meta_scope: meta.line.ruby.slim
        - meta_content_scope: source.ruby.embedded.slim
        - match: (do\s*\n$)|(?<!\\|,|,\n|\\\n)$
          captures:
            1: keyword.control.start-block.ruby
          pop: true
        - match: '#.*$'
          comment: Hack to let ruby comments work in this context properly
          scope: comment.line.number-sign.ruby
        - include: continuation
        - include: scope:source.ruby.rails
  string-double-quoted:
    - match: (")(?=.*")
      captures:
        0: punctuation.definition.string.begin.html
      push:
        - meta_scope: string.quoted.double.html
        - meta_content_scope: meta.toc-list.id.html
        - match: '"'
          captures:
            0: punctuation.definition.string.end.html
          pop: true
        - include: embedded-ruby
        - include: entities
  string-single-quoted:
    - match: (')(?=.*')
      captures:
        0: punctuation.definition.string.begin.html
      push:
        - meta_scope: string.quoted.single.html
        - meta_content_scope: meta.toc-list.id.html
        - match: "'"
          captures:
            0: punctuation.definition.string.end.html
          pop: true
        - include: embedded-ruby
        - include: entities
  tag-attribute:
    - match: '([\w.#_-]+)(=)(?!\s)(true|false|nil)?(\s*\(|\{)?'
      captures:
        1: entity.other.attribute-name.event.slim
        2: punctuation.separator.key-value.html
        3: constant.language.slim
      push:
        - meta_scope: meta.attribute-with-value.slim
        - match: '\}|\)|$'
          captures:
            1: entity.other.attribute-name.event.slim
            2: punctuation.separator.key-value.html
            3: constant.language.slim
          pop: true
        - include: tag-stuff
        - include: string-double-quoted
        - include: string-single-quoted
  tag-stuff:
    - include: tag-attribute
    - include: interpolated-ruby
    - include: delimited-ruby-a
    - include: delimited-ruby-b
    - include: delimited-ruby-c
    - include: rubyline
    - include: embedded-ruby