renusify 2.3.1 → 2.4.0
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.
- package/components/bar/toolbar/index.vue +26 -20
- package/components/bar/toolbar/laptop.vue +27 -25
- package/components/bar/toolbar/mobile.vue +28 -27
- package/components/calendar/index.vue +25 -33
- package/components/calendar/month.vue +35 -10
- package/components/calendar/year.vue +19 -8
- package/components/card/index.vue +49 -49
- package/components/codeEditor/highlightCss.vue +12 -24
- package/components/codeEditor/highlightHtml.vue +14 -29
- package/components/codeEditor/highlightJs.vue +14 -25
- package/components/codeEditor/index.vue +214 -205
- package/components/codeEditor/mixin.js +1 -42
- package/components/form/dateInput/index.vue +407 -413
- package/components/form/dateInput/month.vue +35 -11
- package/components/form/dateInput/year.vue +14 -8
- package/components/form/groupInput/index.js +2 -1
- package/components/form/groupInput/index.vue +13 -32
- package/components/form/jsonInput/index.vue +29 -19
- package/components/form/text-editor/index.vue +58 -8
- package/components/form/text-editor/style.scss +6 -0
- package/components/highlight/index.js +1 -0
- package/components/highlight/index.vue +31 -0
- package/components/highlight/mixin.js +1106 -0
- package/components/highlight/style.scss +103 -0
- package/components/index.js +1 -0
- package/components/table/crud/index.vue +82 -66
- package/components/table/index.vue +5 -8
- package/directive/sortable/index.js +1 -3
- package/index.js +0 -2
- package/package.json +1 -1
- package/style/app.scss +13 -13
- package/tools/icons.js +3 -1
|
@@ -0,0 +1,1106 @@
|
|
|
1
|
+
//forked from https://github.com/speed-highlight/core
|
|
2
|
+
export default {
|
|
3
|
+
data() {
|
|
4
|
+
return {
|
|
5
|
+
expandData: {
|
|
6
|
+
num: {
|
|
7
|
+
type: 'num',
|
|
8
|
+
match: /(\.e?|\b)\d(e-|[\d.oxa-fA-F_])*(\.|\b)/g
|
|
9
|
+
},
|
|
10
|
+
str: {
|
|
11
|
+
type: 'str',
|
|
12
|
+
match: /(["'])(\\[^]|(?!\1)[^\r\n\\])*\1?/g
|
|
13
|
+
},
|
|
14
|
+
strDouble: {
|
|
15
|
+
type: 'str',
|
|
16
|
+
match: /"((?!")[^\r\n\\]|\\[^])*"?/g
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
languages: {}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
created() {
|
|
23
|
+
this.languages.asm = {
|
|
24
|
+
default: [
|
|
25
|
+
{
|
|
26
|
+
type: 'cmnt',
|
|
27
|
+
match: /(;|#).*/gm
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
expand: 'str'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
expand: 'num'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
// value (ex: "$0x1")
|
|
37
|
+
type: 'num',
|
|
38
|
+
match: /\$[\da-fA-F]*\b/g
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'kwd',
|
|
42
|
+
// ex: "section .data"
|
|
43
|
+
match: /^[a-z]+\s+[a-z.]+\b/gm,
|
|
44
|
+
sub: [
|
|
45
|
+
{
|
|
46
|
+
// keyword (ex: "section")
|
|
47
|
+
type: 'func',
|
|
48
|
+
match: /^[a-z]+/g
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
// instruction (ex: "mov")
|
|
54
|
+
type: 'kwd',
|
|
55
|
+
match: /^\t*[a-z][a-z\d]*\b/gm
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
match: /%|\$/g,
|
|
59
|
+
type: 'oper'
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
this.languages.bash = {
|
|
64
|
+
default: [
|
|
65
|
+
{
|
|
66
|
+
sub: 'todo',
|
|
67
|
+
match: /#.*/g
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'str',
|
|
71
|
+
match: /(["'])((?!\1)[^\r\n\\]|\\[^])*\1?/g,
|
|
72
|
+
sub: [{
|
|
73
|
+
type: 'var',
|
|
74
|
+
match: /\$\w+|\${[^}]*}|\$\([^)]*\)/g
|
|
75
|
+
}]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
// relative or absolute path
|
|
79
|
+
type: 'oper',
|
|
80
|
+
match: /(?<=\s|^)\.*\/[a-z/_.-]+/gi
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'kwd',
|
|
84
|
+
match: /\s-[a-zA-Z]+|$<|[&|;]+|\b(unset|readonly|shift|export|if|fi|else|elif|while|do|done|for|until|case|esac|break|continue|exit|return|trap|wait|eval|exec|then|declare|enable|local|select|typeset|time|add|remove|install|update|delete)(?=\s|$)/g
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
expand: 'num'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
// command
|
|
91
|
+
type: 'func',
|
|
92
|
+
match: /(?<=(^|\||\&\&|\;)\s*)[a-z_.-]+(?=\s|$)/gmi
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'bool',
|
|
96
|
+
match: /(?<=\s|^)(true|false)(?=\s|$)/g
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'oper',
|
|
100
|
+
match: /[=(){}<>!]+/g
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'var',
|
|
104
|
+
match: /(?<=\s|^)[\w_]+(?=\s*=)/g
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'var',
|
|
108
|
+
match: /\$\w+|\${[^}]*}|\$\([^)]*\)/g
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
this.languages.bf = {
|
|
113
|
+
default: [
|
|
114
|
+
{
|
|
115
|
+
match: /[^\[\->+.<\]\s].*/g,
|
|
116
|
+
sub: 'todo'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: 'func',
|
|
120
|
+
match: /\.+/g
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'kwd',
|
|
124
|
+
match: /[<>]+/g
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'oper',
|
|
128
|
+
match: /[+-]+/g
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
this.languages.c = {
|
|
133
|
+
default: [
|
|
134
|
+
{
|
|
135
|
+
match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
|
|
136
|
+
sub: 'todo'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
expand: 'str'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
expand: 'num'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
type: 'kwd',
|
|
146
|
+
match: /#\s*include (<.*>|".*")/g,
|
|
147
|
+
sub: [
|
|
148
|
+
{
|
|
149
|
+
type: 'str',
|
|
150
|
+
match: /(<|").*/g
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
match: /asm\s*{[^}]*}/g,
|
|
156
|
+
sub: [
|
|
157
|
+
{
|
|
158
|
+
type: 'kwd',
|
|
159
|
+
match: /^asm/g
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
//type: 'str',
|
|
163
|
+
match: /[^{}]*(?=}$)/g,
|
|
164
|
+
sub: 'asm'
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
type: 'kwd',
|
|
170
|
+
match: /\*|&|#[a-z]+\b|\b(asm|auto|double|int|struct|break|else|long|switch|case|enum|register|typedef|char|extern|return|union|const|float|short|unsigned|continue|for|signed|void|default|goto|sizeof|volatile|do|if|static|while)\b/g
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
type: 'oper',
|
|
174
|
+
match: /[/*+:?&|%^~=!,<>.^-]+/g
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
type: 'func',
|
|
178
|
+
match: /[a-zA-Z_][\w_]*(?=\s*\()/g
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
type: 'class',
|
|
182
|
+
match: /\b[A-Z][\w_]*\b/g
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
this.languages.css = {
|
|
187
|
+
default: [
|
|
188
|
+
{
|
|
189
|
+
match: /\/\*((?!\*\/)[^])*(\*\/)?/g,
|
|
190
|
+
sub: 'todo'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
expand: 'str'
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: 'kwd',
|
|
197
|
+
match: /@\w+\b|\b(and|not|only|or)\b|\b[a-z-]+(?=[^{}]*{)/g
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
type: 'var',
|
|
201
|
+
match: /\b[\w-]+(?=\s*:)|(::?|\.)[\w-]+(?=[^{}]*{)/g
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
type: 'func',
|
|
205
|
+
match: /#[\w-]+(?=[^{}]*{)/g
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
type: 'num',
|
|
209
|
+
match: /#[\da-f]{3,8}/g
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
type: 'num',
|
|
213
|
+
match: /\d+(\.\d+)?(cm|mm|in|px|pt|pc|em|ex|ch|rem|vm|vh|vmin|vmax|%)?/g,
|
|
214
|
+
sub: [
|
|
215
|
+
{
|
|
216
|
+
type: 'var',
|
|
217
|
+
match: /[a-z]+|%/g
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
match: /url\([^)]*\)/g,
|
|
223
|
+
sub: [
|
|
224
|
+
{
|
|
225
|
+
type: 'func',
|
|
226
|
+
match: /url(?=\()/g
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
type: 'str',
|
|
230
|
+
match: /[^()]+/g
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
type: 'func',
|
|
236
|
+
match: /\b[a-zA-Z]\w*(?=\s*\()/g
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
type: 'num',
|
|
240
|
+
match: /\b[a-z-]+\b/g
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
this.languages.csv = {
|
|
245
|
+
default: [
|
|
246
|
+
{
|
|
247
|
+
expand: 'strDouble'
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
type: 'oper',
|
|
251
|
+
match: /,/g
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
this.languages.diff = {
|
|
256
|
+
default: [
|
|
257
|
+
{
|
|
258
|
+
type: 'deleted',
|
|
259
|
+
match: /^[-<].*/gm
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
type: 'insert',
|
|
263
|
+
match: /^[+>].*/gm
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
type: 'kwd',
|
|
267
|
+
match: /!.*/gm
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
type: 'section',
|
|
271
|
+
match: /^@@.*@@$|^\d.*|^([*-+])\1\1.*/gm
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
this.languages.docker = {
|
|
276
|
+
default: [
|
|
277
|
+
{
|
|
278
|
+
type: 'kwd',
|
|
279
|
+
match: /^(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)\b/gmi
|
|
280
|
+
},
|
|
281
|
+
...this.languages.bash.default
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
this.languages.git = {
|
|
285
|
+
default: [
|
|
286
|
+
{
|
|
287
|
+
match: /^#.*/gm,
|
|
288
|
+
sub: 'todo'
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
expand: 'str'
|
|
292
|
+
},
|
|
293
|
+
...this.languages.diff.default,
|
|
294
|
+
{
|
|
295
|
+
type: 'func',
|
|
296
|
+
match: /^(\$ )?git(\s.*)?$/gm
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
type: 'kwd',
|
|
300
|
+
match: /^commit \w+$/gm
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
this.languages.go = {
|
|
305
|
+
default: [
|
|
306
|
+
{
|
|
307
|
+
match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
|
|
308
|
+
sub: 'todo'
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
expand: 'str'
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
expand: 'num'
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
type: 'kwd',
|
|
318
|
+
match: /\*|&|\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go|goto|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/g
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
type: 'func',
|
|
322
|
+
match: /[a-zA-Z_][\w_]*(?=\s*\()/g
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
type: 'class',
|
|
326
|
+
match: /\b[A-Z][\w_]*\b/g
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
type: 'oper',
|
|
330
|
+
match: /[+\-*\/%&|^~=!<>.^-]+/g
|
|
331
|
+
}
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
let name = `[:A-Z_a-z@#\u{C0}-\u{D6}\u{D8}-\u{F6}\u{F8}-\u{2FF}\u{370}-\u{37D}\u{37F}-\u{1FFF}\u{200C}-\u{200D}\u{2070}-\u{218F}\u{2C00}-\u{2FEF}\u{3001}-\u{D7FF}\u{F900}-\u{FDCF}\u{FDF0}-\u{FFFD}][:A-Z_a-z@#\u{C0}-\u{D6}\u{D8}-\u{F6}\u{F8}-\u{2FF}\u{370}-\u{37D}\u{37F}-\u{1FFF}\u{200C}-\u{200D}\u{2070}-\u{218F}\u{2C00}-\u{2FEF}\u{3001}-\u{D7FF}\u{F900}-\u{FDCF}\u{FDF0}-\u{FFFD}\\-\\.0-9\u{B7}\u{0300}-\u{036F}\u{203F}-\u{2040}]*`,
|
|
335
|
+
properties = `\\s*(\\s+${name}\\s*(=\\s*([^"']\\S*|("|')(\\\\[^]|(?!\\4)[^])*\\4?)?)?\\s*)*`,
|
|
336
|
+
xmlElement = {
|
|
337
|
+
match: RegExp(`<[\/!?]?${name}${properties}[\/!?]?>`, 'g'),
|
|
338
|
+
sub: [
|
|
339
|
+
{
|
|
340
|
+
type: 'var',
|
|
341
|
+
match: RegExp(`^<[\/!?]?${name}`, 'g'),
|
|
342
|
+
sub: [
|
|
343
|
+
{
|
|
344
|
+
type: 'oper',
|
|
345
|
+
match: /^<[\/!?]?/g
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
type: 'str',
|
|
351
|
+
match: /=\s*([^"']\S*|("|')(\\[^]|(?!\2)[^])*\2?)/g,
|
|
352
|
+
sub: [
|
|
353
|
+
{
|
|
354
|
+
type: 'oper',
|
|
355
|
+
match: /^=/g
|
|
356
|
+
}
|
|
357
|
+
]
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
type: 'oper',
|
|
361
|
+
match: /[\/!?]?>/g
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
type: 'class',
|
|
365
|
+
match: RegExp(name, 'g')
|
|
366
|
+
}
|
|
367
|
+
]
|
|
368
|
+
};
|
|
369
|
+
this.languages.xml = {
|
|
370
|
+
default: [
|
|
371
|
+
{
|
|
372
|
+
match: /<!--((?!-->)[^])*-->/g,
|
|
373
|
+
sub: 'todo'
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
type: 'class',
|
|
377
|
+
match: /<!\[CDATA\[[\s\S]*?\]\]>/gi
|
|
378
|
+
},
|
|
379
|
+
xmlElement,
|
|
380
|
+
{
|
|
381
|
+
type: 'str',
|
|
382
|
+
match: RegExp(`<\\?${name}([^?]|\\?[^?>])*\\?+>`, 'g'),
|
|
383
|
+
sub: [
|
|
384
|
+
{
|
|
385
|
+
type: 'var',
|
|
386
|
+
match: RegExp(`^<\\?${name}`, 'g'),
|
|
387
|
+
sub: [
|
|
388
|
+
{
|
|
389
|
+
type: 'oper',
|
|
390
|
+
match: /^<\?/g
|
|
391
|
+
}
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
type: 'oper',
|
|
396
|
+
match: /\?+>$/g
|
|
397
|
+
}
|
|
398
|
+
]
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
type: 'var',
|
|
402
|
+
match: /&(#x?)?[\da-z]{1,8};/gi
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
this.languages.html = {
|
|
407
|
+
default: [
|
|
408
|
+
{
|
|
409
|
+
type: 'class',
|
|
410
|
+
match: /<!DOCTYPE("[^"]*"|'[^']*'|[^"'>])*>/gi,
|
|
411
|
+
sub: [
|
|
412
|
+
{
|
|
413
|
+
type: 'str',
|
|
414
|
+
match: /"[^"]*"|'[^']*'/g
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
type: 'oper',
|
|
418
|
+
match: /^<!|>$/g
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
type: 'var',
|
|
422
|
+
match: /DOCTYPE/gi
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
match: RegExp(`<style${properties}>((?!</style>)[^])*</style\\s*>`, 'g'),
|
|
428
|
+
sub: [
|
|
429
|
+
{
|
|
430
|
+
match: RegExp(`^<style${properties}>`, 'g'),
|
|
431
|
+
sub: xmlElement.sub
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
match: RegExp(`${xmlElement.match}|[^]*(?=</style\\s*>$)`, 'g'),
|
|
435
|
+
sub: 'css'
|
|
436
|
+
},
|
|
437
|
+
xmlElement
|
|
438
|
+
]
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
match: RegExp(`<script${properties}>((?!</script>)[^])*</script\\s*>`, 'g'),
|
|
442
|
+
sub: [
|
|
443
|
+
{
|
|
444
|
+
match: RegExp(`^<script${properties}>`, 'g'),
|
|
445
|
+
sub: xmlElement.sub
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
match: RegExp(`${xmlElement.match}|[^]*(?=</script\\s*>$)`, 'g'),
|
|
449
|
+
sub: 'js'
|
|
450
|
+
},
|
|
451
|
+
xmlElement
|
|
452
|
+
]
|
|
453
|
+
},
|
|
454
|
+
...this.languages.xml.default
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
this.languages.ini = {
|
|
458
|
+
default: [
|
|
459
|
+
{
|
|
460
|
+
match: /(^[ \f\t\v]*)[#;].*/gm,
|
|
461
|
+
sub: 'todo'
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
type: 'str',
|
|
465
|
+
match: /.*/g
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
type: 'var',
|
|
469
|
+
match: /.*(?==)/g
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
type: 'section',
|
|
473
|
+
match: /^\s*\[.+\]\s*$/gm
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
type: 'oper',
|
|
477
|
+
match: /=/g
|
|
478
|
+
}
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
this.languages.todo = {
|
|
482
|
+
type: 'cmnt', default: [
|
|
483
|
+
{
|
|
484
|
+
type: 'err',
|
|
485
|
+
match: /\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
type: 'class',
|
|
489
|
+
match: /\bIDEA\b/g
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
type: 'insert',
|
|
493
|
+
match: /\b(CHANGED|FIX|CHANGE)\b/g
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
type: 'oper',
|
|
497
|
+
match: /\bQUESTION\b/g
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
this.languages.java = {
|
|
502
|
+
default: [
|
|
503
|
+
{
|
|
504
|
+
match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
|
|
505
|
+
sub: 'todo'
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
expand: 'str'
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
expand: 'num'
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
type: 'kwd',
|
|
515
|
+
match: /\b(abstract|assert|boolean|break|byte|case|catch|char|class|continue|const|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|package|private|protected|public|requires|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|transient|try|var|void|volatile|while)\b/g
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
type: 'oper',
|
|
519
|
+
match: /[/*+:?&|%^~=!,<>.^-]+/g
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
type: 'func',
|
|
523
|
+
match: /[a-zA-Z_][\w_]*(?=\s*\()/g
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
type: 'class',
|
|
527
|
+
match: /\b[A-Z][\w_]*\b/g
|
|
528
|
+
}
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
this.languages.js_template_literals = {
|
|
532
|
+
type: 'str', default: [
|
|
533
|
+
{
|
|
534
|
+
match: new class {
|
|
535
|
+
exec(str) {
|
|
536
|
+
let i = this.lastIndex,
|
|
537
|
+
j,
|
|
538
|
+
f = _ => {
|
|
539
|
+
while (++i < str.length - 2)
|
|
540
|
+
if (str[i] == '{') f()
|
|
541
|
+
else if (str[i] == '}') return
|
|
542
|
+
}
|
|
543
|
+
for (; i < str.length; ++i)
|
|
544
|
+
if (str[i - 1] != '\\' && str[i] == '$' && str[i + 1] == '{') {
|
|
545
|
+
j = i++
|
|
546
|
+
f(i)
|
|
547
|
+
this.lastIndex = i + 1
|
|
548
|
+
return {index: j, 0: str.slice(j, i + 1)}
|
|
549
|
+
}
|
|
550
|
+
return null
|
|
551
|
+
}
|
|
552
|
+
}(),
|
|
553
|
+
sub: [
|
|
554
|
+
{
|
|
555
|
+
type: 'kwd',
|
|
556
|
+
match: /^\${|}$/g
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
match: /(?!^\$|{)[^]+(?=}$)/g,
|
|
560
|
+
sub: 'js'
|
|
561
|
+
}
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
]
|
|
565
|
+
}
|
|
566
|
+
this.languages.js = {
|
|
567
|
+
default: [
|
|
568
|
+
{
|
|
569
|
+
match: /\/\*\*((?!\*\/)[^])*(\*\/)?/g,
|
|
570
|
+
sub: 'jsdoc'
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
|
|
574
|
+
sub: 'todo'
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
expand: 'str'
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
match: /`((?!`)[^]|\\[^])*`?/g,
|
|
581
|
+
sub: 'js_template_literals'
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
type: 'kwd',
|
|
585
|
+
match: /=>|\b(this|set|get|as|async|await|break|case|catch|class|const|constructor|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|if|implements|import|in|instanceof|interface|let|var|of|new|package|private|protected|public|return|static|super|switch|throw|throws|try|typeof|void|while|with|yield)\b/g
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
match: /\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,
|
|
589
|
+
sub: 'regex'
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
expand: 'num'
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
type: 'num',
|
|
596
|
+
match: /\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
type: 'bool',
|
|
600
|
+
match: /\b(true|false)\b/g
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
type: 'oper',
|
|
604
|
+
match: /[/*+:?&|%^~=!,<>.^-]+/g
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
type: 'class',
|
|
608
|
+
match: /\b[A-Z][\w_]*\b/g
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
type: 'func',
|
|
612
|
+
match: /[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g
|
|
613
|
+
}
|
|
614
|
+
]
|
|
615
|
+
}
|
|
616
|
+
this.languages.jsdoc = {
|
|
617
|
+
type: 'cmnt', default: [
|
|
618
|
+
{
|
|
619
|
+
type: 'kwd',
|
|
620
|
+
match: /@\w+/g
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
type: 'class',
|
|
624
|
+
match: /{[\w\s|<>,.@\[\]]+}/g
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
type: 'var',
|
|
628
|
+
match: /\[[\w\s="']+\]/g
|
|
629
|
+
},
|
|
630
|
+
...this.languages.todo.default
|
|
631
|
+
]
|
|
632
|
+
}
|
|
633
|
+
this.languages.json = {
|
|
634
|
+
default: [
|
|
635
|
+
{
|
|
636
|
+
type: 'var',
|
|
637
|
+
match: /("|')?[a-zA-Z]\w*\1(?=\s*:)/g
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
expand: 'str'
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
expand: 'num'
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
type: 'num',
|
|
647
|
+
match: /\bnull\b/g
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
type: 'bool',
|
|
651
|
+
match: /\b(true|false)\b/g
|
|
652
|
+
}
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
this.languages.log = {
|
|
656
|
+
default: [
|
|
657
|
+
{
|
|
658
|
+
type: 'cmnt',
|
|
659
|
+
match: /^#.*/gm
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
expand: 'strDouble'
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
expand: 'num'
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
type: 'err',
|
|
669
|
+
match: /\b(err(or)?|[a-z_-]*exception|warn|warning|failed|ko|invalid|not ?found|alert|fatal)\b/gi
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
type: 'num',
|
|
673
|
+
match: /\b(null|undefined)\b/gi
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
type: 'bool',
|
|
677
|
+
match: /\b(false|true|yes|no)\b/gi
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
type: 'oper',
|
|
681
|
+
match: /\.|,/g
|
|
682
|
+
}
|
|
683
|
+
]
|
|
684
|
+
}
|
|
685
|
+
this.languages.lua = {
|
|
686
|
+
default: [
|
|
687
|
+
{
|
|
688
|
+
match: /^#!.*|--(\[(=*)\[((?!--\]\2\])[^])*--\]\2\]|.*)/g,
|
|
689
|
+
sub: 'todo'
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
expand: 'str'
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
type: 'kwd',
|
|
696
|
+
match: /\b(and|break|do|else|elseif|end|for|function|if|in|local|not|or|repeat|return|then|until|while)\b/g
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
type: 'bool',
|
|
700
|
+
match: /\b(true|false|nil)\b/g
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
type: 'oper',
|
|
704
|
+
match: /[+*/%^#=~<>:,.-]+/g
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
expand: 'num'
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
type: 'func',
|
|
711
|
+
match: /[a-z_]+(?=\s*[({])/g
|
|
712
|
+
}
|
|
713
|
+
]
|
|
714
|
+
}
|
|
715
|
+
this.languages.make = {
|
|
716
|
+
default: [
|
|
717
|
+
{
|
|
718
|
+
match: /^\s*#.*/gm,
|
|
719
|
+
sub: 'todo'
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
expand: 'str'
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
type: 'oper',
|
|
726
|
+
match: /[${}()]+/g
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
type: 'class',
|
|
730
|
+
match: /.PHONY:/gm
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
type: 'section',
|
|
734
|
+
match: /^[\w.]+:/gm
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
type: 'kwd',
|
|
738
|
+
match: /\b(ifneq|endif)\b/g
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
expand: 'num'
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
type: 'var',
|
|
745
|
+
match: /[A-Z_]+(?=\s*=)/g
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
match: /^.*$/gm,
|
|
749
|
+
sub: 'bash'
|
|
750
|
+
}
|
|
751
|
+
]
|
|
752
|
+
}
|
|
753
|
+
this.languages.pl = {
|
|
754
|
+
default: [
|
|
755
|
+
{
|
|
756
|
+
match: /#.*/g,
|
|
757
|
+
sub: 'todo'
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
type: 'str',
|
|
761
|
+
match: /(["'])(\\[^]|(?!\1)[^])*\1?/g
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
expand: 'num'
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
type: 'kwd',
|
|
768
|
+
match: /\b(any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|return|say|state|sub|switch|undef|unless|until|use|when|while|not|and|or|xor)\b/g
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
type: 'oper',
|
|
772
|
+
match: /[-+*/%~!&<>|=?,]+/g
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
type: 'func',
|
|
776
|
+
match: /[a-z_]+(?=\s*\()/g
|
|
777
|
+
}
|
|
778
|
+
]
|
|
779
|
+
}
|
|
780
|
+
this.languages.plain = {
|
|
781
|
+
default: [
|
|
782
|
+
{
|
|
783
|
+
expand: 'strDouble'
|
|
784
|
+
}
|
|
785
|
+
]
|
|
786
|
+
}
|
|
787
|
+
this.languages.py = {
|
|
788
|
+
default: [
|
|
789
|
+
{
|
|
790
|
+
match: /#.*/g,
|
|
791
|
+
sub: 'todo'
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
match: /("""|''')(\\[^]|(?!\1)[^])*\1?/g,
|
|
795
|
+
sub: 'todo'
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
type: 'str',
|
|
799
|
+
match: /f("|')(\\[^]|(?!\1).)*\1?|f((["'])\4\4)(\\[^]|(?!\3)[^])*\3?/gi,
|
|
800
|
+
sub: [
|
|
801
|
+
{
|
|
802
|
+
type: 'var',
|
|
803
|
+
match: /{[^{}]*}/g,
|
|
804
|
+
sub: [
|
|
805
|
+
{
|
|
806
|
+
match: /(?!^{)[^]*(?=}$)/g,
|
|
807
|
+
sub: 'py'
|
|
808
|
+
}
|
|
809
|
+
]
|
|
810
|
+
}
|
|
811
|
+
]
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
expand: 'str'
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
type: 'kwd',
|
|
818
|
+
match: /\b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/g
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
type: 'bool',
|
|
822
|
+
match: /\b(False|True|None)\b/g
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
expand: 'num'
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
type: 'func',
|
|
829
|
+
match: /[a-z_]+(?=\s*\()/g
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
type: 'oper',
|
|
833
|
+
match: /[-/*+<>,=!&|^%]+/g
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
type: 'class',
|
|
837
|
+
match: /\b[A-Z][\w_]*\b/g
|
|
838
|
+
}
|
|
839
|
+
]
|
|
840
|
+
}
|
|
841
|
+
this.languages.regex = {
|
|
842
|
+
type: 'oper', default: [
|
|
843
|
+
{
|
|
844
|
+
match: /^(?!\/).*/gm,
|
|
845
|
+
sub: 'todo'
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
type: 'num',
|
|
849
|
+
match: /\[((?!\])[^\\]|\\.)*\]/g
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
type: 'kwd',
|
|
853
|
+
match: /\||\^|\$|\\.|\w+($|\r|\n)/g
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
type: 'var',
|
|
857
|
+
match: /\*|\+|\{\d+,\d+\}/g
|
|
858
|
+
}
|
|
859
|
+
]
|
|
860
|
+
}
|
|
861
|
+
this.languages.rs = {
|
|
862
|
+
default: [
|
|
863
|
+
{
|
|
864
|
+
match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
|
|
865
|
+
sub: 'todo'
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
expand: 'str'
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
expand: 'num'
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
type: 'kwd',
|
|
875
|
+
match: /\b(as|break|const|continue|crate|else|enum|extern|false|fn|for|if|impl|in|let|loop|match|mod|move|mut|pub|ref|return|self|Self|static|struct|super|trait|true|type|unsafe|use|where|while|async|await|dyn|abstract|become|box|do|final|macro|override|priv|typeof|unsized|virtual|yield|try)\b/g
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
type: 'oper',
|
|
879
|
+
match: /[/*+:?&|%^~=!,<>.^-]+/g
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
type: 'class',
|
|
883
|
+
match: /\b[A-Z][\w_]*\b/g
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
type: 'func',
|
|
887
|
+
match: /[a-zA-Z_][\w_]*(?=\s*!?\s*\()/g
|
|
888
|
+
}
|
|
889
|
+
]
|
|
890
|
+
}
|
|
891
|
+
this.languages.sql = {
|
|
892
|
+
default: [
|
|
893
|
+
{
|
|
894
|
+
match: /--.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
|
|
895
|
+
sub: 'todo'
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
expand: 'str'
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
type: 'func',
|
|
902
|
+
match: /\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/g
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
type: 'kwd',
|
|
906
|
+
match: /\b(ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|kwdS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:S|ING)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/g
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
type: 'num',
|
|
910
|
+
match: /\.?\d[\d.oxa-fA-F-]*|\bNULL\b/g
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
type: 'bool',
|
|
914
|
+
match: /\b(TRUE|FALSE)\b/g
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
type: 'oper',
|
|
918
|
+
match: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|IN|ILIKE|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/g
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
type: 'var',
|
|
922
|
+
match: /@\S+/g
|
|
923
|
+
}
|
|
924
|
+
]
|
|
925
|
+
}
|
|
926
|
+
this.languages.toml = {
|
|
927
|
+
default: [
|
|
928
|
+
{
|
|
929
|
+
match: /#.*/g,
|
|
930
|
+
sub: 'todo'
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
type: 'str',
|
|
934
|
+
match: /("""|''')((?!\1)[^]|\\[^])*\1?/g
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
expand: 'str'
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
type: 'section',
|
|
941
|
+
match: /^\[.+\]\s*$/gm
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
type: 'num',
|
|
945
|
+
match: /\b(inf|nan)\b|\d[\d:ZT.-]*/g
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
expand: 'num'
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
type: 'bool',
|
|
952
|
+
match: /\b(true|false)\b/g
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
type: 'oper',
|
|
956
|
+
match: /[+,.=-]/g
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
type: 'var',
|
|
960
|
+
match: /\w+(?= \=)/g
|
|
961
|
+
}
|
|
962
|
+
]
|
|
963
|
+
}
|
|
964
|
+
this.languages.ts = {
|
|
965
|
+
default: [
|
|
966
|
+
{
|
|
967
|
+
type: 'type',
|
|
968
|
+
match: /:\s*(any|void|number|boolean|string|object|never|enum)\b/g
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
type: 'kwd',
|
|
972
|
+
match: /\b(type|namespace|typedef|interface|public|private|protected|implements|declare|abstract|readonly)\b/g
|
|
973
|
+
},
|
|
974
|
+
...this.languages.js.default
|
|
975
|
+
]
|
|
976
|
+
}
|
|
977
|
+
this.languages.uri = {
|
|
978
|
+
default: [
|
|
979
|
+
{
|
|
980
|
+
match: /^#.*/gm,
|
|
981
|
+
sub: 'todo'
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
type: 'class',
|
|
985
|
+
match: /^\w+(?=:?)/gm
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
type: 'num',
|
|
989
|
+
match: /:\d+/g
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
type: 'oper',
|
|
993
|
+
match: /[:/&?]|\w+=/g
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
type: 'func',
|
|
997
|
+
match: /[.\w]+@|#[\w]+$/gm
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
type: 'var',
|
|
1001
|
+
match: /\w+\.\w+(\.\w+)*/g
|
|
1002
|
+
}
|
|
1003
|
+
]
|
|
1004
|
+
}
|
|
1005
|
+
this.languages.yaml = {
|
|
1006
|
+
default: [
|
|
1007
|
+
{
|
|
1008
|
+
match: /#.*/g,
|
|
1009
|
+
sub: 'todo'
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
expand: 'str'
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
type: 'str',
|
|
1016
|
+
match: /(>|\|)\r?\n((\s[^\n]*)?(\r?\n|$))*/g
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
type: 'type',
|
|
1020
|
+
match: /!![a-z]+/g
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
type: 'bool',
|
|
1024
|
+
match: /\b(Yes|No)\b/g
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
type: 'oper',
|
|
1028
|
+
match: /[+:-]/g
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
expand: 'num'
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
type: 'var',
|
|
1035
|
+
match: /[a-zA-Z]\w*(?=:)/g
|
|
1036
|
+
}
|
|
1037
|
+
]
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
methods: {
|
|
1041
|
+
async highlight(code, lang, hideLineNumbers) {
|
|
1042
|
+
let tmp = ''
|
|
1043
|
+
await this.tokenize(code, lang, (str, type) => tmp += this.toSpan(this.sanitize(str), type))
|
|
1044
|
+
|
|
1045
|
+
return `<div><div class="highlight-numbers">${'<div></div>'.repeat(!hideLineNumbers && code.split('\n').length)}</div><div>${tmp}</div></div>`
|
|
1046
|
+
|
|
1047
|
+
},
|
|
1048
|
+
async tokenize(src, lang, token) {
|
|
1049
|
+
try {
|
|
1050
|
+
let m,
|
|
1051
|
+
part,
|
|
1052
|
+
first = {},
|
|
1053
|
+
match,
|
|
1054
|
+
cache = [],
|
|
1055
|
+
i = 0,
|
|
1056
|
+
data = typeof lang === 'string' ? this.languages[lang] : lang,
|
|
1057
|
+
arr = [...typeof lang === 'string' ? data.default : lang.sub]
|
|
1058
|
+
|
|
1059
|
+
while (i < src.length) {
|
|
1060
|
+
first.index = null
|
|
1061
|
+
for (m = arr.length; m-- > 0;) {
|
|
1062
|
+
part = arr[m].expand ? this.expandData[arr[m].expand] : arr[m]
|
|
1063
|
+
// do not call again exec if the previous result is sufficient
|
|
1064
|
+
if (cache[m] === undefined || cache[m].match.index < i) {
|
|
1065
|
+
part.match.lastIndex = i
|
|
1066
|
+
match = part.match.exec(src)
|
|
1067
|
+
if (match === null) {
|
|
1068
|
+
// no more match with this regex can be disposed
|
|
1069
|
+
arr.splice(m, 1)
|
|
1070
|
+
cache.splice(m, 1)
|
|
1071
|
+
continue
|
|
1072
|
+
}
|
|
1073
|
+
// save match for later use to decrease performance cost
|
|
1074
|
+
cache[m] = {match, lastIndex: part.match.lastIndex}
|
|
1075
|
+
}
|
|
1076
|
+
// check if it the first match in the string
|
|
1077
|
+
if (cache[m].match[0] && (cache[m].match.index <= first.index || first.index === null))
|
|
1078
|
+
first = {
|
|
1079
|
+
part: part,
|
|
1080
|
+
index: cache[m].match.index,
|
|
1081
|
+
match: cache[m].match[0],
|
|
1082
|
+
end: cache[m].lastIndex
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
if (first.index === null)
|
|
1086
|
+
break
|
|
1087
|
+
token(src.slice(i, first.index), data.type)
|
|
1088
|
+
i = first.end
|
|
1089
|
+
if (first.part.sub)
|
|
1090
|
+
await this.tokenize(first.match, typeof first.part.sub === 'string' ? first.part.sub : (typeof first.part.sub === 'function' ? first.part.sub(first.match) : first.part), token)
|
|
1091
|
+
else
|
|
1092
|
+
token(first.match, first.part.type)
|
|
1093
|
+
}
|
|
1094
|
+
token(src.slice(i, src.length), data.type)
|
|
1095
|
+
} catch {
|
|
1096
|
+
token(src)
|
|
1097
|
+
}
|
|
1098
|
+
},
|
|
1099
|
+
toSpan(str, token) {
|
|
1100
|
+
return token ? `<span class="highlight-syn-${token}">${str}</span>` : str
|
|
1101
|
+
},
|
|
1102
|
+
sanitize(str = '') {
|
|
1103
|
+
return str.replaceAll('&', '&').replaceAll?.('<', '<').replaceAll?.('>', '>')
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|