/
text.html.ecmarkup.js
277 lines (276 loc) · 10 KB
/
text.html.ecmarkup.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-etc>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
dependencies: ['etc', 'source.yaml', 'text.grammarkdown', 'text.html.basic'],
extensions: [],
extensionsWithDot: ['.html'],
injections: {
'L:(source.embedded.yaml.front-matter.ecmarkup - (comment | embedded))': {
patterns: [{include: 'text.html.basic#character-reference'}]
},
'L:(text.html.ecmarkup meta.tag.opaque-element - (meta.emu-alg | meta.emu-grammar))':
{patterns: [{match: '[*_`|~\\\\]'}]}
},
names: ['ecmarkup', 'ecmarkdown'],
patterns: [
{
begin: '\\A(?=\\s*(?:\\d+\\.|\\*)(?=$|\\s))',
end: '(?=A)B',
patterns: [{include: '#list'}, {include: '#main'}]
},
{include: '#main'}
],
repository: {
'code-blocks': {
begin: '(?i)\\s*(<(pre|code)(?=$|\\s|>))',
beginCaptures: {1: {patterns: [{include: '#tag-opening-start'}]}},
end: '(?i)\\s*(</\\2\\s*>)',
endCaptures: {1: {patterns: [{include: '#tag-closing'}]}},
name: 'meta.tag.opaque-element.${2:/downcase}.html.ecmarkup',
patterns: [{include: '#tag-opening-rest'}, {include: '#main'}]
},
'emu-alg': {
begin: '(?i)\\s*(<emu-alg(?=$|\\s|>))',
beginCaptures: {1: {patterns: [{include: '#tag-opening-start'}]}},
end: '(?i)\\s*(</emu-alg\\s*>)',
endCaptures: {1: {patterns: [{include: '#tag-closing'}]}},
name: 'meta.emu-alg.html.ecmarkup',
patterns: [
{include: '#tag-opening-rest'},
{
begin: '(?<=>)',
end: '(?i)(?=\\s*(</emu-alg\\s*>))',
patterns: [{include: '#list'}, {include: '#main'}]
}
]
},
'emu-element': {
begin: '(?i)\\s*(<(emu-[\\w][-\\w]*)(?=$|\\s|>))',
beginCaptures: {1: {patterns: [{include: '#tag-opening-start'}]}},
end: '(?i)\\s*(</\\2\\s*>)',
endCaptures: {1: {patterns: [{include: '#tag-closing'}]}},
name: 'meta.${2:/downcase}.html.ecmarkup',
patterns: [{include: '#tag-opening-rest'}, {include: '#tag-body'}]
},
'emu-grammar': {
begin: '(?i)\\s*(<emu-grammar(?=$|\\s|>))',
beginCaptures: {1: {patterns: [{include: '#tag-opening-start'}]}},
end: '(?i)\\s*(</emu-grammar\\s*>)',
endCaptures: {1: {patterns: [{include: '#tag-closing'}]}},
name: 'meta.emu-grammar.html.ecmarkup',
patterns: [
{include: '#tag-opening-rest'},
{
begin: '(?<=>)',
contentName: 'text.embedded.grammarkdown',
end: '(?i)(?=\\s*(</emu-grammar\\s*>))',
name: 'meta.grammar.ecmarkup',
patterns: [{include: 'text.grammarkdown'}]
}
]
},
escape: {
captures: {1: {name: 'punctuation.definition.escape.backslash.ecmarkup'}},
match: '(\\\\)[*_`<|~\\\\]',
name: 'constant.character.escape.ecmarkup'
},
formatting: {
patterns: [
{
captures: {
1: {name: 'punctuation.definition.variable.begin.ecmarkup'},
2: {patterns: [{include: '#escape'}]},
3: {name: 'punctuation.definition.variable.end.ecmarkup'}
},
match: '(?<![\\w*_`<|~])(_)((?:\\\\_|[^\\s_])++)(_)',
name: 'variable.reference.ecmarkup'
},
{
captures: {
1: {name: 'punctuation.definition.value.begin.ecmarkup'},
2: {patterns: [{include: '#escape'}]},
3: {name: 'punctuation.definition.value.end.ecmarkup'}
},
match:
'(?<![\\w*_`<|~])(\\*)(?=\\S)((?:\\\\\\*|[^*])++)(?<=\\S)(\\*)',
name: 'constant.other.value.ecmarkup'
},
{
captures: {
1: {name: 'punctuation.definition.value.begin.ecmarkup'},
2: {patterns: [{include: '#escape'}]},
3: {name: 'punctuation.definition.value.end.ecmarkup'}
},
match: '(\\`)(?=\\S)((?:\\\\`|[^`])++)(?<=\\S)(\\`)',
name: 'markup.raw.code.monospace.ecmarkup'
},
{
captures: {
1: {name: 'punctuation.definition.constant.begin.ecmarkup'},
2: {patterns: [{include: '#escape'}]},
3: {name: 'punctuation.definition.constant.end.ecmarkup'}
},
match: '(?<![\\w*_`<|~])(~)(?=\\S)((?:\\\\~|[^~])++)(?<=\\S)(~)',
name: 'support.constant.spec-level.ecmarkup'
},
{include: '#nonterminal'}
]
},
list: {
begin: '^(\\s*)((\\d+\\.|\\*))(?=$|\\s)(?:\\s*(Assert(:)))?[ \\t]*',
beginCaptures: {
2: {name: 'markup.list.marker.ecmarkup'},
3: {name: 'punctuation.definition.list.ecmarkup'},
4: {name: 'support.constant.assertion.ecmarkup'},
5: {name: 'puncutation.definition.constant.ecmarkup'}
},
end: '(?=\\s*</(?i:emu-alg)\\s*>)|(?!\\G)^(?=\\s*(?:$|(?:\\d+\\.|\\*)(?:$|\\s)))',
name: 'meta.list.ecmarkup',
patterns: [
{
begin: '\\G(?=\\[)',
end: '(?<=\\])(?:\\s*(Assert(:)))?',
endCaptures: {
1: {name: 'support.constant.assertion.ecmarkup'},
2: {name: 'puncutation.definition.constant.ecmarkup'}
},
patterns: [
{
begin: '\\G(\\[)',
beginCaptures: {
0: {name: 'punctuation.definition.list.begin.ecmarkup'},
1: {name: 'brackethighlighter.square'}
},
end: '(\\])',
endCaptures: {
0: {name: 'punctuation.definition.list.end.ecmarkup'},
1: {name: 'brackethighlighter.square'}
},
name: 'meta.attributes.ecmarkup',
patterns: [
{
applyEndPatternLast: true,
begin: '(\\w[-\\w]*)\\s*(=)\\s*(?=")',
beginCaptures: {
1: {name: 'entity.other.attribute-name.ecmarkup'},
2: {patterns: [{include: 'etc#eql'}]}
},
end: '(?!\\G)',
name: 'meta.attribute.ecmarkup',
patterns: [{include: 'etc#strDouble'}, {include: 'etc#comma'}]
}
]
}
]
},
{include: '#main'}
]
},
main: {
patterns: [
{include: '#emu-alg'},
{include: '#emu-grammar'},
{include: '#emu-element'},
{include: '#metadata-block'},
{include: '#code-blocks'},
{include: '#escape'},
{include: '#formatting'},
{include: 'text.html.basic'}
]
},
'metadata-block': {
begin:
'(?ix) \\s*\n((<)(pre)\n(\n\t\\s+[^>]*?(?<=\\s)\n\tclass \\s* = \\s*\n\t(?:"metadata"|\'metadata\'|metadata)\n\t(?=\\s|>) [^>]*\n)\n(>))',
beginCaptures: {
1: {name: 'meta.tag.other.html.ecmarkup'},
2: {name: 'punctuation.definition.tag.begin.html.ecmarkup'},
3: {name: 'entity.name.tag.block.pre.html'},
4: {patterns: [{include: 'text.html.basic#tag-stuff'}]},
5: {name: 'punctuation.definition.tag.end.html'}
},
contentName: 'source.embedded.yaml.front-matter.ecmarkup',
end: '(?i)\\s*((</)(pre)\\s*(>))',
endCaptures: {
1: {name: 'meta.tag.block.pre.html'},
2: {name: 'punctuation.definition.tag.begin.html'},
3: {name: 'entity.name.tag.block.pre.html'},
4: {name: 'punctuation.definition.tag.end.html'}
},
name: 'meta.tag.block.pre.front-matter.html.ecmarkup',
patterns: [{include: 'source.yaml'}]
},
nonterminal: {
captures: {
1: {name: 'punctuation.definition.nonterminal.begin.ecmarkup'},
2: {name: 'brackethighlighter.tag'},
3: {name: 'keyword.other.nonterminal.ecmarkup'},
4: {patterns: [{include: '#nonterminal-params'}]},
5: {name: 'keyword.operator.optional.question-mark.ecmarkup'},
6: {name: 'keyword.operator.optional.english.ecmarkup'},
7: {name: 'punctuation.separator.suffix.ecmarkup'},
8: {name: 'punctuation.definition.nonterminal.end.ecmarkup'},
9: {name: 'brackethighlighter.tag'}
},
match:
'(?x) (?<![\\w*_`<|~])\n((\\|))\n([A-Za-z0-9]+)\n(\\[ [^\\]]* \\])?\n(?: (\\?) | ((_)opt))?\n((\\|))',
name: 'meta.nonterminal.ecmarkup'
},
'nonterminal-params': {
begin: '(\\[)',
beginCaptures: {
0: {name: 'punctuation.section.list.begin.ecmarkup'},
1: {name: 'brackethighlighter.square'}
},
end: '(\\])',
endCaptures: {
0: {name: 'punctuation.section.list.end.ecmarkup'},
1: {name: 'brackethighlighter.square'}
},
name: 'meta.parameters.ecmarkup',
patterns: [
{match: '\\w[-\\w]*', name: 'variable.parameter.nonterminal.ecmarkup'},
{
match: '\\?',
name: 'keyword.operator.optional.question-mark.ecmarkup'
},
{include: '#escape'},
{include: 'etc#comma'}
]
},
'tag-body': {
begin: '(?<=>)',
end: '(?=\\s*</emu-[-\\w]*\\s*>)',
name: 'meta.tag-contents.html.ecmarkup',
patterns: [{include: '#main'}]
},
'tag-closing': {
captures: {
1: {name: 'punctuation.definition.tag.begin.html.ecmarkup'},
2: {name: 'entity.name.tag.other.html.ecmarkup'},
3: {name: 'punctuation.definition.tag.end.html.ecmarkup'}
},
match: '(?i)(?:^|\\G)(</)(\\w[-\\w]*)\\s*(>)',
name: 'meta.tag.other.html.ecmarkup'
},
'tag-opening-rest': {
begin: '\\G',
end: '\\s*(>)',
endCaptures: {1: {name: 'punctuation.definition.tag.end.html.ecmarkup'}},
patterns: [{include: 'text.html.basic#tag-stuff'}]
},
'tag-opening-start': {
captures: {
1: {name: 'punctuation.definition.tag.begin.html.ecmarkup'},
2: {name: 'entity.name.tag.other.html.ecmarkup'}
},
match: '(?:^|\\G)(<)(\\w[-\\w]*)(?=$|\\s|>)',
name: 'meta.tag.other.html.ecmarkup'
}
},
scopeName: 'text.html.ecmarkup'
}
export default grammar