@hep-code-runner/vue2 2.1.10 → 2.2.1
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/dist/index.js +1 -236
- package/dist/index.mjs +1397 -971
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var w = Object.defineProperty;
|
|
2
|
+
var y = (o, e, t) => e in o ? w(o, e, { enumerable: true, configurable: true, writable: true, value: t }) : o[e] = t;
|
|
3
|
+
var c = (o, e, t) => y(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
let u = null;
|
|
5
|
+
class W {
|
|
4
6
|
constructor(e = {}) {
|
|
5
|
-
|
|
7
|
+
c(this, "baseUrl");
|
|
8
|
+
c(this, "timeout");
|
|
9
|
+
this.baseUrl = e.pistonUrl || "/api/piston", this.timeout = e.timeout || 3e3;
|
|
6
10
|
}
|
|
7
|
-
async getRuntimes(e =
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
11
|
+
async getRuntimes(e = false) {
|
|
12
|
+
if (u && !e)
|
|
13
|
+
return u;
|
|
10
14
|
try {
|
|
11
15
|
const t = await fetch(`${this.baseUrl}/runtimes`, {
|
|
12
16
|
method: "GET",
|
|
@@ -16,65 +20,65 @@ class se {
|
|
|
16
20
|
});
|
|
17
21
|
if (!t.ok)
|
|
18
22
|
throw new Error(`Failed to fetch runtimes: ${t.statusText}`);
|
|
19
|
-
const
|
|
20
|
-
return
|
|
23
|
+
const n = await t.json();
|
|
24
|
+
return u = n, n;
|
|
21
25
|
} catch (t) {
|
|
22
26
|
throw console.error("Failed to fetch runtimes:", t), t;
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
|
-
async execute(e, t,
|
|
26
|
-
const
|
|
27
|
-
(
|
|
28
|
-
var
|
|
29
|
-
return
|
|
29
|
+
async execute(e, t, n = {}) {
|
|
30
|
+
const l = (await this.getRuntimes()).find(
|
|
31
|
+
(a) => {
|
|
32
|
+
var r;
|
|
33
|
+
return a.language.toLowerCase() === e.toLowerCase() || ((r = a.aliases) == null ? void 0 : r.some((i) => i.toLowerCase() === e.toLowerCase()));
|
|
30
34
|
}
|
|
31
35
|
);
|
|
32
|
-
if (!
|
|
36
|
+
if (!l)
|
|
33
37
|
throw new Error(`Language '${e}' is not supported`);
|
|
34
|
-
const
|
|
35
|
-
language:
|
|
36
|
-
version:
|
|
38
|
+
const p = this.getFileName(e), h = {
|
|
39
|
+
language: l.language,
|
|
40
|
+
version: n.version || l.version,
|
|
37
41
|
files: [
|
|
38
42
|
{
|
|
39
|
-
name:
|
|
43
|
+
name: p,
|
|
40
44
|
content: t
|
|
41
45
|
}
|
|
42
46
|
],
|
|
43
|
-
stdin:
|
|
44
|
-
args:
|
|
45
|
-
run_timeout:
|
|
47
|
+
stdin: n.stdin || "",
|
|
48
|
+
args: n.args || [],
|
|
49
|
+
run_timeout: n.runTimeout || this.timeout,
|
|
46
50
|
compile_timeout: this.timeout
|
|
47
|
-
},
|
|
51
|
+
}, d = Date.now();
|
|
48
52
|
try {
|
|
49
|
-
const
|
|
53
|
+
const a = await fetch(`${this.baseUrl}/execute`, {
|
|
50
54
|
method: "POST",
|
|
51
55
|
headers: {
|
|
52
56
|
"Content-Type": "application/json"
|
|
53
57
|
},
|
|
54
|
-
body: JSON.stringify(
|
|
58
|
+
body: JSON.stringify(h)
|
|
55
59
|
});
|
|
56
|
-
if (!
|
|
57
|
-
throw new Error(`Execute failed: ${
|
|
58
|
-
const
|
|
60
|
+
if (!a.ok)
|
|
61
|
+
throw new Error(`Execute failed: ${a.statusText}`);
|
|
62
|
+
const r = await a.json(), i = Date.now() - d, g = r.run.stdout || "", f = r.run.stderr || "";
|
|
59
63
|
return {
|
|
60
|
-
success:
|
|
61
|
-
output:
|
|
62
|
-
stderr:
|
|
63
|
-
code:
|
|
64
|
-
executionTime:
|
|
65
|
-
compile:
|
|
66
|
-
stdout:
|
|
67
|
-
stderr:
|
|
68
|
-
code:
|
|
64
|
+
success: r.run.code === 0,
|
|
65
|
+
output: g,
|
|
66
|
+
stderr: f,
|
|
67
|
+
code: r.run.code,
|
|
68
|
+
executionTime: i,
|
|
69
|
+
compile: r.compile ? {
|
|
70
|
+
stdout: r.compile.stdout || "",
|
|
71
|
+
stderr: r.compile.stderr || "",
|
|
72
|
+
code: r.compile.code
|
|
69
73
|
} : void 0
|
|
70
74
|
};
|
|
71
|
-
} catch (
|
|
75
|
+
} catch (a) {
|
|
72
76
|
return {
|
|
73
|
-
success:
|
|
77
|
+
success: false,
|
|
74
78
|
output: "",
|
|
75
|
-
stderr:
|
|
79
|
+
stderr: a instanceof Error ? a.message : "Unknown error",
|
|
76
80
|
code: -1,
|
|
77
|
-
executionTime: Date.now() -
|
|
81
|
+
executionTime: Date.now() - d
|
|
78
82
|
};
|
|
79
83
|
}
|
|
80
84
|
}
|
|
@@ -108,7 +112,7 @@ class se {
|
|
|
108
112
|
}[e.toLowerCase()] || `main.${e}`;
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
|
-
const
|
|
115
|
+
const m = {
|
|
112
116
|
javascript: 'console.log("Hello, World!");',
|
|
113
117
|
typescript: 'console.log("Hello, World!");',
|
|
114
118
|
python: 'print("Hello, World!")',
|
|
@@ -206,18 +210,18 @@ h1 {
|
|
|
206
210
|
|
|
207
211
|
This is a sample markdown document.`
|
|
208
212
|
};
|
|
209
|
-
function
|
|
210
|
-
const e =
|
|
211
|
-
return
|
|
213
|
+
function j(o) {
|
|
214
|
+
const e = o.toLowerCase();
|
|
215
|
+
return m[e] || `// ${o}
|
|
212
216
|
// Write your code here`;
|
|
213
217
|
}
|
|
214
|
-
var
|
|
215
|
-
function
|
|
216
|
-
return
|
|
218
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
219
|
+
function getDefaultExportFromCjs(x) {
|
|
220
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
217
221
|
}
|
|
218
|
-
var
|
|
219
|
-
(function(
|
|
220
|
-
var
|
|
222
|
+
var prism = { exports: {} };
|
|
223
|
+
(function(module) {
|
|
224
|
+
var _self = typeof window !== "undefined" ? window : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
|
|
221
225
|
/**
|
|
222
226
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
223
227
|
*
|
|
@@ -226,8 +230,11 @@ var Q = { exports: {} };
|
|
|
226
230
|
* @namespace
|
|
227
231
|
* @public
|
|
228
232
|
*/
|
|
229
|
-
var
|
|
230
|
-
var
|
|
233
|
+
var Prism2 = function(_self2) {
|
|
234
|
+
var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
|
|
235
|
+
var uniqueId = 0;
|
|
236
|
+
var plainTextGrammar = {};
|
|
237
|
+
var _ = {
|
|
231
238
|
/**
|
|
232
239
|
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
233
240
|
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
@@ -249,7 +256,7 @@ var Q = { exports: {} };
|
|
|
249
256
|
* @memberof Prism
|
|
250
257
|
* @public
|
|
251
258
|
*/
|
|
252
|
-
manual:
|
|
259
|
+
manual: _self2.Prism && _self2.Prism.manual,
|
|
253
260
|
/**
|
|
254
261
|
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
255
262
|
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
@@ -271,7 +278,7 @@ var Q = { exports: {} };
|
|
|
271
278
|
* @memberof Prism
|
|
272
279
|
* @public
|
|
273
280
|
*/
|
|
274
|
-
disableWorkerMessageHandler:
|
|
281
|
+
disableWorkerMessageHandler: _self2.Prism && _self2.Prism.disableWorkerMessageHandler,
|
|
275
282
|
/**
|
|
276
283
|
* A namespace for utility methods.
|
|
277
284
|
*
|
|
@@ -282,8 +289,14 @@ var Q = { exports: {} };
|
|
|
282
289
|
* @memberof Prism
|
|
283
290
|
*/
|
|
284
291
|
util: {
|
|
285
|
-
encode: function
|
|
286
|
-
|
|
292
|
+
encode: function encode(tokens) {
|
|
293
|
+
if (tokens instanceof Token) {
|
|
294
|
+
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
295
|
+
} else if (Array.isArray(tokens)) {
|
|
296
|
+
return tokens.map(encode);
|
|
297
|
+
} else {
|
|
298
|
+
return tokens.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
299
|
+
}
|
|
287
300
|
},
|
|
288
301
|
/**
|
|
289
302
|
* Returns the name of the type of the given value.
|
|
@@ -301,8 +314,8 @@ var Q = { exports: {} };
|
|
|
301
314
|
* type(String) === 'Function'
|
|
302
315
|
* type(/abc+/) === 'RegExp'
|
|
303
316
|
*/
|
|
304
|
-
type: function(
|
|
305
|
-
return Object.prototype.toString.call(
|
|
317
|
+
type: function(o) {
|
|
318
|
+
return Object.prototype.toString.call(o).slice(8, -1);
|
|
306
319
|
},
|
|
307
320
|
/**
|
|
308
321
|
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
@@ -310,8 +323,11 @@ var Q = { exports: {} };
|
|
|
310
323
|
* @param {Object} obj
|
|
311
324
|
* @returns {number}
|
|
312
325
|
*/
|
|
313
|
-
objId: function(
|
|
314
|
-
|
|
326
|
+
objId: function(obj) {
|
|
327
|
+
if (!obj["__id"]) {
|
|
328
|
+
Object.defineProperty(obj, "__id", { value: ++uniqueId });
|
|
329
|
+
}
|
|
330
|
+
return obj["__id"];
|
|
315
331
|
},
|
|
316
332
|
/**
|
|
317
333
|
* Creates a deep clone of the given object.
|
|
@@ -323,30 +339,46 @@ var Q = { exports: {} };
|
|
|
323
339
|
* @returns {T}
|
|
324
340
|
* @template T
|
|
325
341
|
*/
|
|
326
|
-
clone: function
|
|
327
|
-
|
|
328
|
-
var
|
|
329
|
-
|
|
342
|
+
clone: function deepClone(o, visited) {
|
|
343
|
+
visited = visited || {};
|
|
344
|
+
var clone;
|
|
345
|
+
var id;
|
|
346
|
+
switch (_.util.type(o)) {
|
|
330
347
|
case "Object":
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
348
|
+
id = _.util.objId(o);
|
|
349
|
+
if (visited[id]) {
|
|
350
|
+
return visited[id];
|
|
351
|
+
}
|
|
352
|
+
clone = /** @type {Record<string, any>} */
|
|
353
|
+
{};
|
|
354
|
+
visited[id] = clone;
|
|
355
|
+
for (var key in o) {
|
|
356
|
+
if (o.hasOwnProperty(key)) {
|
|
357
|
+
clone[key] = deepClone(o[key], visited);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
337
360
|
return (
|
|
338
361
|
/** @type {any} */
|
|
339
|
-
|
|
362
|
+
clone
|
|
340
363
|
);
|
|
341
364
|
case "Array":
|
|
342
|
-
|
|
365
|
+
id = _.util.objId(o);
|
|
366
|
+
if (visited[id]) {
|
|
367
|
+
return visited[id];
|
|
368
|
+
}
|
|
369
|
+
clone = [];
|
|
370
|
+
visited[id] = clone;
|
|
371
|
+
/** @type {Array} */
|
|
343
372
|
/** @type {any} */
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
})
|
|
347
|
-
|
|
373
|
+
o.forEach(function(v, i) {
|
|
374
|
+
clone[i] = deepClone(v, visited);
|
|
375
|
+
});
|
|
376
|
+
return (
|
|
377
|
+
/** @type {any} */
|
|
378
|
+
clone
|
|
379
|
+
);
|
|
348
380
|
default:
|
|
349
|
-
return
|
|
381
|
+
return o;
|
|
350
382
|
}
|
|
351
383
|
},
|
|
352
384
|
/**
|
|
@@ -357,12 +389,13 @@ var Q = { exports: {} };
|
|
|
357
389
|
* @param {Element} element
|
|
358
390
|
* @returns {string}
|
|
359
391
|
*/
|
|
360
|
-
getLanguage: function(
|
|
361
|
-
|
|
362
|
-
var
|
|
363
|
-
if (
|
|
364
|
-
return
|
|
365
|
-
|
|
392
|
+
getLanguage: function(element) {
|
|
393
|
+
while (element) {
|
|
394
|
+
var m2 = lang.exec(element.className);
|
|
395
|
+
if (m2) {
|
|
396
|
+
return m2[1].toLowerCase();
|
|
397
|
+
}
|
|
398
|
+
element = element.parentElement;
|
|
366
399
|
}
|
|
367
400
|
return "none";
|
|
368
401
|
},
|
|
@@ -373,8 +406,9 @@ var Q = { exports: {} };
|
|
|
373
406
|
* @param {string} language
|
|
374
407
|
* @returns {void}
|
|
375
408
|
*/
|
|
376
|
-
setLanguage: function(
|
|
377
|
-
|
|
409
|
+
setLanguage: function(element, language) {
|
|
410
|
+
element.className = element.className.replace(RegExp(lang, "gi"), "");
|
|
411
|
+
element.classList.add("language-" + language);
|
|
378
412
|
},
|
|
379
413
|
/**
|
|
380
414
|
* Returns the script element that is currently executing.
|
|
@@ -384,22 +418,26 @@ var Q = { exports: {} };
|
|
|
384
418
|
* @returns {HTMLScriptElement | null}
|
|
385
419
|
*/
|
|
386
420
|
currentScript: function() {
|
|
387
|
-
if (typeof document
|
|
421
|
+
if (typeof document === "undefined") {
|
|
388
422
|
return null;
|
|
389
|
-
|
|
423
|
+
}
|
|
424
|
+
if (document.currentScript && document.currentScript.tagName === "SCRIPT" && 1 < 2) {
|
|
390
425
|
return (
|
|
391
426
|
/** @type {any} */
|
|
392
427
|
document.currentScript
|
|
393
428
|
);
|
|
429
|
+
}
|
|
394
430
|
try {
|
|
395
431
|
throw new Error();
|
|
396
|
-
} catch (
|
|
397
|
-
var
|
|
398
|
-
if (
|
|
399
|
-
var
|
|
400
|
-
for (var i in
|
|
401
|
-
if (
|
|
402
|
-
return
|
|
432
|
+
} catch (err) {
|
|
433
|
+
var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
|
|
434
|
+
if (src) {
|
|
435
|
+
var scripts = document.getElementsByTagName("script");
|
|
436
|
+
for (var i in scripts) {
|
|
437
|
+
if (scripts[i].src == src) {
|
|
438
|
+
return scripts[i];
|
|
439
|
+
}
|
|
440
|
+
}
|
|
403
441
|
}
|
|
404
442
|
return null;
|
|
405
443
|
}
|
|
@@ -423,16 +461,19 @@ var Q = { exports: {} };
|
|
|
423
461
|
* @param {boolean} [defaultActivation=false]
|
|
424
462
|
* @returns {boolean}
|
|
425
463
|
*/
|
|
426
|
-
isActive: function(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
464
|
+
isActive: function(element, className, defaultActivation) {
|
|
465
|
+
var no = "no-" + className;
|
|
466
|
+
while (element) {
|
|
467
|
+
var classList = element.classList;
|
|
468
|
+
if (classList.contains(className)) {
|
|
469
|
+
return true;
|
|
470
|
+
}
|
|
471
|
+
if (classList.contains(no)) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
element = element.parentElement;
|
|
434
475
|
}
|
|
435
|
-
return !!
|
|
476
|
+
return !!defaultActivation;
|
|
436
477
|
}
|
|
437
478
|
},
|
|
438
479
|
/**
|
|
@@ -446,10 +487,10 @@ var Q = { exports: {} };
|
|
|
446
487
|
/**
|
|
447
488
|
* The grammar for plain, unformatted text.
|
|
448
489
|
*/
|
|
449
|
-
plain:
|
|
450
|
-
plaintext:
|
|
451
|
-
text:
|
|
452
|
-
txt:
|
|
490
|
+
plain: plainTextGrammar,
|
|
491
|
+
plaintext: plainTextGrammar,
|
|
492
|
+
text: plainTextGrammar,
|
|
493
|
+
txt: plainTextGrammar,
|
|
453
494
|
/**
|
|
454
495
|
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
455
496
|
*
|
|
@@ -478,11 +519,12 @@ var Q = { exports: {} };
|
|
|
478
519
|
* 'color': /\b(?:red|green|blue)\b/
|
|
479
520
|
* });
|
|
480
521
|
*/
|
|
481
|
-
extend: function(
|
|
482
|
-
var
|
|
483
|
-
for (var
|
|
484
|
-
|
|
485
|
-
|
|
522
|
+
extend: function(id, redef) {
|
|
523
|
+
var lang2 = _.util.clone(_.languages[id]);
|
|
524
|
+
for (var key in redef) {
|
|
525
|
+
lang2[key] = redef[key];
|
|
526
|
+
}
|
|
527
|
+
return lang2;
|
|
486
528
|
},
|
|
487
529
|
/**
|
|
488
530
|
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
@@ -559,32 +601,52 @@ var Q = { exports: {} };
|
|
|
559
601
|
* @returns {Grammar} The new grammar object.
|
|
560
602
|
* @public
|
|
561
603
|
*/
|
|
562
|
-
insertBefore: function(
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
var
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
604
|
+
insertBefore: function(inside, before, insert, root) {
|
|
605
|
+
root = root || /** @type {any} */
|
|
606
|
+
_.languages;
|
|
607
|
+
var grammar = root[inside];
|
|
608
|
+
var ret = {};
|
|
609
|
+
for (var token in grammar) {
|
|
610
|
+
if (grammar.hasOwnProperty(token)) {
|
|
611
|
+
if (token == before) {
|
|
612
|
+
for (var newToken in insert) {
|
|
613
|
+
if (insert.hasOwnProperty(newToken)) {
|
|
614
|
+
ret[newToken] = insert[newToken];
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if (!insert.hasOwnProperty(token)) {
|
|
619
|
+
ret[token] = grammar[token];
|
|
620
|
+
}
|
|
572
621
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
622
|
+
}
|
|
623
|
+
var old = root[inside];
|
|
624
|
+
root[inside] = ret;
|
|
625
|
+
_.languages.DFS(_.languages, function(key, value) {
|
|
626
|
+
if (value === old && key != inside) {
|
|
627
|
+
this[key] = ret;
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
return ret;
|
|
577
631
|
},
|
|
578
632
|
// Traverse a language definition with Depth First Search
|
|
579
|
-
DFS: function
|
|
580
|
-
|
|
581
|
-
var
|
|
582
|
-
for (var
|
|
583
|
-
if (
|
|
584
|
-
|
|
585
|
-
var
|
|
586
|
-
|
|
633
|
+
DFS: function DFS(o, callback, type, visited) {
|
|
634
|
+
visited = visited || {};
|
|
635
|
+
var objId = _.util.objId;
|
|
636
|
+
for (var i in o) {
|
|
637
|
+
if (o.hasOwnProperty(i)) {
|
|
638
|
+
callback.call(o, i, o[i], type || i);
|
|
639
|
+
var property = o[i];
|
|
640
|
+
var propertyType = _.util.type(property);
|
|
641
|
+
if (propertyType === "Object" && !visited[objId(property)]) {
|
|
642
|
+
visited[objId(property)] = true;
|
|
643
|
+
DFS(property, callback, null, visited);
|
|
644
|
+
} else if (propertyType === "Array" && !visited[objId(property)]) {
|
|
645
|
+
visited[objId(property)] = true;
|
|
646
|
+
DFS(property, callback, i, visited);
|
|
647
|
+
}
|
|
587
648
|
}
|
|
649
|
+
}
|
|
588
650
|
}
|
|
589
651
|
},
|
|
590
652
|
plugins: {},
|
|
@@ -600,8 +662,8 @@ var Q = { exports: {} };
|
|
|
600
662
|
* @memberof Prism
|
|
601
663
|
* @public
|
|
602
664
|
*/
|
|
603
|
-
highlightAll: function(
|
|
604
|
-
|
|
665
|
+
highlightAll: function(async, callback) {
|
|
666
|
+
_.highlightAllUnder(document, async, callback);
|
|
605
667
|
},
|
|
606
668
|
/**
|
|
607
669
|
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
@@ -618,15 +680,18 @@ var Q = { exports: {} };
|
|
|
618
680
|
* @memberof Prism
|
|
619
681
|
* @public
|
|
620
682
|
*/
|
|
621
|
-
highlightAllUnder: function(
|
|
622
|
-
var
|
|
623
|
-
callback
|
|
624
|
-
container
|
|
683
|
+
highlightAllUnder: function(container, async, callback) {
|
|
684
|
+
var env = {
|
|
685
|
+
callback,
|
|
686
|
+
container,
|
|
625
687
|
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
626
688
|
};
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
689
|
+
_.hooks.run("before-highlightall", env);
|
|
690
|
+
env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
|
|
691
|
+
_.hooks.run("before-all-elements-highlight", env);
|
|
692
|
+
for (var i = 0, element; element = env.elements[i++]; ) {
|
|
693
|
+
_.highlightElement(element, async === true, env.callback);
|
|
694
|
+
}
|
|
630
695
|
},
|
|
631
696
|
/**
|
|
632
697
|
* Highlights the code inside a single element.
|
|
@@ -656,39 +721,57 @@ var Q = { exports: {} };
|
|
|
656
721
|
* @memberof Prism
|
|
657
722
|
* @public
|
|
658
723
|
*/
|
|
659
|
-
highlightElement: function(
|
|
660
|
-
var
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
724
|
+
highlightElement: function(element, async, callback) {
|
|
725
|
+
var language = _.util.getLanguage(element);
|
|
726
|
+
var grammar = _.languages[language];
|
|
727
|
+
_.util.setLanguage(element, language);
|
|
728
|
+
var parent = element.parentElement;
|
|
729
|
+
if (parent && parent.nodeName.toLowerCase() === "pre") {
|
|
730
|
+
_.util.setLanguage(parent, language);
|
|
731
|
+
}
|
|
732
|
+
var code = element.textContent;
|
|
733
|
+
var env = {
|
|
734
|
+
element,
|
|
735
|
+
language,
|
|
736
|
+
grammar,
|
|
737
|
+
code
|
|
669
738
|
};
|
|
670
|
-
function
|
|
671
|
-
|
|
739
|
+
function insertHighlightedCode(highlightedCode) {
|
|
740
|
+
env.highlightedCode = highlightedCode;
|
|
741
|
+
_.hooks.run("before-insert", env);
|
|
742
|
+
env.element.innerHTML = env.highlightedCode;
|
|
743
|
+
_.hooks.run("after-highlight", env);
|
|
744
|
+
_.hooks.run("complete", env);
|
|
745
|
+
callback && callback.call(env.element);
|
|
746
|
+
}
|
|
747
|
+
_.hooks.run("before-sanity-check", env);
|
|
748
|
+
parent = env.element.parentElement;
|
|
749
|
+
if (parent && parent.nodeName.toLowerCase() === "pre" && !parent.hasAttribute("tabindex")) {
|
|
750
|
+
parent.setAttribute("tabindex", "0");
|
|
672
751
|
}
|
|
673
|
-
if (
|
|
674
|
-
|
|
752
|
+
if (!env.code) {
|
|
753
|
+
_.hooks.run("complete", env);
|
|
754
|
+
callback && callback.call(env.element);
|
|
675
755
|
return;
|
|
676
756
|
}
|
|
677
|
-
|
|
678
|
-
|
|
757
|
+
_.hooks.run("before-highlight", env);
|
|
758
|
+
if (!env.grammar) {
|
|
759
|
+
insertHighlightedCode(_.util.encode(env.code));
|
|
679
760
|
return;
|
|
680
761
|
}
|
|
681
|
-
if (
|
|
682
|
-
var
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
762
|
+
if (async && _self2.Worker) {
|
|
763
|
+
var worker = new Worker(_.filename);
|
|
764
|
+
worker.onmessage = function(evt) {
|
|
765
|
+
insertHighlightedCode(evt.data);
|
|
766
|
+
};
|
|
767
|
+
worker.postMessage(JSON.stringify({
|
|
768
|
+
language: env.language,
|
|
769
|
+
code: env.code,
|
|
770
|
+
immediateClose: true
|
|
689
771
|
}));
|
|
690
|
-
} else
|
|
691
|
-
|
|
772
|
+
} else {
|
|
773
|
+
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
|
|
774
|
+
}
|
|
692
775
|
},
|
|
693
776
|
/**
|
|
694
777
|
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
@@ -710,15 +793,19 @@ var Q = { exports: {} };
|
|
|
710
793
|
* @example
|
|
711
794
|
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
712
795
|
*/
|
|
713
|
-
highlight: function(
|
|
714
|
-
var
|
|
715
|
-
code:
|
|
716
|
-
grammar
|
|
717
|
-
language
|
|
796
|
+
highlight: function(text, grammar, language) {
|
|
797
|
+
var env = {
|
|
798
|
+
code: text,
|
|
799
|
+
grammar,
|
|
800
|
+
language
|
|
718
801
|
};
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
802
|
+
_.hooks.run("before-tokenize", env);
|
|
803
|
+
if (!env.grammar) {
|
|
804
|
+
throw new Error('The language "' + env.language + '" has no grammar.');
|
|
805
|
+
}
|
|
806
|
+
env.tokens = _.tokenize(env.code, env.grammar);
|
|
807
|
+
_.hooks.run("after-tokenize", env);
|
|
808
|
+
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
722
809
|
},
|
|
723
810
|
/**
|
|
724
811
|
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
@@ -744,15 +831,18 @@ var Q = { exports: {} };
|
|
|
744
831
|
* }
|
|
745
832
|
* });
|
|
746
833
|
*/
|
|
747
|
-
tokenize: function(
|
|
748
|
-
var
|
|
749
|
-
if (
|
|
750
|
-
for (var
|
|
751
|
-
|
|
752
|
-
|
|
834
|
+
tokenize: function(text, grammar) {
|
|
835
|
+
var rest = grammar.rest;
|
|
836
|
+
if (rest) {
|
|
837
|
+
for (var token in rest) {
|
|
838
|
+
grammar[token] = rest[token];
|
|
839
|
+
}
|
|
840
|
+
delete grammar.rest;
|
|
753
841
|
}
|
|
754
|
-
var
|
|
755
|
-
|
|
842
|
+
var tokenList = new LinkedList();
|
|
843
|
+
addAfter(tokenList, tokenList.head, text);
|
|
844
|
+
matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
|
845
|
+
return toArray(tokenList);
|
|
756
846
|
},
|
|
757
847
|
/**
|
|
758
848
|
* @namespace
|
|
@@ -773,9 +863,10 @@ var Q = { exports: {} };
|
|
|
773
863
|
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
774
864
|
* @public
|
|
775
865
|
*/
|
|
776
|
-
add: function(
|
|
777
|
-
var
|
|
778
|
-
|
|
866
|
+
add: function(name, callback) {
|
|
867
|
+
var hooks = _.hooks.all;
|
|
868
|
+
hooks[name] = hooks[name] || [];
|
|
869
|
+
hooks[name].push(callback);
|
|
779
870
|
},
|
|
780
871
|
/**
|
|
781
872
|
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
@@ -786,214 +877,337 @@ var Q = { exports: {} };
|
|
|
786
877
|
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
787
878
|
* @public
|
|
788
879
|
*/
|
|
789
|
-
run: function(
|
|
790
|
-
var
|
|
791
|
-
if (!
|
|
792
|
-
|
|
793
|
-
|
|
880
|
+
run: function(name, env) {
|
|
881
|
+
var callbacks = _.hooks.all[name];
|
|
882
|
+
if (!callbacks || !callbacks.length) {
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
for (var i = 0, callback; callback = callbacks[i++]; ) {
|
|
886
|
+
callback(env);
|
|
887
|
+
}
|
|
794
888
|
}
|
|
795
889
|
},
|
|
796
|
-
Token
|
|
890
|
+
Token
|
|
797
891
|
};
|
|
798
|
-
|
|
799
|
-
function
|
|
800
|
-
this.type =
|
|
892
|
+
_self2.Prism = _;
|
|
893
|
+
function Token(type, content, alias, matchedStr) {
|
|
894
|
+
this.type = type;
|
|
895
|
+
this.content = content;
|
|
896
|
+
this.alias = alias;
|
|
897
|
+
this.length = (matchedStr || "").length | 0;
|
|
801
898
|
}
|
|
802
|
-
|
|
803
|
-
if (typeof
|
|
804
|
-
return
|
|
805
|
-
|
|
899
|
+
Token.stringify = function stringify(o, language) {
|
|
900
|
+
if (typeof o == "string") {
|
|
901
|
+
return o;
|
|
902
|
+
}
|
|
903
|
+
if (Array.isArray(o)) {
|
|
806
904
|
var s = "";
|
|
807
|
-
|
|
808
|
-
s +=
|
|
809
|
-
})
|
|
905
|
+
o.forEach(function(e) {
|
|
906
|
+
s += stringify(e, language);
|
|
907
|
+
});
|
|
908
|
+
return s;
|
|
810
909
|
}
|
|
811
|
-
var
|
|
812
|
-
type:
|
|
813
|
-
content:
|
|
910
|
+
var env = {
|
|
911
|
+
type: o.type,
|
|
912
|
+
content: stringify(o.content, language),
|
|
814
913
|
tag: "span",
|
|
815
|
-
classes: ["token",
|
|
914
|
+
classes: ["token", o.type],
|
|
816
915
|
attributes: {},
|
|
817
|
-
language
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
916
|
+
language
|
|
917
|
+
};
|
|
918
|
+
var aliases = o.alias;
|
|
919
|
+
if (aliases) {
|
|
920
|
+
if (Array.isArray(aliases)) {
|
|
921
|
+
Array.prototype.push.apply(env.classes, aliases);
|
|
922
|
+
} else {
|
|
923
|
+
env.classes.push(aliases);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
_.hooks.run("wrap", env);
|
|
927
|
+
var attributes = "";
|
|
928
|
+
for (var name in env.attributes) {
|
|
929
|
+
attributes += " " + name + '="' + (env.attributes[name] || "").replace(/"/g, """) + '"';
|
|
930
|
+
}
|
|
931
|
+
return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + attributes + ">" + env.content + "</" + env.tag + ">";
|
|
824
932
|
};
|
|
825
|
-
function
|
|
826
|
-
|
|
827
|
-
var
|
|
828
|
-
if (
|
|
829
|
-
var
|
|
830
|
-
|
|
933
|
+
function matchPattern(pattern, pos, text, lookbehind) {
|
|
934
|
+
pattern.lastIndex = pos;
|
|
935
|
+
var match = pattern.exec(text);
|
|
936
|
+
if (match && lookbehind && match[1]) {
|
|
937
|
+
var lookbehindLength = match[1].length;
|
|
938
|
+
match.index += lookbehindLength;
|
|
939
|
+
match[0] = match[0].slice(lookbehindLength);
|
|
831
940
|
}
|
|
832
|
-
return
|
|
941
|
+
return match;
|
|
833
942
|
}
|
|
834
|
-
function
|
|
835
|
-
for (var
|
|
836
|
-
if (!
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
943
|
+
function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
|
944
|
+
for (var token in grammar) {
|
|
945
|
+
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
var patterns = grammar[token];
|
|
949
|
+
patterns = Array.isArray(patterns) ? patterns : [patterns];
|
|
950
|
+
for (var j2 = 0; j2 < patterns.length; ++j2) {
|
|
951
|
+
if (rematch && rematch.cause == token + "," + j2) {
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
var patternObj = patterns[j2];
|
|
955
|
+
var inside = patternObj.inside;
|
|
956
|
+
var lookbehind = !!patternObj.lookbehind;
|
|
957
|
+
var greedy = !!patternObj.greedy;
|
|
958
|
+
var alias = patternObj.alias;
|
|
959
|
+
if (greedy && !patternObj.pattern.global) {
|
|
960
|
+
var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
|
961
|
+
patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
|
|
962
|
+
}
|
|
963
|
+
var pattern = patternObj.pattern || patternObj;
|
|
964
|
+
for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
|
|
965
|
+
if (rematch && pos >= rematch.reach) {
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
var str = currentNode.value;
|
|
969
|
+
if (tokenList.length > text.length) {
|
|
841
970
|
return;
|
|
842
|
-
var A = c[v], R = A.inside, X = !!A.lookbehind, Z = !!A.greedy, ee = A.alias;
|
|
843
|
-
if (Z && !A.pattern.global) {
|
|
844
|
-
var te = A.pattern.toString().match(/[imsuy]*$/)[0];
|
|
845
|
-
A.pattern = RegExp(A.pattern.source, te + "g");
|
|
846
971
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
972
|
+
if (str instanceof Token) {
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
var removeCount = 1;
|
|
976
|
+
var match;
|
|
977
|
+
if (greedy) {
|
|
978
|
+
match = matchPattern(pattern, pos, text, lookbehind);
|
|
979
|
+
if (!match || match.index >= text.length) {
|
|
980
|
+
break;
|
|
981
|
+
}
|
|
982
|
+
var from = match.index;
|
|
983
|
+
var to = match.index + match[0].length;
|
|
984
|
+
var p = pos;
|
|
985
|
+
p += currentNode.value.length;
|
|
986
|
+
while (from >= p) {
|
|
987
|
+
currentNode = currentNode.next;
|
|
988
|
+
p += currentNode.value.length;
|
|
989
|
+
}
|
|
990
|
+
p -= currentNode.value.length;
|
|
991
|
+
pos = p;
|
|
992
|
+
if (currentNode.value instanceof Token) {
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
|
|
996
|
+
removeCount++;
|
|
997
|
+
p += k.value.length;
|
|
998
|
+
}
|
|
999
|
+
removeCount--;
|
|
1000
|
+
str = text.slice(pos, p);
|
|
1001
|
+
match.index -= pos;
|
|
1002
|
+
} else {
|
|
1003
|
+
match = matchPattern(pattern, 0, str, lookbehind);
|
|
1004
|
+
if (!match) {
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
var from = match.index;
|
|
1009
|
+
var matchStr = match[0];
|
|
1010
|
+
var before = str.slice(0, from);
|
|
1011
|
+
var after = str.slice(from + matchStr.length);
|
|
1012
|
+
var reach = pos + str.length;
|
|
1013
|
+
if (rematch && reach > rematch.reach) {
|
|
1014
|
+
rematch.reach = reach;
|
|
1015
|
+
}
|
|
1016
|
+
var removeFrom = currentNode.prev;
|
|
1017
|
+
if (before) {
|
|
1018
|
+
removeFrom = addAfter(tokenList, removeFrom, before);
|
|
1019
|
+
pos += before.length;
|
|
1020
|
+
}
|
|
1021
|
+
removeRange(tokenList, removeFrom, removeCount);
|
|
1022
|
+
var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
|
1023
|
+
currentNode = addAfter(tokenList, removeFrom, wrapped);
|
|
1024
|
+
if (after) {
|
|
1025
|
+
addAfter(tokenList, currentNode, after);
|
|
1026
|
+
}
|
|
1027
|
+
if (removeCount > 1) {
|
|
1028
|
+
var nestedRematch = {
|
|
1029
|
+
cause: token + "," + j2,
|
|
1030
|
+
reach
|
|
1031
|
+
};
|
|
1032
|
+
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
|
1033
|
+
if (rematch && nestedRematch.reach > rematch.reach) {
|
|
1034
|
+
rematch.reach = nestedRematch.reach;
|
|
878
1035
|
}
|
|
879
1036
|
}
|
|
880
1037
|
}
|
|
881
1038
|
}
|
|
1039
|
+
}
|
|
882
1040
|
}
|
|
883
|
-
function
|
|
884
|
-
var
|
|
885
|
-
|
|
1041
|
+
function LinkedList() {
|
|
1042
|
+
var head = { value: null, prev: null, next: null };
|
|
1043
|
+
var tail = { value: null, prev: head, next: null };
|
|
1044
|
+
head.next = tail;
|
|
1045
|
+
this.head = head;
|
|
1046
|
+
this.tail = tail;
|
|
1047
|
+
this.length = 0;
|
|
886
1048
|
}
|
|
887
|
-
function
|
|
888
|
-
var
|
|
889
|
-
|
|
1049
|
+
function addAfter(list, node, value) {
|
|
1050
|
+
var next = node.next;
|
|
1051
|
+
var newNode = { value, prev: node, next };
|
|
1052
|
+
node.next = newNode;
|
|
1053
|
+
next.prev = newNode;
|
|
1054
|
+
list.length++;
|
|
1055
|
+
return newNode;
|
|
890
1056
|
}
|
|
891
|
-
function
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1057
|
+
function removeRange(list, node, count) {
|
|
1058
|
+
var next = node.next;
|
|
1059
|
+
for (var i = 0; i < count && next !== list.tail; i++) {
|
|
1060
|
+
next = next.next;
|
|
1061
|
+
}
|
|
1062
|
+
node.next = next;
|
|
1063
|
+
next.prev = node;
|
|
1064
|
+
list.length -= i;
|
|
895
1065
|
}
|
|
896
|
-
function
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1066
|
+
function toArray(list) {
|
|
1067
|
+
var array = [];
|
|
1068
|
+
var node = list.head.next;
|
|
1069
|
+
while (node !== list.tail) {
|
|
1070
|
+
array.push(node.value);
|
|
1071
|
+
node = node.next;
|
|
1072
|
+
}
|
|
1073
|
+
return array;
|
|
900
1074
|
}
|
|
901
|
-
if (!
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
1075
|
+
if (!_self2.document) {
|
|
1076
|
+
if (!_self2.addEventListener) {
|
|
1077
|
+
return _;
|
|
1078
|
+
}
|
|
1079
|
+
if (!_.disableWorkerMessageHandler) {
|
|
1080
|
+
_self2.addEventListener("message", function(evt) {
|
|
1081
|
+
var message = JSON.parse(evt.data);
|
|
1082
|
+
var lang2 = message.language;
|
|
1083
|
+
var code = message.code;
|
|
1084
|
+
var immediateClose = message.immediateClose;
|
|
1085
|
+
_self2.postMessage(_.highlight(code, _.languages[lang2], lang2));
|
|
1086
|
+
if (immediateClose) {
|
|
1087
|
+
_self2.close();
|
|
1088
|
+
}
|
|
1089
|
+
}, false);
|
|
1090
|
+
}
|
|
1091
|
+
return _;
|
|
910
1092
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
1093
|
+
var script = _.util.currentScript();
|
|
1094
|
+
if (script) {
|
|
1095
|
+
_.filename = script.src;
|
|
1096
|
+
if (script.hasAttribute("data-manual")) {
|
|
1097
|
+
_.manual = true;
|
|
1098
|
+
}
|
|
914
1099
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1100
|
+
function highlightAutomaticallyCallback() {
|
|
1101
|
+
if (!_.manual) {
|
|
1102
|
+
_.highlightAll();
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
if (!_.manual) {
|
|
1106
|
+
var readyState = document.readyState;
|
|
1107
|
+
if (readyState === "loading" || readyState === "interactive" && script && script.defer) {
|
|
1108
|
+
document.addEventListener("DOMContentLoaded", highlightAutomaticallyCallback);
|
|
1109
|
+
} else {
|
|
1110
|
+
if (window.requestAnimationFrame) {
|
|
1111
|
+
window.requestAnimationFrame(highlightAutomaticallyCallback);
|
|
1112
|
+
} else {
|
|
1113
|
+
window.setTimeout(highlightAutomaticallyCallback, 16);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return _;
|
|
1118
|
+
}(_self);
|
|
1119
|
+
if (module.exports) {
|
|
1120
|
+
module.exports = Prism2;
|
|
1121
|
+
}
|
|
1122
|
+
if (typeof commonjsGlobal !== "undefined") {
|
|
1123
|
+
commonjsGlobal.Prism = Prism2;
|
|
1124
|
+
}
|
|
1125
|
+
Prism2.languages.markup = {
|
|
1126
|
+
"comment": {
|
|
919
1127
|
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
920
|
-
greedy:
|
|
1128
|
+
greedy: true
|
|
921
1129
|
},
|
|
922
|
-
prolog: {
|
|
1130
|
+
"prolog": {
|
|
923
1131
|
pattern: /<\?[\s\S]+?\?>/,
|
|
924
|
-
greedy:
|
|
1132
|
+
greedy: true
|
|
925
1133
|
},
|
|
926
|
-
doctype: {
|
|
1134
|
+
"doctype": {
|
|
927
1135
|
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
928
1136
|
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
929
|
-
greedy:
|
|
1137
|
+
greedy: true,
|
|
930
1138
|
inside: {
|
|
931
1139
|
"internal-subset": {
|
|
932
1140
|
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
933
|
-
lookbehind:
|
|
934
|
-
greedy:
|
|
1141
|
+
lookbehind: true,
|
|
1142
|
+
greedy: true,
|
|
935
1143
|
inside: null
|
|
936
1144
|
// see below
|
|
937
1145
|
},
|
|
938
|
-
string: {
|
|
1146
|
+
"string": {
|
|
939
1147
|
pattern: /"[^"]*"|'[^']*'/,
|
|
940
|
-
greedy:
|
|
1148
|
+
greedy: true
|
|
941
1149
|
},
|
|
942
|
-
punctuation: /^<!|>$|[[\]]/,
|
|
1150
|
+
"punctuation": /^<!|>$|[[\]]/,
|
|
943
1151
|
"doctype-tag": /^DOCTYPE/i,
|
|
944
|
-
name: /[^\s<>'"]+/
|
|
1152
|
+
"name": /[^\s<>'"]+/
|
|
945
1153
|
}
|
|
946
1154
|
},
|
|
947
|
-
cdata: {
|
|
1155
|
+
"cdata": {
|
|
948
1156
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
949
|
-
greedy:
|
|
1157
|
+
greedy: true
|
|
950
1158
|
},
|
|
951
|
-
tag: {
|
|
1159
|
+
"tag": {
|
|
952
1160
|
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
953
|
-
greedy:
|
|
1161
|
+
greedy: true,
|
|
954
1162
|
inside: {
|
|
955
|
-
tag: {
|
|
1163
|
+
"tag": {
|
|
956
1164
|
pattern: /^<\/?[^\s>\/]+/,
|
|
957
1165
|
inside: {
|
|
958
|
-
punctuation: /^<\/?/,
|
|
959
|
-
namespace: /^[^\s>\/:]+:/
|
|
1166
|
+
"punctuation": /^<\/?/,
|
|
1167
|
+
"namespace": /^[^\s>\/:]+:/
|
|
960
1168
|
}
|
|
961
1169
|
},
|
|
962
1170
|
"special-attr": [],
|
|
963
1171
|
"attr-value": {
|
|
964
1172
|
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
965
1173
|
inside: {
|
|
966
|
-
punctuation: [
|
|
1174
|
+
"punctuation": [
|
|
967
1175
|
{
|
|
968
1176
|
pattern: /^=/,
|
|
969
1177
|
alias: "attr-equals"
|
|
970
1178
|
},
|
|
971
1179
|
{
|
|
972
1180
|
pattern: /^(\s*)["']|["']$/,
|
|
973
|
-
lookbehind:
|
|
1181
|
+
lookbehind: true
|
|
974
1182
|
}
|
|
975
1183
|
]
|
|
976
1184
|
}
|
|
977
1185
|
},
|
|
978
|
-
punctuation: /\/?>/,
|
|
1186
|
+
"punctuation": /\/?>/,
|
|
979
1187
|
"attr-name": {
|
|
980
1188
|
pattern: /[^\s>\/]+/,
|
|
981
1189
|
inside: {
|
|
982
|
-
namespace: /^[^\s>\/:]+:/
|
|
1190
|
+
"namespace": /^[^\s>\/:]+:/
|
|
983
1191
|
}
|
|
984
1192
|
}
|
|
985
1193
|
}
|
|
986
1194
|
},
|
|
987
|
-
entity: [
|
|
1195
|
+
"entity": [
|
|
988
1196
|
{
|
|
989
1197
|
pattern: /&[\da-z]{1,8};/i,
|
|
990
1198
|
alias: "named-entity"
|
|
991
1199
|
},
|
|
992
1200
|
/&#x?[\da-f]{1,8};/i
|
|
993
1201
|
]
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
|
|
1202
|
+
};
|
|
1203
|
+
Prism2.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism2.languages.markup["entity"];
|
|
1204
|
+
Prism2.languages.markup["doctype"].inside["internal-subset"].inside = Prism2.languages.markup;
|
|
1205
|
+
Prism2.hooks.add("wrap", function(env) {
|
|
1206
|
+
if (env.type === "entity") {
|
|
1207
|
+
env.attributes["title"] = env.content.replace(/&/, "&");
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
Object.defineProperty(Prism2.languages.markup.tag, "addInlined", {
|
|
997
1211
|
/**
|
|
998
1212
|
* Adds an inlined language to markup.
|
|
999
1213
|
*
|
|
@@ -1005,34 +1219,37 @@ var Q = { exports: {} };
|
|
|
1005
1219
|
* @example
|
|
1006
1220
|
* addInlined('style', 'css');
|
|
1007
1221
|
*/
|
|
1008
|
-
value: function(
|
|
1009
|
-
var
|
|
1010
|
-
|
|
1222
|
+
value: function addInlined(tagName, lang) {
|
|
1223
|
+
var includedCdataInside = {};
|
|
1224
|
+
includedCdataInside["language-" + lang] = {
|
|
1011
1225
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1012
|
-
lookbehind:
|
|
1013
|
-
inside:
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1226
|
+
lookbehind: true,
|
|
1227
|
+
inside: Prism2.languages[lang]
|
|
1228
|
+
};
|
|
1229
|
+
includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
|
|
1230
|
+
var inside = {
|
|
1016
1231
|
"included-cdata": {
|
|
1017
1232
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1018
|
-
inside:
|
|
1233
|
+
inside: includedCdataInside
|
|
1019
1234
|
}
|
|
1020
1235
|
};
|
|
1021
|
-
|
|
1236
|
+
inside["language-" + lang] = {
|
|
1022
1237
|
pattern: /[\s\S]+/,
|
|
1023
|
-
inside:
|
|
1238
|
+
inside: Prism2.languages[lang]
|
|
1024
1239
|
};
|
|
1025
|
-
var
|
|
1026
|
-
|
|
1240
|
+
var def = {};
|
|
1241
|
+
def[tagName] = {
|
|
1027
1242
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1028
|
-
return
|
|
1243
|
+
return tagName;
|
|
1029
1244
|
}), "i"),
|
|
1030
|
-
lookbehind:
|
|
1031
|
-
greedy:
|
|
1032
|
-
inside
|
|
1033
|
-
}
|
|
1245
|
+
lookbehind: true,
|
|
1246
|
+
greedy: true,
|
|
1247
|
+
inside
|
|
1248
|
+
};
|
|
1249
|
+
Prism2.languages.insertBefore("markup", "cdata", def);
|
|
1034
1250
|
}
|
|
1035
|
-
})
|
|
1251
|
+
});
|
|
1252
|
+
Object.defineProperty(Prism2.languages.markup.tag, "addAttribute", {
|
|
1036
1253
|
/**
|
|
1037
1254
|
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
1038
1255
|
*
|
|
@@ -1044,25 +1261,25 @@ var Q = { exports: {} };
|
|
|
1044
1261
|
* @example
|
|
1045
1262
|
* addAttribute('style', 'css');
|
|
1046
1263
|
*/
|
|
1047
|
-
value: function(
|
|
1048
|
-
|
|
1264
|
+
value: function(attrName, lang) {
|
|
1265
|
+
Prism2.languages.markup.tag.inside["special-attr"].push({
|
|
1049
1266
|
pattern: RegExp(
|
|
1050
|
-
/(^|["'\s])/.source + "(?:" +
|
|
1267
|
+
/(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1051
1268
|
"i"
|
|
1052
1269
|
),
|
|
1053
|
-
lookbehind:
|
|
1270
|
+
lookbehind: true,
|
|
1054
1271
|
inside: {
|
|
1055
1272
|
"attr-name": /^[^\s=]+/,
|
|
1056
1273
|
"attr-value": {
|
|
1057
1274
|
pattern: /=[\s\S]+/,
|
|
1058
1275
|
inside: {
|
|
1059
|
-
value: {
|
|
1276
|
+
"value": {
|
|
1060
1277
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1061
|
-
lookbehind:
|
|
1062
|
-
alias: [
|
|
1063
|
-
inside:
|
|
1278
|
+
lookbehind: true,
|
|
1279
|
+
alias: [lang, "language-" + lang],
|
|
1280
|
+
inside: Prism2.languages[lang]
|
|
1064
1281
|
},
|
|
1065
|
-
punctuation: [
|
|
1282
|
+
"punctuation": [
|
|
1066
1283
|
{
|
|
1067
1284
|
pattern: /^=/,
|
|
1068
1285
|
alias: "attr-equals"
|
|
@@ -1074,111 +1291,125 @@ var Q = { exports: {} };
|
|
|
1074
1291
|
}
|
|
1075
1292
|
});
|
|
1076
1293
|
}
|
|
1077
|
-
})
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1294
|
+
});
|
|
1295
|
+
Prism2.languages.html = Prism2.languages.markup;
|
|
1296
|
+
Prism2.languages.mathml = Prism2.languages.markup;
|
|
1297
|
+
Prism2.languages.svg = Prism2.languages.markup;
|
|
1298
|
+
Prism2.languages.xml = Prism2.languages.extend("markup", {});
|
|
1299
|
+
Prism2.languages.ssml = Prism2.languages.xml;
|
|
1300
|
+
Prism2.languages.atom = Prism2.languages.xml;
|
|
1301
|
+
Prism2.languages.rss = Prism2.languages.xml;
|
|
1302
|
+
(function(Prism3) {
|
|
1303
|
+
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1304
|
+
Prism3.languages.css = {
|
|
1305
|
+
"comment": /\/\*[\s\S]*?\*\//,
|
|
1306
|
+
"atrule": {
|
|
1307
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + string.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1083
1308
|
inside: {
|
|
1084
|
-
rule: /^@[\w-]+/,
|
|
1309
|
+
"rule": /^@[\w-]+/,
|
|
1085
1310
|
"selector-function-argument": {
|
|
1086
1311
|
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
1087
|
-
lookbehind:
|
|
1312
|
+
lookbehind: true,
|
|
1088
1313
|
alias: "selector"
|
|
1089
1314
|
},
|
|
1090
|
-
keyword: {
|
|
1315
|
+
"keyword": {
|
|
1091
1316
|
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
1092
|
-
lookbehind:
|
|
1317
|
+
lookbehind: true
|
|
1093
1318
|
}
|
|
1094
1319
|
// See rest below
|
|
1095
1320
|
}
|
|
1096
1321
|
},
|
|
1097
|
-
url: {
|
|
1322
|
+
"url": {
|
|
1098
1323
|
// https://drafts.csswg.org/css-values-3/#urls
|
|
1099
|
-
pattern: RegExp("\\burl\\((?:" +
|
|
1100
|
-
greedy:
|
|
1324
|
+
pattern: RegExp("\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1325
|
+
greedy: true,
|
|
1101
1326
|
inside: {
|
|
1102
|
-
function: /^url/i,
|
|
1103
|
-
punctuation: /^\(|\)$/,
|
|
1104
|
-
string: {
|
|
1105
|
-
pattern: RegExp("^" +
|
|
1327
|
+
"function": /^url/i,
|
|
1328
|
+
"punctuation": /^\(|\)$/,
|
|
1329
|
+
"string": {
|
|
1330
|
+
pattern: RegExp("^" + string.source + "$"),
|
|
1106
1331
|
alias: "url"
|
|
1107
1332
|
}
|
|
1108
1333
|
}
|
|
1109
1334
|
},
|
|
1110
|
-
selector: {
|
|
1111
|
-
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` +
|
|
1112
|
-
lookbehind:
|
|
1335
|
+
"selector": {
|
|
1336
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"),
|
|
1337
|
+
lookbehind: true
|
|
1113
1338
|
},
|
|
1114
|
-
string: {
|
|
1115
|
-
pattern:
|
|
1116
|
-
greedy:
|
|
1339
|
+
"string": {
|
|
1340
|
+
pattern: string,
|
|
1341
|
+
greedy: true
|
|
1117
1342
|
},
|
|
1118
|
-
property: {
|
|
1343
|
+
"property": {
|
|
1119
1344
|
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
1120
|
-
lookbehind:
|
|
1345
|
+
lookbehind: true
|
|
1121
1346
|
},
|
|
1122
|
-
important: /!important\b/i,
|
|
1123
|
-
function: {
|
|
1347
|
+
"important": /!important\b/i,
|
|
1348
|
+
"function": {
|
|
1124
1349
|
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
1125
|
-
lookbehind:
|
|
1350
|
+
lookbehind: true
|
|
1126
1351
|
},
|
|
1127
|
-
punctuation: /[(){};:,]/
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1352
|
+
"punctuation": /[(){};:,]/
|
|
1353
|
+
};
|
|
1354
|
+
Prism3.languages.css["atrule"].inside.rest = Prism3.languages.css;
|
|
1355
|
+
var markup = Prism3.languages.markup;
|
|
1356
|
+
if (markup) {
|
|
1357
|
+
markup.tag.addInlined("style", "css");
|
|
1358
|
+
markup.tag.addAttribute("style", "css");
|
|
1359
|
+
}
|
|
1360
|
+
})(Prism2);
|
|
1361
|
+
Prism2.languages.clike = {
|
|
1362
|
+
"comment": [
|
|
1133
1363
|
{
|
|
1134
1364
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1135
|
-
lookbehind:
|
|
1136
|
-
greedy:
|
|
1365
|
+
lookbehind: true,
|
|
1366
|
+
greedy: true
|
|
1137
1367
|
},
|
|
1138
1368
|
{
|
|
1139
1369
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
1140
|
-
lookbehind:
|
|
1141
|
-
greedy:
|
|
1370
|
+
lookbehind: true,
|
|
1371
|
+
greedy: true
|
|
1142
1372
|
}
|
|
1143
1373
|
],
|
|
1144
|
-
string: {
|
|
1374
|
+
"string": {
|
|
1145
1375
|
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1146
|
-
greedy:
|
|
1376
|
+
greedy: true
|
|
1147
1377
|
},
|
|
1148
1378
|
"class-name": {
|
|
1149
1379
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1150
|
-
lookbehind:
|
|
1380
|
+
lookbehind: true,
|
|
1151
1381
|
inside: {
|
|
1152
|
-
punctuation: /[.\\]/
|
|
1382
|
+
"punctuation": /[.\\]/
|
|
1153
1383
|
}
|
|
1154
1384
|
},
|
|
1155
|
-
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1156
|
-
boolean: /\b(?:false|true)\b/,
|
|
1157
|
-
function: /\b\w+(?=\()/,
|
|
1158
|
-
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1159
|
-
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1160
|
-
punctuation: /[{}[\];(),.:]/
|
|
1161
|
-
}
|
|
1385
|
+
"keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1386
|
+
"boolean": /\b(?:false|true)\b/,
|
|
1387
|
+
"function": /\b\w+(?=\()/,
|
|
1388
|
+
"number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1389
|
+
"operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1390
|
+
"punctuation": /[{}[\];(),.:]/
|
|
1391
|
+
};
|
|
1392
|
+
Prism2.languages.javascript = Prism2.languages.extend("clike", {
|
|
1162
1393
|
"class-name": [
|
|
1163
|
-
|
|
1394
|
+
Prism2.languages.clike["class-name"],
|
|
1164
1395
|
{
|
|
1165
1396
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1166
|
-
lookbehind:
|
|
1397
|
+
lookbehind: true
|
|
1167
1398
|
}
|
|
1168
1399
|
],
|
|
1169
|
-
keyword: [
|
|
1400
|
+
"keyword": [
|
|
1170
1401
|
{
|
|
1171
1402
|
pattern: /((?:^|\})\s*)catch\b/,
|
|
1172
|
-
lookbehind:
|
|
1403
|
+
lookbehind: true
|
|
1173
1404
|
},
|
|
1174
1405
|
{
|
|
1175
1406
|
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
1176
|
-
lookbehind:
|
|
1407
|
+
lookbehind: true
|
|
1177
1408
|
}
|
|
1178
1409
|
],
|
|
1179
1410
|
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1180
|
-
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1181
|
-
number: {
|
|
1411
|
+
"function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1412
|
+
"number": {
|
|
1182
1413
|
pattern: RegExp(
|
|
1183
1414
|
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1184
1415
|
(/NaN|Infinity/.source + "|" + // binary integer
|
|
@@ -1188,11 +1419,13 @@ var Q = { exports: {} };
|
|
|
1188
1419
|
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1189
1420
|
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1190
1421
|
),
|
|
1191
|
-
lookbehind:
|
|
1422
|
+
lookbehind: true
|
|
1192
1423
|
},
|
|
1193
|
-
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1194
|
-
})
|
|
1195
|
-
|
|
1424
|
+
"operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1425
|
+
});
|
|
1426
|
+
Prism2.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
1427
|
+
Prism2.languages.insertBefore("javascript", "keyword", {
|
|
1428
|
+
"regex": {
|
|
1196
1429
|
pattern: RegExp(
|
|
1197
1430
|
// lookbehind
|
|
1198
1431
|
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
@@ -1204,14 +1437,14 @@ var Q = { exports: {} };
|
|
|
1204
1437
|
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1205
1438
|
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1206
1439
|
),
|
|
1207
|
-
lookbehind:
|
|
1208
|
-
greedy:
|
|
1440
|
+
lookbehind: true,
|
|
1441
|
+
greedy: true,
|
|
1209
1442
|
inside: {
|
|
1210
1443
|
"regex-source": {
|
|
1211
1444
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1212
|
-
lookbehind:
|
|
1445
|
+
lookbehind: true,
|
|
1213
1446
|
alias: "language-regex",
|
|
1214
|
-
inside:
|
|
1447
|
+
inside: Prism2.languages.regex
|
|
1215
1448
|
},
|
|
1216
1449
|
"regex-delimiter": /^\/|\/$/,
|
|
1217
1450
|
"regex-flags": /^[a-z]+$/
|
|
@@ -1222,138 +1455,200 @@ var Q = { exports: {} };
|
|
|
1222
1455
|
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
1223
1456
|
alias: "function"
|
|
1224
1457
|
},
|
|
1225
|
-
parameter: [
|
|
1458
|
+
"parameter": [
|
|
1226
1459
|
{
|
|
1227
1460
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1228
|
-
lookbehind:
|
|
1229
|
-
inside:
|
|
1461
|
+
lookbehind: true,
|
|
1462
|
+
inside: Prism2.languages.javascript
|
|
1230
1463
|
},
|
|
1231
1464
|
{
|
|
1232
1465
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1233
|
-
lookbehind:
|
|
1234
|
-
inside:
|
|
1466
|
+
lookbehind: true,
|
|
1467
|
+
inside: Prism2.languages.javascript
|
|
1235
1468
|
},
|
|
1236
1469
|
{
|
|
1237
1470
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1238
|
-
lookbehind:
|
|
1239
|
-
inside:
|
|
1471
|
+
lookbehind: true,
|
|
1472
|
+
inside: Prism2.languages.javascript
|
|
1240
1473
|
},
|
|
1241
1474
|
{
|
|
1242
1475
|
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
1243
|
-
lookbehind:
|
|
1244
|
-
inside:
|
|
1476
|
+
lookbehind: true,
|
|
1477
|
+
inside: Prism2.languages.javascript
|
|
1245
1478
|
}
|
|
1246
1479
|
],
|
|
1247
|
-
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1248
|
-
})
|
|
1249
|
-
|
|
1480
|
+
"constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1481
|
+
});
|
|
1482
|
+
Prism2.languages.insertBefore("javascript", "string", {
|
|
1483
|
+
"hashbang": {
|
|
1250
1484
|
pattern: /^#!.*/,
|
|
1251
|
-
greedy:
|
|
1485
|
+
greedy: true,
|
|
1252
1486
|
alias: "comment"
|
|
1253
1487
|
},
|
|
1254
1488
|
"template-string": {
|
|
1255
1489
|
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1256
|
-
greedy:
|
|
1490
|
+
greedy: true,
|
|
1257
1491
|
inside: {
|
|
1258
1492
|
"template-punctuation": {
|
|
1259
1493
|
pattern: /^`|`$/,
|
|
1260
1494
|
alias: "string"
|
|
1261
1495
|
},
|
|
1262
|
-
interpolation: {
|
|
1496
|
+
"interpolation": {
|
|
1263
1497
|
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1264
|
-
lookbehind:
|
|
1498
|
+
lookbehind: true,
|
|
1265
1499
|
inside: {
|
|
1266
1500
|
"interpolation-punctuation": {
|
|
1267
1501
|
pattern: /^\$\{|\}$/,
|
|
1268
1502
|
alias: "punctuation"
|
|
1269
1503
|
},
|
|
1270
|
-
rest:
|
|
1504
|
+
rest: Prism2.languages.javascript
|
|
1271
1505
|
}
|
|
1272
1506
|
},
|
|
1273
|
-
string: /[\s\S]+/
|
|
1507
|
+
"string": /[\s\S]+/
|
|
1274
1508
|
}
|
|
1275
1509
|
},
|
|
1276
1510
|
"string-property": {
|
|
1277
1511
|
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1278
|
-
lookbehind:
|
|
1279
|
-
greedy:
|
|
1512
|
+
lookbehind: true,
|
|
1513
|
+
greedy: true,
|
|
1280
1514
|
alias: "property"
|
|
1281
1515
|
}
|
|
1282
|
-
})
|
|
1516
|
+
});
|
|
1517
|
+
Prism2.languages.insertBefore("javascript", "operator", {
|
|
1283
1518
|
"literal-property": {
|
|
1284
1519
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1285
|
-
lookbehind:
|
|
1520
|
+
lookbehind: true,
|
|
1286
1521
|
alias: "property"
|
|
1287
1522
|
}
|
|
1288
|
-
})
|
|
1289
|
-
|
|
1290
|
-
"javascript"
|
|
1291
|
-
|
|
1292
|
-
|
|
1523
|
+
});
|
|
1524
|
+
if (Prism2.languages.markup) {
|
|
1525
|
+
Prism2.languages.markup.tag.addInlined("script", "javascript");
|
|
1526
|
+
Prism2.languages.markup.tag.addAttribute(
|
|
1527
|
+
/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
|
|
1528
|
+
"javascript"
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
Prism2.languages.js = Prism2.languages.javascript;
|
|
1532
|
+
(function() {
|
|
1533
|
+
if (typeof Prism2 === "undefined" || typeof document === "undefined") {
|
|
1293
1534
|
return;
|
|
1294
|
-
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1295
|
-
var l = "Loading…", p = function(y, b) {
|
|
1296
|
-
return "✖ Error " + y + " while fetching file: " + b;
|
|
1297
|
-
}, f = "✖ Error: File does not exist or is empty", m = {
|
|
1298
|
-
js: "javascript",
|
|
1299
|
-
py: "python",
|
|
1300
|
-
rb: "ruby",
|
|
1301
|
-
ps1: "powershell",
|
|
1302
|
-
psm1: "powershell",
|
|
1303
|
-
sh: "bash",
|
|
1304
|
-
bat: "batch",
|
|
1305
|
-
h: "c",
|
|
1306
|
-
tex: "latex"
|
|
1307
|
-
}, u = "data-src-status", g = "loading", E = "loaded", w = "failed", k = "pre[data-src]:not([" + u + '="' + E + '"]):not([' + u + '="' + g + '"])';
|
|
1308
|
-
function x(y, b, S) {
|
|
1309
|
-
var a = new XMLHttpRequest();
|
|
1310
|
-
a.open("GET", y, !0), a.onreadystatechange = function() {
|
|
1311
|
-
a.readyState == 4 && (a.status < 400 && a.responseText ? b(a.responseText) : a.status >= 400 ? S(p(a.status, a.statusText)) : S(f));
|
|
1312
|
-
}, a.send(null);
|
|
1313
1535
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1536
|
+
if (!Element.prototype.matches) {
|
|
1537
|
+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
1538
|
+
}
|
|
1539
|
+
var LOADING_MESSAGE = "Loading…";
|
|
1540
|
+
var FAILURE_MESSAGE = function(status, message) {
|
|
1541
|
+
return "✖ Error " + status + " while fetching file: " + message;
|
|
1542
|
+
};
|
|
1543
|
+
var FAILURE_EMPTY_MESSAGE = "✖ Error: File does not exist or is empty";
|
|
1544
|
+
var EXTENSIONS = {
|
|
1545
|
+
"js": "javascript",
|
|
1546
|
+
"py": "python",
|
|
1547
|
+
"rb": "ruby",
|
|
1548
|
+
"ps1": "powershell",
|
|
1549
|
+
"psm1": "powershell",
|
|
1550
|
+
"sh": "bash",
|
|
1551
|
+
"bat": "batch",
|
|
1552
|
+
"h": "c",
|
|
1553
|
+
"tex": "latex"
|
|
1554
|
+
};
|
|
1555
|
+
var STATUS_ATTR = "data-src-status";
|
|
1556
|
+
var STATUS_LOADING = "loading";
|
|
1557
|
+
var STATUS_LOADED = "loaded";
|
|
1558
|
+
var STATUS_FAILED = "failed";
|
|
1559
|
+
var SELECTOR = "pre[data-src]:not([" + STATUS_ATTR + '="' + STATUS_LOADED + '"]):not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
|
|
1560
|
+
function loadFile(src, success, error) {
|
|
1561
|
+
var xhr = new XMLHttpRequest();
|
|
1562
|
+
xhr.open("GET", src, true);
|
|
1563
|
+
xhr.onreadystatechange = function() {
|
|
1564
|
+
if (xhr.readyState == 4) {
|
|
1565
|
+
if (xhr.status < 400 && xhr.responseText) {
|
|
1566
|
+
success(xhr.responseText);
|
|
1567
|
+
} else {
|
|
1568
|
+
if (xhr.status >= 400) {
|
|
1569
|
+
error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
|
|
1570
|
+
} else {
|
|
1571
|
+
error(FAILURE_EMPTY_MESSAGE);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
xhr.send(null);
|
|
1577
|
+
}
|
|
1578
|
+
function parseRange(range) {
|
|
1579
|
+
var m2 = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || "");
|
|
1580
|
+
if (m2) {
|
|
1581
|
+
var start = Number(m2[1]);
|
|
1582
|
+
var comma = m2[2];
|
|
1583
|
+
var end = m2[3];
|
|
1584
|
+
if (!comma) {
|
|
1585
|
+
return [start, start];
|
|
1586
|
+
}
|
|
1587
|
+
if (!end) {
|
|
1588
|
+
return [start, void 0];
|
|
1589
|
+
}
|
|
1590
|
+
return [start, Number(end)];
|
|
1319
1591
|
}
|
|
1592
|
+
return void 0;
|
|
1320
1593
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
})
|
|
1324
|
-
|
|
1594
|
+
Prism2.hooks.add("before-highlightall", function(env) {
|
|
1595
|
+
env.selector += ", " + SELECTOR;
|
|
1596
|
+
});
|
|
1597
|
+
Prism2.hooks.add("before-sanity-check", function(env) {
|
|
1598
|
+
var pre = (
|
|
1325
1599
|
/** @type {HTMLPreElement} */
|
|
1326
|
-
|
|
1600
|
+
env.element
|
|
1327
1601
|
);
|
|
1328
|
-
if (
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1602
|
+
if (pre.matches(SELECTOR)) {
|
|
1603
|
+
env.code = "";
|
|
1604
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADING);
|
|
1605
|
+
var code = pre.appendChild(document.createElement("CODE"));
|
|
1606
|
+
code.textContent = LOADING_MESSAGE;
|
|
1607
|
+
var src = pre.getAttribute("data-src");
|
|
1608
|
+
var language = env.language;
|
|
1609
|
+
if (language === "none") {
|
|
1610
|
+
var extension = (/\.(\w+)$/.exec(src) || [, "none"])[1];
|
|
1611
|
+
language = EXTENSIONS[extension] || extension;
|
|
1336
1612
|
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1613
|
+
Prism2.util.setLanguage(code, language);
|
|
1614
|
+
Prism2.util.setLanguage(pre, language);
|
|
1615
|
+
var autoloader = Prism2.plugins.autoloader;
|
|
1616
|
+
if (autoloader) {
|
|
1617
|
+
autoloader.loadLanguages(language);
|
|
1618
|
+
}
|
|
1619
|
+
loadFile(
|
|
1620
|
+
src,
|
|
1621
|
+
function(text) {
|
|
1622
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
|
|
1623
|
+
var range = parseRange(pre.getAttribute("data-range"));
|
|
1624
|
+
if (range) {
|
|
1625
|
+
var lines = text.split(/\r\n?|\n/g);
|
|
1626
|
+
var start = range[0];
|
|
1627
|
+
var end = range[1] == null ? lines.length : range[1];
|
|
1628
|
+
if (start < 0) {
|
|
1629
|
+
start += lines.length;
|
|
1630
|
+
}
|
|
1631
|
+
start = Math.max(0, Math.min(start - 1, lines.length));
|
|
1632
|
+
if (end < 0) {
|
|
1633
|
+
end += lines.length;
|
|
1634
|
+
}
|
|
1635
|
+
end = Math.max(0, Math.min(end, lines.length));
|
|
1636
|
+
text = lines.slice(start, end).join("\n");
|
|
1637
|
+
if (!pre.hasAttribute("data-start")) {
|
|
1638
|
+
pre.setAttribute("data-start", String(start + 1));
|
|
1639
|
+
}
|
|
1348
1640
|
}
|
|
1349
|
-
|
|
1641
|
+
code.textContent = text;
|
|
1642
|
+
Prism2.highlightElement(code);
|
|
1350
1643
|
},
|
|
1351
|
-
function(
|
|
1352
|
-
|
|
1644
|
+
function(error) {
|
|
1645
|
+
pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
|
|
1646
|
+
code.textContent = error;
|
|
1353
1647
|
}
|
|
1354
1648
|
);
|
|
1355
1649
|
}
|
|
1356
|
-
})
|
|
1650
|
+
});
|
|
1651
|
+
Prism2.plugins.fileHighlight = {
|
|
1357
1652
|
/**
|
|
1358
1653
|
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
1359
1654
|
*
|
|
@@ -1361,71 +1656,77 @@ var Q = { exports: {} };
|
|
|
1361
1656
|
*
|
|
1362
1657
|
* @param {ParentNode} [container=document]
|
|
1363
1658
|
*/
|
|
1364
|
-
highlight: function(
|
|
1365
|
-
|
|
1366
|
-
|
|
1659
|
+
highlight: function highlight(container) {
|
|
1660
|
+
var elements = (container || document).querySelectorAll(SELECTOR);
|
|
1661
|
+
for (var i = 0, element; element = elements[i++]; ) {
|
|
1662
|
+
Prism2.highlightElement(element);
|
|
1663
|
+
}
|
|
1367
1664
|
}
|
|
1368
1665
|
};
|
|
1369
|
-
var
|
|
1370
|
-
|
|
1371
|
-
|
|
1666
|
+
var logged = false;
|
|
1667
|
+
Prism2.fileHighlight = function() {
|
|
1668
|
+
if (!logged) {
|
|
1669
|
+
console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.");
|
|
1670
|
+
logged = true;
|
|
1671
|
+
}
|
|
1672
|
+
Prism2.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1372
1673
|
};
|
|
1373
|
-
}();
|
|
1374
|
-
})(
|
|
1375
|
-
var
|
|
1376
|
-
const
|
|
1674
|
+
})();
|
|
1675
|
+
})(prism);
|
|
1676
|
+
var prismExports = prism.exports;
|
|
1677
|
+
const Prism$1 = /* @__PURE__ */ getDefaultExportFromCjs(prismExports);
|
|
1377
1678
|
Prism.languages.clike = {
|
|
1378
|
-
comment: [
|
|
1679
|
+
"comment": [
|
|
1379
1680
|
{
|
|
1380
1681
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1381
|
-
lookbehind:
|
|
1382
|
-
greedy:
|
|
1682
|
+
lookbehind: true,
|
|
1683
|
+
greedy: true
|
|
1383
1684
|
},
|
|
1384
1685
|
{
|
|
1385
1686
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
1386
|
-
lookbehind:
|
|
1387
|
-
greedy:
|
|
1687
|
+
lookbehind: true,
|
|
1688
|
+
greedy: true
|
|
1388
1689
|
}
|
|
1389
1690
|
],
|
|
1390
|
-
string: {
|
|
1691
|
+
"string": {
|
|
1391
1692
|
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1392
|
-
greedy:
|
|
1693
|
+
greedy: true
|
|
1393
1694
|
},
|
|
1394
1695
|
"class-name": {
|
|
1395
1696
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1396
|
-
lookbehind:
|
|
1697
|
+
lookbehind: true,
|
|
1397
1698
|
inside: {
|
|
1398
|
-
punctuation: /[.\\]/
|
|
1699
|
+
"punctuation": /[.\\]/
|
|
1399
1700
|
}
|
|
1400
1701
|
},
|
|
1401
|
-
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1402
|
-
boolean: /\b(?:false|true)\b/,
|
|
1403
|
-
function: /\b\w+(?=\()/,
|
|
1404
|
-
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1405
|
-
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1406
|
-
punctuation: /[{}[\];(),.:]/
|
|
1702
|
+
"keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1703
|
+
"boolean": /\b(?:false|true)\b/,
|
|
1704
|
+
"function": /\b\w+(?=\()/,
|
|
1705
|
+
"number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1706
|
+
"operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1707
|
+
"punctuation": /[{}[\];(),.:]/
|
|
1407
1708
|
};
|
|
1408
1709
|
Prism.languages.javascript = Prism.languages.extend("clike", {
|
|
1409
1710
|
"class-name": [
|
|
1410
1711
|
Prism.languages.clike["class-name"],
|
|
1411
1712
|
{
|
|
1412
1713
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1413
|
-
lookbehind:
|
|
1714
|
+
lookbehind: true
|
|
1414
1715
|
}
|
|
1415
1716
|
],
|
|
1416
|
-
keyword: [
|
|
1717
|
+
"keyword": [
|
|
1417
1718
|
{
|
|
1418
1719
|
pattern: /((?:^|\})\s*)catch\b/,
|
|
1419
|
-
lookbehind:
|
|
1720
|
+
lookbehind: true
|
|
1420
1721
|
},
|
|
1421
1722
|
{
|
|
1422
1723
|
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
1423
|
-
lookbehind:
|
|
1724
|
+
lookbehind: true
|
|
1424
1725
|
}
|
|
1425
1726
|
],
|
|
1426
1727
|
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1427
|
-
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1428
|
-
number: {
|
|
1728
|
+
"function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1729
|
+
"number": {
|
|
1429
1730
|
pattern: RegExp(
|
|
1430
1731
|
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1431
1732
|
(/NaN|Infinity/.source + "|" + // binary integer
|
|
@@ -1435,13 +1736,13 @@ Prism.languages.javascript = Prism.languages.extend("clike", {
|
|
|
1435
1736
|
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1436
1737
|
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1437
1738
|
),
|
|
1438
|
-
lookbehind:
|
|
1739
|
+
lookbehind: true
|
|
1439
1740
|
},
|
|
1440
|
-
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1741
|
+
"operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1441
1742
|
});
|
|
1442
1743
|
Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
1443
1744
|
Prism.languages.insertBefore("javascript", "keyword", {
|
|
1444
|
-
regex: {
|
|
1745
|
+
"regex": {
|
|
1445
1746
|
pattern: RegExp(
|
|
1446
1747
|
// lookbehind
|
|
1447
1748
|
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
@@ -1453,12 +1754,12 @@ Prism.languages.insertBefore("javascript", "keyword", {
|
|
|
1453
1754
|
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1454
1755
|
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1455
1756
|
),
|
|
1456
|
-
lookbehind:
|
|
1457
|
-
greedy:
|
|
1757
|
+
lookbehind: true,
|
|
1758
|
+
greedy: true,
|
|
1458
1759
|
inside: {
|
|
1459
1760
|
"regex-source": {
|
|
1460
1761
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1461
|
-
lookbehind:
|
|
1762
|
+
lookbehind: true,
|
|
1462
1763
|
alias: "language-regex",
|
|
1463
1764
|
inside: Prism.languages.regex
|
|
1464
1765
|
},
|
|
@@ -1471,47 +1772,47 @@ Prism.languages.insertBefore("javascript", "keyword", {
|
|
|
1471
1772
|
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
1472
1773
|
alias: "function"
|
|
1473
1774
|
},
|
|
1474
|
-
parameter: [
|
|
1775
|
+
"parameter": [
|
|
1475
1776
|
{
|
|
1476
1777
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1477
|
-
lookbehind:
|
|
1778
|
+
lookbehind: true,
|
|
1478
1779
|
inside: Prism.languages.javascript
|
|
1479
1780
|
},
|
|
1480
1781
|
{
|
|
1481
1782
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1482
|
-
lookbehind:
|
|
1783
|
+
lookbehind: true,
|
|
1483
1784
|
inside: Prism.languages.javascript
|
|
1484
1785
|
},
|
|
1485
1786
|
{
|
|
1486
1787
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1487
|
-
lookbehind:
|
|
1788
|
+
lookbehind: true,
|
|
1488
1789
|
inside: Prism.languages.javascript
|
|
1489
1790
|
},
|
|
1490
1791
|
{
|
|
1491
1792
|
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
1492
|
-
lookbehind:
|
|
1793
|
+
lookbehind: true,
|
|
1493
1794
|
inside: Prism.languages.javascript
|
|
1494
1795
|
}
|
|
1495
1796
|
],
|
|
1496
|
-
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1797
|
+
"constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1497
1798
|
});
|
|
1498
1799
|
Prism.languages.insertBefore("javascript", "string", {
|
|
1499
|
-
hashbang: {
|
|
1800
|
+
"hashbang": {
|
|
1500
1801
|
pattern: /^#!.*/,
|
|
1501
|
-
greedy:
|
|
1802
|
+
greedy: true,
|
|
1502
1803
|
alias: "comment"
|
|
1503
1804
|
},
|
|
1504
1805
|
"template-string": {
|
|
1505
1806
|
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1506
|
-
greedy:
|
|
1807
|
+
greedy: true,
|
|
1507
1808
|
inside: {
|
|
1508
1809
|
"template-punctuation": {
|
|
1509
1810
|
pattern: /^`|`$/,
|
|
1510
1811
|
alias: "string"
|
|
1511
1812
|
},
|
|
1512
|
-
interpolation: {
|
|
1813
|
+
"interpolation": {
|
|
1513
1814
|
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1514
|
-
lookbehind:
|
|
1815
|
+
lookbehind: true,
|
|
1515
1816
|
inside: {
|
|
1516
1817
|
"interpolation-punctuation": {
|
|
1517
1818
|
pattern: /^\$\{|\}$/,
|
|
@@ -1520,46 +1821,49 @@ Prism.languages.insertBefore("javascript", "string", {
|
|
|
1520
1821
|
rest: Prism.languages.javascript
|
|
1521
1822
|
}
|
|
1522
1823
|
},
|
|
1523
|
-
string: /[\s\S]+/
|
|
1824
|
+
"string": /[\s\S]+/
|
|
1524
1825
|
}
|
|
1525
1826
|
},
|
|
1526
1827
|
"string-property": {
|
|
1527
1828
|
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1528
|
-
lookbehind:
|
|
1529
|
-
greedy:
|
|
1829
|
+
lookbehind: true,
|
|
1830
|
+
greedy: true,
|
|
1530
1831
|
alias: "property"
|
|
1531
1832
|
}
|
|
1532
1833
|
});
|
|
1533
1834
|
Prism.languages.insertBefore("javascript", "operator", {
|
|
1534
1835
|
"literal-property": {
|
|
1535
1836
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1536
|
-
lookbehind:
|
|
1837
|
+
lookbehind: true,
|
|
1537
1838
|
alias: "property"
|
|
1538
1839
|
}
|
|
1539
1840
|
});
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
))
|
|
1841
|
+
if (Prism.languages.markup) {
|
|
1842
|
+
Prism.languages.markup.tag.addInlined("script", "javascript");
|
|
1843
|
+
Prism.languages.markup.tag.addAttribute(
|
|
1844
|
+
/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
|
|
1845
|
+
"javascript"
|
|
1846
|
+
);
|
|
1847
|
+
}
|
|
1544
1848
|
Prism.languages.js = Prism.languages.javascript;
|
|
1545
1849
|
Prism.languages.python = {
|
|
1546
|
-
comment: {
|
|
1850
|
+
"comment": {
|
|
1547
1851
|
pattern: /(^|[^\\])#.*/,
|
|
1548
|
-
lookbehind:
|
|
1549
|
-
greedy:
|
|
1852
|
+
lookbehind: true,
|
|
1853
|
+
greedy: true
|
|
1550
1854
|
},
|
|
1551
1855
|
"string-interpolation": {
|
|
1552
1856
|
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
1553
|
-
greedy:
|
|
1857
|
+
greedy: true,
|
|
1554
1858
|
inside: {
|
|
1555
|
-
interpolation: {
|
|
1859
|
+
"interpolation": {
|
|
1556
1860
|
// "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
|
1557
1861
|
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
1558
|
-
lookbehind:
|
|
1862
|
+
lookbehind: true,
|
|
1559
1863
|
inside: {
|
|
1560
1864
|
"format-spec": {
|
|
1561
1865
|
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
1562
|
-
lookbehind:
|
|
1866
|
+
lookbehind: true
|
|
1563
1867
|
},
|
|
1564
1868
|
"conversion-option": {
|
|
1565
1869
|
pattern: //,
|
|
@@ -1568,52 +1872,52 @@ Prism.languages.python = {
|
|
|
1568
1872
|
rest: null
|
|
1569
1873
|
}
|
|
1570
1874
|
},
|
|
1571
|
-
string: /[\s\S]+/
|
|
1875
|
+
"string": /[\s\S]+/
|
|
1572
1876
|
}
|
|
1573
1877
|
},
|
|
1574
1878
|
"triple-quoted-string": {
|
|
1575
1879
|
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
1576
|
-
greedy:
|
|
1880
|
+
greedy: true,
|
|
1577
1881
|
alias: "string"
|
|
1578
1882
|
},
|
|
1579
|
-
string: {
|
|
1883
|
+
"string": {
|
|
1580
1884
|
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
1581
|
-
greedy:
|
|
1885
|
+
greedy: true
|
|
1582
1886
|
},
|
|
1583
|
-
function: {
|
|
1887
|
+
"function": {
|
|
1584
1888
|
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
1585
|
-
lookbehind:
|
|
1889
|
+
lookbehind: true
|
|
1586
1890
|
},
|
|
1587
1891
|
"class-name": {
|
|
1588
1892
|
pattern: /(\bclass\s+)\w+/i,
|
|
1589
|
-
lookbehind:
|
|
1893
|
+
lookbehind: true
|
|
1590
1894
|
},
|
|
1591
|
-
decorator: {
|
|
1895
|
+
"decorator": {
|
|
1592
1896
|
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
1593
|
-
lookbehind:
|
|
1897
|
+
lookbehind: true,
|
|
1594
1898
|
alias: ["annotation", "punctuation"],
|
|
1595
1899
|
inside: {
|
|
1596
|
-
punctuation: /\./
|
|
1900
|
+
"punctuation": /\./
|
|
1597
1901
|
}
|
|
1598
1902
|
},
|
|
1599
|
-
keyword: /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
|
1600
|
-
builtin: /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
|
1601
|
-
boolean: /\b(?:False|None|True)\b/,
|
|
1602
|
-
number: /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
1603
|
-
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
1604
|
-
punctuation: /[{}[\];(),.:]/
|
|
1903
|
+
"keyword": /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
|
1904
|
+
"builtin": /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
|
1905
|
+
"boolean": /\b(?:False|None|True)\b/,
|
|
1906
|
+
"number": /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
1907
|
+
"operator": /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
1908
|
+
"punctuation": /[{}[\];(),.:]/
|
|
1605
1909
|
};
|
|
1606
|
-
Prism.languages.python["string-interpolation"].inside
|
|
1910
|
+
Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
|
|
1607
1911
|
Prism.languages.py = Prism.languages.python;
|
|
1608
1912
|
Prism.languages.go = Prism.languages.extend("clike", {
|
|
1609
|
-
string: {
|
|
1913
|
+
"string": {
|
|
1610
1914
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
|
|
1611
|
-
lookbehind:
|
|
1612
|
-
greedy:
|
|
1915
|
+
lookbehind: true,
|
|
1916
|
+
greedy: true
|
|
1613
1917
|
},
|
|
1614
|
-
keyword: /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
|
1615
|
-
boolean: /\b(?:_|false|iota|nil|true)\b/,
|
|
1616
|
-
number: [
|
|
1918
|
+
"keyword": /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
|
1919
|
+
"boolean": /\b(?:_|false|iota|nil|true)\b/,
|
|
1920
|
+
"number": [
|
|
1617
1921
|
// binary and octal integers
|
|
1618
1922
|
/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
|
|
1619
1923
|
// hexadecimal integers and floats
|
|
@@ -1621,195 +1925,199 @@ Prism.languages.go = Prism.languages.extend("clike", {
|
|
|
1621
1925
|
// decimal integers and floats
|
|
1622
1926
|
/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
|
|
1623
1927
|
],
|
|
1624
|
-
operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
1625
|
-
builtin: /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
|
|
1928
|
+
"operator": /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
1929
|
+
"builtin": /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
|
|
1626
1930
|
});
|
|
1627
1931
|
Prism.languages.insertBefore("go", "string", {
|
|
1628
|
-
char: {
|
|
1932
|
+
"char": {
|
|
1629
1933
|
pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
|
|
1630
|
-
greedy:
|
|
1934
|
+
greedy: true
|
|
1631
1935
|
}
|
|
1632
1936
|
});
|
|
1633
1937
|
delete Prism.languages.go["class-name"];
|
|
1634
|
-
(function(
|
|
1635
|
-
var
|
|
1636
|
-
|
|
1637
|
-
|
|
1938
|
+
(function(Prism2) {
|
|
1939
|
+
var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
|
|
1940
|
+
var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
|
|
1941
|
+
var className = {
|
|
1942
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
|
|
1943
|
+
lookbehind: true,
|
|
1638
1944
|
inside: {
|
|
1639
|
-
namespace: {
|
|
1945
|
+
"namespace": {
|
|
1640
1946
|
pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
|
|
1641
1947
|
inside: {
|
|
1642
|
-
punctuation: /\./
|
|
1948
|
+
"punctuation": /\./
|
|
1643
1949
|
}
|
|
1644
1950
|
},
|
|
1645
|
-
punctuation: /\./
|
|
1951
|
+
"punctuation": /\./
|
|
1646
1952
|
}
|
|
1647
1953
|
};
|
|
1648
|
-
|
|
1649
|
-
string: {
|
|
1954
|
+
Prism2.languages.java = Prism2.languages.extend("clike", {
|
|
1955
|
+
"string": {
|
|
1650
1956
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
|
|
1651
|
-
lookbehind:
|
|
1652
|
-
greedy:
|
|
1957
|
+
lookbehind: true,
|
|
1958
|
+
greedy: true
|
|
1653
1959
|
},
|
|
1654
1960
|
"class-name": [
|
|
1655
|
-
|
|
1961
|
+
className,
|
|
1656
1962
|
{
|
|
1657
1963
|
// variables, parameters, and constructor references
|
|
1658
1964
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
1659
|
-
pattern: RegExp(/(^|[^\w.])/.source +
|
|
1660
|
-
lookbehind:
|
|
1661
|
-
inside:
|
|
1965
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
|
|
1966
|
+
lookbehind: true,
|
|
1967
|
+
inside: className.inside
|
|
1662
1968
|
},
|
|
1663
1969
|
{
|
|
1664
1970
|
// class names based on keyword
|
|
1665
1971
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
1666
|
-
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source +
|
|
1667
|
-
lookbehind:
|
|
1668
|
-
inside:
|
|
1972
|
+
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
|
|
1973
|
+
lookbehind: true,
|
|
1974
|
+
inside: className.inside
|
|
1669
1975
|
}
|
|
1670
1976
|
],
|
|
1671
|
-
keyword:
|
|
1672
|
-
function: [
|
|
1673
|
-
|
|
1977
|
+
"keyword": keywords,
|
|
1978
|
+
"function": [
|
|
1979
|
+
Prism2.languages.clike.function,
|
|
1674
1980
|
{
|
|
1675
1981
|
pattern: /(::\s*)[a-z_]\w*/,
|
|
1676
|
-
lookbehind:
|
|
1982
|
+
lookbehind: true
|
|
1677
1983
|
}
|
|
1678
1984
|
],
|
|
1679
|
-
number: /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
|
1680
|
-
operator: {
|
|
1985
|
+
"number": /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
|
1986
|
+
"operator": {
|
|
1681
1987
|
pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
|
1682
|
-
lookbehind:
|
|
1988
|
+
lookbehind: true
|
|
1683
1989
|
},
|
|
1684
|
-
constant: /\b[A-Z][A-Z_\d]+\b/
|
|
1685
|
-
})
|
|
1990
|
+
"constant": /\b[A-Z][A-Z_\d]+\b/
|
|
1991
|
+
});
|
|
1992
|
+
Prism2.languages.insertBefore("java", "string", {
|
|
1686
1993
|
"triple-quoted-string": {
|
|
1687
1994
|
// http://openjdk.java.net/jeps/355#Description
|
|
1688
1995
|
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
1689
|
-
greedy:
|
|
1996
|
+
greedy: true,
|
|
1690
1997
|
alias: "string"
|
|
1691
1998
|
},
|
|
1692
|
-
char: {
|
|
1999
|
+
"char": {
|
|
1693
2000
|
pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
|
|
1694
|
-
greedy:
|
|
2001
|
+
greedy: true
|
|
1695
2002
|
}
|
|
1696
|
-
})
|
|
1697
|
-
|
|
2003
|
+
});
|
|
2004
|
+
Prism2.languages.insertBefore("java", "class-name", {
|
|
2005
|
+
"annotation": {
|
|
1698
2006
|
pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
|
|
1699
|
-
lookbehind:
|
|
2007
|
+
lookbehind: true,
|
|
1700
2008
|
alias: "punctuation"
|
|
1701
2009
|
},
|
|
1702
|
-
generics: {
|
|
2010
|
+
"generics": {
|
|
1703
2011
|
pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
|
|
1704
2012
|
inside: {
|
|
1705
|
-
"class-name":
|
|
1706
|
-
keyword:
|
|
1707
|
-
punctuation: /[<>(),.:]/,
|
|
1708
|
-
operator: /[?&|]/
|
|
2013
|
+
"class-name": className,
|
|
2014
|
+
"keyword": keywords,
|
|
2015
|
+
"punctuation": /[<>(),.:]/,
|
|
2016
|
+
"operator": /[?&|]/
|
|
1709
2017
|
}
|
|
1710
2018
|
},
|
|
1711
|
-
import: [
|
|
2019
|
+
"import": [
|
|
1712
2020
|
{
|
|
1713
|
-
pattern: RegExp(/(\bimport\s+)/.source +
|
|
1714
|
-
lookbehind:
|
|
2021
|
+
pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
|
|
2022
|
+
lookbehind: true,
|
|
1715
2023
|
inside: {
|
|
1716
|
-
namespace:
|
|
1717
|
-
punctuation: /\./,
|
|
1718
|
-
operator: /\*/,
|
|
2024
|
+
"namespace": className.inside.namespace,
|
|
2025
|
+
"punctuation": /\./,
|
|
2026
|
+
"operator": /\*/,
|
|
1719
2027
|
"class-name": /\w+/
|
|
1720
2028
|
}
|
|
1721
2029
|
},
|
|
1722
2030
|
{
|
|
1723
|
-
pattern: RegExp(/(\bimport\s+static\s+)/.source +
|
|
1724
|
-
lookbehind:
|
|
2031
|
+
pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
|
|
2032
|
+
lookbehind: true,
|
|
1725
2033
|
alias: "static",
|
|
1726
2034
|
inside: {
|
|
1727
|
-
namespace:
|
|
1728
|
-
static: /\b\w+$/,
|
|
1729
|
-
punctuation: /\./,
|
|
1730
|
-
operator: /\*/,
|
|
2035
|
+
"namespace": className.inside.namespace,
|
|
2036
|
+
"static": /\b\w+$/,
|
|
2037
|
+
"punctuation": /\./,
|
|
2038
|
+
"operator": /\*/,
|
|
1731
2039
|
"class-name": /\w+/
|
|
1732
2040
|
}
|
|
1733
2041
|
}
|
|
1734
2042
|
],
|
|
1735
|
-
namespace: {
|
|
2043
|
+
"namespace": {
|
|
1736
2044
|
pattern: RegExp(
|
|
1737
2045
|
/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function() {
|
|
1738
|
-
return
|
|
2046
|
+
return keywords.source;
|
|
1739
2047
|
})
|
|
1740
2048
|
),
|
|
1741
|
-
lookbehind:
|
|
2049
|
+
lookbehind: true,
|
|
1742
2050
|
inside: {
|
|
1743
|
-
punctuation: /\./
|
|
2051
|
+
"punctuation": /\./
|
|
1744
2052
|
}
|
|
1745
2053
|
}
|
|
1746
2054
|
});
|
|
1747
2055
|
})(Prism);
|
|
1748
2056
|
Prism.languages.c = Prism.languages.extend("clike", {
|
|
1749
|
-
comment: {
|
|
2057
|
+
"comment": {
|
|
1750
2058
|
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1751
|
-
greedy:
|
|
2059
|
+
greedy: true
|
|
1752
2060
|
},
|
|
1753
|
-
string: {
|
|
2061
|
+
"string": {
|
|
1754
2062
|
// https://en.cppreference.com/w/c/language/string_literal
|
|
1755
2063
|
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
1756
|
-
greedy:
|
|
2064
|
+
greedy: true
|
|
1757
2065
|
},
|
|
1758
2066
|
"class-name": {
|
|
1759
2067
|
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
1760
|
-
lookbehind:
|
|
2068
|
+
lookbehind: true
|
|
1761
2069
|
},
|
|
1762
|
-
keyword: /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
|
1763
|
-
function: /\b[a-z_]\w*(?=\s*\()/i,
|
|
1764
|
-
number: /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
1765
|
-
operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
2070
|
+
"keyword": /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
|
2071
|
+
"function": /\b[a-z_]\w*(?=\s*\()/i,
|
|
2072
|
+
"number": /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
2073
|
+
"operator": />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
1766
2074
|
});
|
|
1767
2075
|
Prism.languages.insertBefore("c", "string", {
|
|
1768
|
-
char: {
|
|
2076
|
+
"char": {
|
|
1769
2077
|
// https://en.cppreference.com/w/c/language/character_constant
|
|
1770
2078
|
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
1771
|
-
greedy:
|
|
2079
|
+
greedy: true
|
|
1772
2080
|
}
|
|
1773
2081
|
});
|
|
1774
2082
|
Prism.languages.insertBefore("c", "string", {
|
|
1775
|
-
macro: {
|
|
2083
|
+
"macro": {
|
|
1776
2084
|
// allow for multiline macro definitions
|
|
1777
2085
|
// spaces after the # character compile fine with gcc
|
|
1778
2086
|
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
1779
|
-
lookbehind:
|
|
1780
|
-
greedy:
|
|
2087
|
+
lookbehind: true,
|
|
2088
|
+
greedy: true,
|
|
1781
2089
|
alias: "property",
|
|
1782
2090
|
inside: {
|
|
1783
|
-
string: [
|
|
2091
|
+
"string": [
|
|
1784
2092
|
{
|
|
1785
2093
|
// highlight the path of the include statement as a string
|
|
1786
2094
|
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
1787
|
-
lookbehind:
|
|
2095
|
+
lookbehind: true
|
|
1788
2096
|
},
|
|
1789
|
-
Prism.languages.c
|
|
2097
|
+
Prism.languages.c["string"]
|
|
1790
2098
|
],
|
|
1791
|
-
char: Prism.languages.c
|
|
1792
|
-
comment: Prism.languages.c
|
|
2099
|
+
"char": Prism.languages.c["char"],
|
|
2100
|
+
"comment": Prism.languages.c["comment"],
|
|
1793
2101
|
"macro-name": [
|
|
1794
2102
|
{
|
|
1795
2103
|
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
1796
|
-
lookbehind:
|
|
2104
|
+
lookbehind: true
|
|
1797
2105
|
},
|
|
1798
2106
|
{
|
|
1799
2107
|
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
1800
|
-
lookbehind:
|
|
2108
|
+
lookbehind: true,
|
|
1801
2109
|
alias: "function"
|
|
1802
2110
|
}
|
|
1803
2111
|
],
|
|
1804
2112
|
// highlight macro directives as keywords
|
|
1805
|
-
directive: {
|
|
2113
|
+
"directive": {
|
|
1806
2114
|
pattern: /^(#\s*)[a-z]+/,
|
|
1807
|
-
lookbehind:
|
|
2115
|
+
lookbehind: true,
|
|
1808
2116
|
alias: "keyword"
|
|
1809
2117
|
},
|
|
1810
2118
|
"directive-hash": /^#/,
|
|
1811
|
-
punctuation: /##|\\(?=[\r\n])/,
|
|
1812
|
-
expression: {
|
|
2119
|
+
"punctuation": /##|\\(?=[\r\n])/,
|
|
2120
|
+
"expression": {
|
|
1813
2121
|
pattern: /\S[\s\S]*/,
|
|
1814
2122
|
inside: Prism.languages.c
|
|
1815
2123
|
}
|
|
@@ -1818,51 +2126,54 @@ Prism.languages.insertBefore("c", "string", {
|
|
|
1818
2126
|
});
|
|
1819
2127
|
Prism.languages.insertBefore("c", "function", {
|
|
1820
2128
|
// highlight predefined macros as constants
|
|
1821
|
-
constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
2129
|
+
"constant": /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
1822
2130
|
});
|
|
1823
|
-
delete Prism.languages.c
|
|
1824
|
-
(function(
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
2131
|
+
delete Prism.languages.c["boolean"];
|
|
2132
|
+
(function(Prism2) {
|
|
2133
|
+
var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
|
|
2134
|
+
for (var i = 0; i < 2; i++) {
|
|
2135
|
+
multilineComment = multilineComment.replace(/<self>/g, function() {
|
|
2136
|
+
return multilineComment;
|
|
1828
2137
|
});
|
|
1829
|
-
|
|
2138
|
+
}
|
|
2139
|
+
multilineComment = multilineComment.replace(/<self>/g, function() {
|
|
1830
2140
|
return /[^\s\S]/.source;
|
|
1831
|
-
})
|
|
1832
|
-
|
|
2141
|
+
});
|
|
2142
|
+
Prism2.languages.rust = {
|
|
2143
|
+
"comment": [
|
|
1833
2144
|
{
|
|
1834
|
-
pattern: RegExp(/(^|[^\\])/.source +
|
|
1835
|
-
lookbehind:
|
|
1836
|
-
greedy:
|
|
2145
|
+
pattern: RegExp(/(^|[^\\])/.source + multilineComment),
|
|
2146
|
+
lookbehind: true,
|
|
2147
|
+
greedy: true
|
|
1837
2148
|
},
|
|
1838
2149
|
{
|
|
1839
2150
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
1840
|
-
lookbehind:
|
|
1841
|
-
greedy:
|
|
2151
|
+
lookbehind: true,
|
|
2152
|
+
greedy: true
|
|
1842
2153
|
}
|
|
1843
2154
|
],
|
|
1844
|
-
string: {
|
|
2155
|
+
"string": {
|
|
1845
2156
|
pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
|
|
1846
|
-
greedy:
|
|
2157
|
+
greedy: true
|
|
1847
2158
|
},
|
|
1848
|
-
char: {
|
|
2159
|
+
"char": {
|
|
1849
2160
|
pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
|
|
1850
|
-
greedy:
|
|
2161
|
+
greedy: true
|
|
1851
2162
|
},
|
|
1852
|
-
attribute: {
|
|
2163
|
+
"attribute": {
|
|
1853
2164
|
pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
|
|
1854
|
-
greedy:
|
|
2165
|
+
greedy: true,
|
|
1855
2166
|
alias: "attr-name",
|
|
1856
2167
|
inside: {
|
|
1857
|
-
string: null
|
|
2168
|
+
"string": null
|
|
1858
2169
|
// see below
|
|
1859
2170
|
}
|
|
1860
2171
|
},
|
|
1861
2172
|
// Closure params should not be confused with bitwise OR |
|
|
1862
2173
|
"closure-params": {
|
|
1863
2174
|
pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
|
|
1864
|
-
lookbehind:
|
|
1865
|
-
greedy:
|
|
2175
|
+
lookbehind: true,
|
|
2176
|
+
greedy: true,
|
|
1866
2177
|
inside: {
|
|
1867
2178
|
"closure-punctuation": {
|
|
1868
2179
|
pattern: /^\||\|$/,
|
|
@@ -1878,36 +2189,36 @@ delete Prism.languages.c.boolean;
|
|
|
1878
2189
|
},
|
|
1879
2190
|
"fragment-specifier": {
|
|
1880
2191
|
pattern: /(\$\w+:)[a-z]+/,
|
|
1881
|
-
lookbehind:
|
|
2192
|
+
lookbehind: true,
|
|
1882
2193
|
alias: "punctuation"
|
|
1883
2194
|
},
|
|
1884
|
-
variable: /\$\w+/,
|
|
2195
|
+
"variable": /\$\w+/,
|
|
1885
2196
|
"function-definition": {
|
|
1886
2197
|
pattern: /(\bfn\s+)\w+/,
|
|
1887
|
-
lookbehind:
|
|
2198
|
+
lookbehind: true,
|
|
1888
2199
|
alias: "function"
|
|
1889
2200
|
},
|
|
1890
2201
|
"type-definition": {
|
|
1891
2202
|
pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
|
|
1892
|
-
lookbehind:
|
|
2203
|
+
lookbehind: true,
|
|
1893
2204
|
alias: "class-name"
|
|
1894
2205
|
},
|
|
1895
2206
|
"module-declaration": [
|
|
1896
2207
|
{
|
|
1897
2208
|
pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
|
|
1898
|
-
lookbehind:
|
|
2209
|
+
lookbehind: true,
|
|
1899
2210
|
alias: "namespace"
|
|
1900
2211
|
},
|
|
1901
2212
|
{
|
|
1902
2213
|
pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
|
|
1903
|
-
lookbehind:
|
|
2214
|
+
lookbehind: true,
|
|
1904
2215
|
alias: "namespace",
|
|
1905
2216
|
inside: {
|
|
1906
|
-
punctuation: /::/
|
|
2217
|
+
"punctuation": /::/
|
|
1907
2218
|
}
|
|
1908
2219
|
}
|
|
1909
2220
|
],
|
|
1910
|
-
keyword: [
|
|
2221
|
+
"keyword": [
|
|
1911
2222
|
// https://github.com/rust-lang/reference/blob/master/src/keywords.md
|
|
1912
2223
|
/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
|
|
1913
2224
|
// primitives and str
|
|
@@ -1917,112 +2228,116 @@ delete Prism.languages.c.boolean;
|
|
|
1917
2228
|
// functions can technically start with an upper-case letter, but this will introduce a lot of false positives
|
|
1918
2229
|
// and Rust's naming conventions recommend snake_case anyway.
|
|
1919
2230
|
// https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
|
|
1920
|
-
function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
1921
|
-
macro: {
|
|
2231
|
+
"function": /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
2232
|
+
"macro": {
|
|
1922
2233
|
pattern: /\b\w+!/,
|
|
1923
2234
|
alias: "property"
|
|
1924
2235
|
},
|
|
1925
|
-
constant: /\b[A-Z_][A-Z_\d]+\b/,
|
|
2236
|
+
"constant": /\b[A-Z_][A-Z_\d]+\b/,
|
|
1926
2237
|
"class-name": /\b[A-Z]\w*\b/,
|
|
1927
|
-
namespace: {
|
|
2238
|
+
"namespace": {
|
|
1928
2239
|
pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
|
|
1929
2240
|
inside: {
|
|
1930
|
-
punctuation: /::/
|
|
2241
|
+
"punctuation": /::/
|
|
1931
2242
|
}
|
|
1932
2243
|
},
|
|
1933
2244
|
// Hex, oct, bin, dec numbers with visual separators and type suffix
|
|
1934
|
-
number: /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
|
|
1935
|
-
boolean: /\b(?:false|true)\b/,
|
|
1936
|
-
punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
1937
|
-
operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
1938
|
-
}
|
|
2245
|
+
"number": /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
|
|
2246
|
+
"boolean": /\b(?:false|true)\b/,
|
|
2247
|
+
"punctuation": /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
2248
|
+
"operator": /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
2249
|
+
};
|
|
2250
|
+
Prism2.languages.rust["closure-params"].inside.rest = Prism2.languages.rust;
|
|
2251
|
+
Prism2.languages.rust["attribute"].inside["string"] = Prism2.languages.rust["string"];
|
|
1939
2252
|
})(Prism);
|
|
1940
2253
|
Prism.languages.sql = {
|
|
1941
|
-
comment: {
|
|
2254
|
+
"comment": {
|
|
1942
2255
|
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
|
1943
|
-
lookbehind:
|
|
2256
|
+
lookbehind: true
|
|
1944
2257
|
},
|
|
1945
|
-
variable: [
|
|
2258
|
+
"variable": [
|
|
1946
2259
|
{
|
|
1947
2260
|
pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
|
|
1948
|
-
greedy:
|
|
2261
|
+
greedy: true
|
|
1949
2262
|
},
|
|
1950
2263
|
/@[\w.$]+/
|
|
1951
2264
|
],
|
|
1952
|
-
string: {
|
|
2265
|
+
"string": {
|
|
1953
2266
|
pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
|
|
1954
|
-
greedy:
|
|
1955
|
-
lookbehind:
|
|
2267
|
+
greedy: true,
|
|
2268
|
+
lookbehind: true
|
|
1956
2269
|
},
|
|
1957
|
-
identifier: {
|
|
2270
|
+
"identifier": {
|
|
1958
2271
|
pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
|
|
1959
|
-
greedy:
|
|
1960
|
-
lookbehind:
|
|
2272
|
+
greedy: true,
|
|
2273
|
+
lookbehind: true,
|
|
1961
2274
|
inside: {
|
|
1962
|
-
punctuation: /^`|`$/
|
|
2275
|
+
"punctuation": /^`|`$/
|
|
1963
2276
|
}
|
|
1964
2277
|
},
|
|
1965
|
-
function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
2278
|
+
"function": /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
1966
2279
|
// Should we highlight user defined functions too?
|
|
1967
|
-
keyword: /\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(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|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(?:ING|S)?|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/i,
|
|
1968
|
-
boolean: /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
1969
|
-
number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
1970
|
-
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
1971
|
-
punctuation: /[;[\]()`,.]/
|
|
2280
|
+
"keyword": /\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(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|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(?:ING|S)?|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/i,
|
|
2281
|
+
"boolean": /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
2282
|
+
"number": /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
2283
|
+
"operator": /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
2284
|
+
"punctuation": /[;[\]()`,.]/
|
|
1972
2285
|
};
|
|
1973
|
-
(function(
|
|
1974
|
-
var
|
|
2286
|
+
(function(Prism2) {
|
|
2287
|
+
var envVars = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b";
|
|
2288
|
+
var commandAfterHeredoc = {
|
|
1975
2289
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
1976
|
-
lookbehind:
|
|
2290
|
+
lookbehind: true,
|
|
1977
2291
|
alias: "punctuation",
|
|
1978
2292
|
// this looks reasonably well in all themes
|
|
1979
2293
|
inside: null
|
|
1980
2294
|
// see below
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2295
|
+
};
|
|
2296
|
+
var insideString = {
|
|
2297
|
+
"bash": commandAfterHeredoc,
|
|
2298
|
+
"environment": {
|
|
2299
|
+
pattern: RegExp("\\$" + envVars),
|
|
1985
2300
|
alias: "constant"
|
|
1986
2301
|
},
|
|
1987
|
-
variable: [
|
|
2302
|
+
"variable": [
|
|
1988
2303
|
// [0]: Arithmetic Environment
|
|
1989
2304
|
{
|
|
1990
2305
|
pattern: /\$?\(\([\s\S]+?\)\)/,
|
|
1991
|
-
greedy:
|
|
2306
|
+
greedy: true,
|
|
1992
2307
|
inside: {
|
|
1993
2308
|
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
|
1994
|
-
variable: [
|
|
2309
|
+
"variable": [
|
|
1995
2310
|
{
|
|
1996
2311
|
pattern: /(^\$\(\([\s\S]+)\)\)/,
|
|
1997
|
-
lookbehind:
|
|
2312
|
+
lookbehind: true
|
|
1998
2313
|
},
|
|
1999
2314
|
/^\$\(\(/
|
|
2000
2315
|
],
|
|
2001
|
-
number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
2316
|
+
"number": /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
2002
2317
|
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
|
2003
|
-
operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
2318
|
+
"operator": /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
2004
2319
|
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
|
2005
|
-
punctuation: /\(\(?|\)\)?|,|;/
|
|
2320
|
+
"punctuation": /\(\(?|\)\)?|,|;/
|
|
2006
2321
|
}
|
|
2007
2322
|
},
|
|
2008
2323
|
// [1]: Command Substitution
|
|
2009
2324
|
{
|
|
2010
2325
|
pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
|
2011
|
-
greedy:
|
|
2326
|
+
greedy: true,
|
|
2012
2327
|
inside: {
|
|
2013
|
-
variable: /^\$\(|^`|\)$|`$/
|
|
2328
|
+
"variable": /^\$\(|^`|\)$|`$/
|
|
2014
2329
|
}
|
|
2015
2330
|
},
|
|
2016
2331
|
// [2]: Brace expansion
|
|
2017
2332
|
{
|
|
2018
2333
|
pattern: /\$\{[^}]+\}/,
|
|
2019
|
-
greedy:
|
|
2334
|
+
greedy: true,
|
|
2020
2335
|
inside: {
|
|
2021
|
-
operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
2022
|
-
punctuation: /[\[\]]/,
|
|
2023
|
-
environment: {
|
|
2024
|
-
pattern: RegExp("(\\{)" +
|
|
2025
|
-
lookbehind:
|
|
2336
|
+
"operator": /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
2337
|
+
"punctuation": /[\[\]]/,
|
|
2338
|
+
"environment": {
|
|
2339
|
+
pattern: RegExp("(\\{)" + envVars),
|
|
2340
|
+
lookbehind: true,
|
|
2026
2341
|
alias: "constant"
|
|
2027
2342
|
}
|
|
2028
2343
|
}
|
|
@@ -2030,16 +2345,16 @@ Prism.languages.sql = {
|
|
|
2030
2345
|
/\$(?:\w+|[#?*!@$])/
|
|
2031
2346
|
],
|
|
2032
2347
|
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
2033
|
-
entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
2348
|
+
"entity": /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
2034
2349
|
};
|
|
2035
|
-
|
|
2036
|
-
shebang: {
|
|
2350
|
+
Prism2.languages.bash = {
|
|
2351
|
+
"shebang": {
|
|
2037
2352
|
pattern: /^#!\s*\/.*/,
|
|
2038
2353
|
alias: "important"
|
|
2039
2354
|
},
|
|
2040
|
-
comment: {
|
|
2355
|
+
"comment": {
|
|
2041
2356
|
pattern: /(^|[^"{\\$])#.*/,
|
|
2042
|
-
lookbehind:
|
|
2357
|
+
lookbehind: true
|
|
2043
2358
|
},
|
|
2044
2359
|
"function-name": [
|
|
2045
2360
|
// a) function foo {
|
|
@@ -2049,7 +2364,7 @@ Prism.languages.sql = {
|
|
|
2049
2364
|
{
|
|
2050
2365
|
// a) and c)
|
|
2051
2366
|
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
|
2052
|
-
lookbehind:
|
|
2367
|
+
lookbehind: true,
|
|
2053
2368
|
alias: "function"
|
|
2054
2369
|
},
|
|
2055
2370
|
{
|
|
@@ -2062,98 +2377,98 @@ Prism.languages.sql = {
|
|
|
2062
2377
|
"for-or-select": {
|
|
2063
2378
|
pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
|
2064
2379
|
alias: "variable",
|
|
2065
|
-
lookbehind:
|
|
2380
|
+
lookbehind: true
|
|
2066
2381
|
},
|
|
2067
2382
|
// Highlight variable names as variables in the left-hand part
|
|
2068
2383
|
// of assignments (“=” and “+=”).
|
|
2069
2384
|
"assign-left": {
|
|
2070
2385
|
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
2071
2386
|
inside: {
|
|
2072
|
-
environment: {
|
|
2073
|
-
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" +
|
|
2074
|
-
lookbehind:
|
|
2387
|
+
"environment": {
|
|
2388
|
+
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
|
|
2389
|
+
lookbehind: true,
|
|
2075
2390
|
alias: "constant"
|
|
2076
2391
|
}
|
|
2077
2392
|
},
|
|
2078
2393
|
alias: "variable",
|
|
2079
|
-
lookbehind:
|
|
2394
|
+
lookbehind: true
|
|
2080
2395
|
},
|
|
2081
2396
|
// Highlight parameter names as variables
|
|
2082
|
-
parameter: {
|
|
2397
|
+
"parameter": {
|
|
2083
2398
|
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
|
|
2084
2399
|
alias: "variable",
|
|
2085
|
-
lookbehind:
|
|
2400
|
+
lookbehind: true
|
|
2086
2401
|
},
|
|
2087
|
-
string: [
|
|
2402
|
+
"string": [
|
|
2088
2403
|
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
|
|
2089
2404
|
{
|
|
2090
2405
|
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
2091
|
-
lookbehind:
|
|
2092
|
-
greedy:
|
|
2093
|
-
inside:
|
|
2406
|
+
lookbehind: true,
|
|
2407
|
+
greedy: true,
|
|
2408
|
+
inside: insideString
|
|
2094
2409
|
},
|
|
2095
2410
|
// Here-document with quotes around the tag
|
|
2096
2411
|
// → No expansion (so no “inside”).
|
|
2097
2412
|
{
|
|
2098
2413
|
pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
|
2099
|
-
lookbehind:
|
|
2100
|
-
greedy:
|
|
2414
|
+
lookbehind: true,
|
|
2415
|
+
greedy: true,
|
|
2101
2416
|
inside: {
|
|
2102
|
-
bash:
|
|
2417
|
+
"bash": commandAfterHeredoc
|
|
2103
2418
|
}
|
|
2104
2419
|
},
|
|
2105
2420
|
// “Normal” string
|
|
2106
2421
|
{
|
|
2107
2422
|
// https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
|
|
2108
2423
|
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
2109
|
-
lookbehind:
|
|
2110
|
-
greedy:
|
|
2111
|
-
inside:
|
|
2424
|
+
lookbehind: true,
|
|
2425
|
+
greedy: true,
|
|
2426
|
+
inside: insideString
|
|
2112
2427
|
},
|
|
2113
2428
|
{
|
|
2114
2429
|
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
2115
2430
|
pattern: /(^|[^$\\])'[^']*'/,
|
|
2116
|
-
lookbehind:
|
|
2117
|
-
greedy:
|
|
2431
|
+
lookbehind: true,
|
|
2432
|
+
greedy: true
|
|
2118
2433
|
},
|
|
2119
2434
|
{
|
|
2120
2435
|
// https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
|
|
2121
2436
|
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
2122
|
-
greedy:
|
|
2437
|
+
greedy: true,
|
|
2123
2438
|
inside: {
|
|
2124
|
-
entity:
|
|
2439
|
+
"entity": insideString.entity
|
|
2125
2440
|
}
|
|
2126
2441
|
}
|
|
2127
2442
|
],
|
|
2128
|
-
environment: {
|
|
2129
|
-
pattern: RegExp("\\$?" +
|
|
2443
|
+
"environment": {
|
|
2444
|
+
pattern: RegExp("\\$?" + envVars),
|
|
2130
2445
|
alias: "constant"
|
|
2131
2446
|
},
|
|
2132
|
-
variable:
|
|
2133
|
-
function: {
|
|
2447
|
+
"variable": insideString.variable,
|
|
2448
|
+
"function": {
|
|
2134
2449
|
pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
|
|
2135
|
-
lookbehind:
|
|
2450
|
+
lookbehind: true
|
|
2136
2451
|
},
|
|
2137
|
-
keyword: {
|
|
2452
|
+
"keyword": {
|
|
2138
2453
|
pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
|
2139
|
-
lookbehind:
|
|
2454
|
+
lookbehind: true
|
|
2140
2455
|
},
|
|
2141
2456
|
// https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
|
2142
|
-
builtin: {
|
|
2457
|
+
"builtin": {
|
|
2143
2458
|
pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
|
|
2144
|
-
lookbehind:
|
|
2459
|
+
lookbehind: true,
|
|
2145
2460
|
// Alias added to make those easier to distinguish from strings.
|
|
2146
2461
|
alias: "class-name"
|
|
2147
2462
|
},
|
|
2148
|
-
boolean: {
|
|
2463
|
+
"boolean": {
|
|
2149
2464
|
pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
|
|
2150
|
-
lookbehind:
|
|
2465
|
+
lookbehind: true
|
|
2151
2466
|
},
|
|
2152
2467
|
"file-descriptor": {
|
|
2153
2468
|
pattern: /\B&\d\b/,
|
|
2154
2469
|
alias: "important"
|
|
2155
2470
|
},
|
|
2156
|
-
operator: {
|
|
2471
|
+
"operator": {
|
|
2157
2472
|
// Lots of redirections here, but not just that.
|
|
2158
2473
|
pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
|
2159
2474
|
inside: {
|
|
@@ -2163,13 +2478,14 @@ Prism.languages.sql = {
|
|
|
2163
2478
|
}
|
|
2164
2479
|
}
|
|
2165
2480
|
},
|
|
2166
|
-
punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
2167
|
-
number: {
|
|
2481
|
+
"punctuation": /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
2482
|
+
"number": {
|
|
2168
2483
|
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
2169
|
-
lookbehind:
|
|
2484
|
+
lookbehind: true
|
|
2170
2485
|
}
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2486
|
+
};
|
|
2487
|
+
commandAfterHeredoc.inside = Prism2.languages.bash;
|
|
2488
|
+
var toBeCopied = [
|
|
2173
2489
|
"comment",
|
|
2174
2490
|
"function-name",
|
|
2175
2491
|
"for-or-select",
|
|
@@ -2185,36 +2501,40 @@ Prism.languages.sql = {
|
|
|
2185
2501
|
"operator",
|
|
2186
2502
|
"punctuation",
|
|
2187
2503
|
"number"
|
|
2188
|
-
]
|
|
2189
|
-
|
|
2190
|
-
|
|
2504
|
+
];
|
|
2505
|
+
var inside = insideString.variable[1].inside;
|
|
2506
|
+
for (var i = 0; i < toBeCopied.length; i++) {
|
|
2507
|
+
inside[toBeCopied[i]] = Prism2.languages.bash[toBeCopied[i]];
|
|
2508
|
+
}
|
|
2509
|
+
Prism2.languages.sh = Prism2.languages.bash;
|
|
2510
|
+
Prism2.languages.shell = Prism2.languages.bash;
|
|
2191
2511
|
})(Prism);
|
|
2192
2512
|
Prism.languages.json = {
|
|
2193
|
-
property: {
|
|
2513
|
+
"property": {
|
|
2194
2514
|
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
2195
|
-
lookbehind:
|
|
2196
|
-
greedy:
|
|
2515
|
+
lookbehind: true,
|
|
2516
|
+
greedy: true
|
|
2197
2517
|
},
|
|
2198
|
-
string: {
|
|
2518
|
+
"string": {
|
|
2199
2519
|
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
|
2200
|
-
lookbehind:
|
|
2201
|
-
greedy:
|
|
2520
|
+
lookbehind: true,
|
|
2521
|
+
greedy: true
|
|
2202
2522
|
},
|
|
2203
|
-
comment: {
|
|
2523
|
+
"comment": {
|
|
2204
2524
|
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2205
|
-
greedy:
|
|
2525
|
+
greedy: true
|
|
2206
2526
|
},
|
|
2207
|
-
number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
2208
|
-
punctuation: /[{}[\],]/,
|
|
2209
|
-
operator: /:/,
|
|
2210
|
-
boolean: /\b(?:false|true)\b/,
|
|
2211
|
-
null: {
|
|
2527
|
+
"number": /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
2528
|
+
"punctuation": /[{}[\],]/,
|
|
2529
|
+
"operator": /:/,
|
|
2530
|
+
"boolean": /\b(?:false|true)\b/,
|
|
2531
|
+
"null": {
|
|
2212
2532
|
pattern: /\bnull\b/,
|
|
2213
2533
|
alias: "keyword"
|
|
2214
2534
|
}
|
|
2215
2535
|
};
|
|
2216
2536
|
Prism.languages.webmanifest = Prism.languages.json;
|
|
2217
|
-
const
|
|
2537
|
+
const prismDarkTheme = `
|
|
2218
2538
|
/* 默认代码颜色 */
|
|
2219
2539
|
.hep-cr-editor .hep-cr-highlight code,
|
|
2220
2540
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -2298,7 +2618,8 @@ const ce = `
|
|
|
2298
2618
|
.hep-cr-editor .token.console {
|
|
2299
2619
|
color: #f8f8f2 !important;
|
|
2300
2620
|
}
|
|
2301
|
-
|
|
2621
|
+
`;
|
|
2622
|
+
const prismLightTheme = `
|
|
2302
2623
|
/* 默认代码颜色 */
|
|
2303
2624
|
.hep-cr-editor .hep-cr-highlight code,
|
|
2304
2625
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -2376,15 +2697,25 @@ const ce = `
|
|
|
2376
2697
|
color: #333 !important;
|
|
2377
2698
|
}
|
|
2378
2699
|
`;
|
|
2379
|
-
function
|
|
2380
|
-
var
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
options
|
|
2700
|
+
function normalizeComponent(scriptExports, render4, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
2701
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
2702
|
+
if (render4) {
|
|
2703
|
+
options.render = render4;
|
|
2704
|
+
options.staticRenderFns = staticRenderFns;
|
|
2705
|
+
options._compiled = true;
|
|
2706
|
+
}
|
|
2707
|
+
if (scopeId) {
|
|
2708
|
+
options._scopeId = "data-v-" + scopeId;
|
|
2709
|
+
}
|
|
2710
|
+
return {
|
|
2711
|
+
exports: scriptExports,
|
|
2712
|
+
options
|
|
2384
2713
|
};
|
|
2385
2714
|
}
|
|
2386
|
-
typeof window
|
|
2387
|
-
|
|
2715
|
+
if (typeof window !== "undefined") {
|
|
2716
|
+
window.Prism = Prism$1;
|
|
2717
|
+
}
|
|
2718
|
+
const _sfc_main$2 = {
|
|
2388
2719
|
name: "CodeEditor",
|
|
2389
2720
|
props: {
|
|
2390
2721
|
value: {
|
|
@@ -2401,7 +2732,7 @@ const pe = {
|
|
|
2401
2732
|
},
|
|
2402
2733
|
disabled: {
|
|
2403
2734
|
type: Boolean,
|
|
2404
|
-
default:
|
|
2735
|
+
default: false
|
|
2405
2736
|
}
|
|
2406
2737
|
},
|
|
2407
2738
|
data: function() {
|
|
@@ -2414,8 +2745,8 @@ const pe = {
|
|
|
2414
2745
|
this.loadPrismTheme(this.theme);
|
|
2415
2746
|
},
|
|
2416
2747
|
watch: {
|
|
2417
|
-
theme(
|
|
2418
|
-
this.loadPrismTheme(
|
|
2748
|
+
theme(newTheme) {
|
|
2749
|
+
this.loadPrismTheme(newTheme);
|
|
2419
2750
|
}
|
|
2420
2751
|
},
|
|
2421
2752
|
computed: {
|
|
@@ -2461,69 +2792,97 @@ const pe = {
|
|
|
2461
2792
|
},
|
|
2462
2793
|
highlightedCode: function() {
|
|
2463
2794
|
try {
|
|
2464
|
-
var
|
|
2465
|
-
if (
|
|
2466
|
-
return
|
|
2795
|
+
var grammar = Prism$1.languages[this.prismLanguage];
|
|
2796
|
+
if (grammar) {
|
|
2797
|
+
return Prism$1.highlight(
|
|
2467
2798
|
this.value || "",
|
|
2468
|
-
|
|
2799
|
+
grammar,
|
|
2469
2800
|
this.prismLanguage
|
|
2470
2801
|
);
|
|
2471
|
-
|
|
2802
|
+
}
|
|
2803
|
+
} catch (e) {
|
|
2472
2804
|
}
|
|
2473
2805
|
return this.escapeHtml(this.value || "");
|
|
2474
2806
|
}
|
|
2475
2807
|
},
|
|
2476
2808
|
methods: {
|
|
2477
|
-
loadPrismTheme(
|
|
2478
|
-
const
|
|
2479
|
-
|
|
2480
|
-
const
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
},
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2809
|
+
loadPrismTheme(theme) {
|
|
2810
|
+
const styleId = "hep-cr-prism-styles";
|
|
2811
|
+
const oldStyleEl = document.getElementById(styleId);
|
|
2812
|
+
const themeContent = theme === "dark" ? prismDarkTheme : prismLightTheme;
|
|
2813
|
+
if (oldStyleEl) {
|
|
2814
|
+
oldStyleEl.remove();
|
|
2815
|
+
}
|
|
2816
|
+
const styleEl = document.createElement("style");
|
|
2817
|
+
styleEl.id = styleId;
|
|
2818
|
+
styleEl.textContent = themeContent;
|
|
2819
|
+
document.head.appendChild(styleEl);
|
|
2820
|
+
},
|
|
2821
|
+
escapeHtml: function(text) {
|
|
2822
|
+
var div = document.createElement("div");
|
|
2823
|
+
div.textContent = text;
|
|
2824
|
+
return div.innerHTML;
|
|
2825
|
+
},
|
|
2826
|
+
handleInput: function(e) {
|
|
2827
|
+
this.$emit("input", e.target.value);
|
|
2828
|
+
this.$emit("update:value", e.target.value);
|
|
2829
|
+
this.emitChange(e.target.value);
|
|
2830
|
+
},
|
|
2831
|
+
handleScroll: function(e) {
|
|
2832
|
+
var highlight = this.$refs.highlightRef;
|
|
2833
|
+
if (highlight) {
|
|
2834
|
+
highlight.scrollTop = e.target.scrollTop;
|
|
2835
|
+
highlight.scrollLeft = e.target.scrollLeft;
|
|
2836
|
+
}
|
|
2837
|
+
},
|
|
2838
|
+
handleKeydown: function(e) {
|
|
2839
|
+
if (e.key === "Tab") {
|
|
2840
|
+
e.preventDefault();
|
|
2841
|
+
var target = e.target;
|
|
2842
|
+
var start = target.selectionStart;
|
|
2843
|
+
var end = target.selectionEnd;
|
|
2844
|
+
var value = target.value;
|
|
2845
|
+
target.value = value.substring(0, start) + " " + value.substring(end);
|
|
2846
|
+
target.selectionStart = target.selectionEnd = start + 2;
|
|
2847
|
+
this.$emit("input", target.value);
|
|
2848
|
+
this.$emit("update:value", target.value);
|
|
2849
|
+
this.emitChange(target.value);
|
|
2499
2850
|
}
|
|
2500
2851
|
},
|
|
2501
|
-
emitChange: function(
|
|
2502
|
-
var
|
|
2503
|
-
|
|
2504
|
-
|
|
2852
|
+
emitChange: function(value) {
|
|
2853
|
+
var self2 = this;
|
|
2854
|
+
if (self2.changeTimer) {
|
|
2855
|
+
clearTimeout(self2.changeTimer);
|
|
2856
|
+
}
|
|
2857
|
+
self2.changeTimer = setTimeout(function() {
|
|
2858
|
+
self2.$emit("change", value);
|
|
2505
2859
|
}, 500);
|
|
2506
2860
|
}
|
|
2507
2861
|
},
|
|
2508
2862
|
beforeDestroy: function() {
|
|
2509
|
-
|
|
2863
|
+
if (this.changeTimer) {
|
|
2864
|
+
clearTimeout(this.changeTimer);
|
|
2865
|
+
}
|
|
2510
2866
|
}
|
|
2511
2867
|
};
|
|
2512
|
-
var
|
|
2513
|
-
var
|
|
2514
|
-
return
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2868
|
+
var _sfc_render$2 = function render() {
|
|
2869
|
+
var _vm = this, _c = _vm._self._c;
|
|
2870
|
+
return _c("div", { staticClass: "hep-cr-editor", class: "hep-cr-theme-" + _vm.theme, style: { background: _vm.editorBackground } }, [_c("pre", { ref: "highlightRef", staticClass: "hep-cr-highlight", class: "language-" + _vm.prismLanguage, attrs: { "aria-hidden": "true" } }, [_c("code", { domProps: { "innerHTML": _vm._s(_vm.highlightedCode) } })]), _c("textarea", { staticClass: "hep-cr-input", attrs: { "disabled": _vm.disabled, "spellcheck": "false", "placeholder": "Write your code here..." }, domProps: { "value": _vm.value }, on: { "input": _vm.handleInput, "scroll": _vm.handleScroll, "keydown": _vm.handleKeydown } })]);
|
|
2871
|
+
};
|
|
2872
|
+
var _sfc_staticRenderFns$2 = [];
|
|
2873
|
+
var __component__$2 = /* @__PURE__ */ normalizeComponent(
|
|
2874
|
+
_sfc_main$2,
|
|
2875
|
+
_sfc_render$2,
|
|
2876
|
+
_sfc_staticRenderFns$2,
|
|
2877
|
+
false,
|
|
2520
2878
|
null,
|
|
2521
2879
|
"525880d3"
|
|
2522
2880
|
);
|
|
2523
|
-
const
|
|
2881
|
+
const CodeEditor = __component__$2.exports;
|
|
2882
|
+
const _sfc_main$1 = {
|
|
2524
2883
|
name: "CodeRunner",
|
|
2525
2884
|
components: {
|
|
2526
|
-
CodeEditor
|
|
2885
|
+
CodeEditor
|
|
2527
2886
|
},
|
|
2528
2887
|
props: {
|
|
2529
2888
|
pistonUrl: {
|
|
@@ -2537,8 +2896,8 @@ const me = fe.exports, be = {
|
|
|
2537
2896
|
theme: {
|
|
2538
2897
|
type: String,
|
|
2539
2898
|
default: "light",
|
|
2540
|
-
validator: function(
|
|
2541
|
-
return ["light", "dark"].indexOf(
|
|
2899
|
+
validator: function(val) {
|
|
2900
|
+
return ["light", "dark"].indexOf(val) !== -1;
|
|
2542
2901
|
}
|
|
2543
2902
|
},
|
|
2544
2903
|
themeColor: {
|
|
@@ -2547,15 +2906,15 @@ const me = fe.exports, be = {
|
|
|
2547
2906
|
},
|
|
2548
2907
|
showLanguageSelector: {
|
|
2549
2908
|
type: Boolean,
|
|
2550
|
-
default:
|
|
2909
|
+
default: true
|
|
2551
2910
|
},
|
|
2552
2911
|
showEditor: {
|
|
2553
2912
|
type: Boolean,
|
|
2554
|
-
default:
|
|
2913
|
+
default: true
|
|
2555
2914
|
},
|
|
2556
2915
|
editable: {
|
|
2557
2916
|
type: Boolean,
|
|
2558
|
-
default:
|
|
2917
|
+
default: true
|
|
2559
2918
|
},
|
|
2560
2919
|
defaultCode: {
|
|
2561
2920
|
type: String,
|
|
@@ -2567,23 +2926,25 @@ const me = fe.exports, be = {
|
|
|
2567
2926
|
}
|
|
2568
2927
|
},
|
|
2569
2928
|
data: function() {
|
|
2570
|
-
var
|
|
2929
|
+
var self2 = this;
|
|
2930
|
+
var storedLang = typeof window !== "undefined" ? localStorage.getItem("hep-cr-default-language") || null : null;
|
|
2931
|
+
var defaultLang = storedLang || self2.language || "javascript";
|
|
2571
2932
|
return {
|
|
2572
2933
|
runtimes: [],
|
|
2573
|
-
currentLanguage:
|
|
2574
|
-
currentTheme:
|
|
2575
|
-
code:
|
|
2934
|
+
currentLanguage: defaultLang,
|
|
2935
|
+
currentTheme: self2.theme,
|
|
2936
|
+
code: self2.defaultCode || j(defaultLang.split(":")[0]),
|
|
2576
2937
|
output: "",
|
|
2577
2938
|
stderr: "",
|
|
2578
|
-
isRunning:
|
|
2939
|
+
isRunning: false,
|
|
2579
2940
|
executionTime: null,
|
|
2580
2941
|
activeTab: "stdout",
|
|
2581
2942
|
error: null,
|
|
2582
|
-
runtimesLoading:
|
|
2943
|
+
runtimesLoading: false,
|
|
2583
2944
|
client: null,
|
|
2584
2945
|
editorWidth: 60,
|
|
2585
|
-
copiedEditor:
|
|
2586
|
-
copiedOutput:
|
|
2946
|
+
copiedEditor: false,
|
|
2947
|
+
copiedOutput: false
|
|
2587
2948
|
};
|
|
2588
2949
|
},
|
|
2589
2950
|
computed: {
|
|
@@ -2592,17 +2953,30 @@ const me = fe.exports, be = {
|
|
|
2592
2953
|
},
|
|
2593
2954
|
themeStyle: function() {
|
|
2594
2955
|
if (!this.themeColor) return {};
|
|
2595
|
-
var
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
var
|
|
2600
|
-
|
|
2601
|
-
|
|
2956
|
+
var isDark = this.currentTheme === "dark";
|
|
2957
|
+
var color = this.themeColor;
|
|
2958
|
+
var adjustColor = function(hex, percent) {
|
|
2959
|
+
var num = parseInt(hex.replace("#", ""), 16);
|
|
2960
|
+
var amt = Math.round(2.55 * percent);
|
|
2961
|
+
var R = Math.min(255, Math.max(0, (num >> 16) + amt));
|
|
2962
|
+
var G = Math.min(255, Math.max(0, (num >> 8 & 255) + amt));
|
|
2963
|
+
var B = Math.min(255, Math.max(0, (num & 255) + amt));
|
|
2964
|
+
return "#" + (16777216 + R * 65536 + G * 256 + B).toString(16).slice(1);
|
|
2965
|
+
};
|
|
2966
|
+
var isColorLight = function(hex) {
|
|
2967
|
+
var num = parseInt(hex.replace("#", ""), 16);
|
|
2968
|
+
var r = num >> 16 & 255;
|
|
2969
|
+
var g = num >> 8 & 255;
|
|
2970
|
+
var b = num & 255;
|
|
2971
|
+
var luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
2972
|
+
return luminance > 0.5;
|
|
2973
|
+
};
|
|
2974
|
+
var isLightColor = isColorLight(color);
|
|
2975
|
+
var textColor = isLightColor ? "#000" : "#fff";
|
|
2602
2976
|
return {
|
|
2603
|
-
"--hep-cr-theme-color":
|
|
2604
|
-
"--hep-cr-theme-color-hover":
|
|
2605
|
-
"--hep-cr-tab-active-color":
|
|
2977
|
+
"--hep-cr-theme-color": color,
|
|
2978
|
+
"--hep-cr-theme-color-hover": isDark ? adjustColor(color, 20) : adjustColor(color, -20),
|
|
2979
|
+
"--hep-cr-tab-active-color": textColor
|
|
2606
2980
|
};
|
|
2607
2981
|
},
|
|
2608
2982
|
languageOptions: function() {
|
|
@@ -2614,125 +2988,170 @@ const me = fe.exports, be = {
|
|
|
2614
2988
|
});
|
|
2615
2989
|
},
|
|
2616
2990
|
languageName: function() {
|
|
2617
|
-
var
|
|
2618
|
-
return
|
|
2991
|
+
var lang = this.currentLanguage;
|
|
2992
|
+
return lang.includes(":") ? lang.split(":")[0] : lang;
|
|
2619
2993
|
}
|
|
2620
2994
|
},
|
|
2621
2995
|
watch: {
|
|
2622
|
-
currentLanguage: function(
|
|
2623
|
-
var
|
|
2624
|
-
this.code =
|
|
2996
|
+
currentLanguage: function(newLang) {
|
|
2997
|
+
var langName = newLang.includes(":") ? newLang.split(":")[0] : newLang;
|
|
2998
|
+
this.code = j(langName);
|
|
2999
|
+
this.$emit("language-change", langName, this.code);
|
|
3000
|
+
if (typeof window !== "undefined") {
|
|
3001
|
+
localStorage.setItem("hep-cr-default-language", newLang);
|
|
3002
|
+
}
|
|
2625
3003
|
}
|
|
2626
3004
|
},
|
|
2627
3005
|
mounted: function() {
|
|
2628
|
-
this.client = new
|
|
3006
|
+
this.client = new W({ pistonUrl: this.pistonUrl });
|
|
3007
|
+
this.loadRuntimes();
|
|
3008
|
+
this.$emit("change", this.code);
|
|
2629
3009
|
},
|
|
2630
3010
|
methods: {
|
|
2631
3011
|
getStoredLanguage: function() {
|
|
2632
|
-
|
|
3012
|
+
if (typeof window === "undefined") return this.language;
|
|
3013
|
+
return localStorage.getItem("hep-cr-default-language") || this.language;
|
|
2633
3014
|
},
|
|
2634
3015
|
loadRuntimes: function() {
|
|
2635
|
-
var
|
|
2636
|
-
this.runtimesLoading =
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
3016
|
+
var self2 = this;
|
|
3017
|
+
this.runtimesLoading = true;
|
|
3018
|
+
this.error = null;
|
|
3019
|
+
this.client.getRuntimes().then(function(runtimes) {
|
|
3020
|
+
self2.runtimes = runtimes;
|
|
3021
|
+
var langName = self2.currentLanguage.split(":")[0];
|
|
3022
|
+
var defaultRuntime = runtimes.find(function(r) {
|
|
3023
|
+
return r.language === langName;
|
|
2640
3024
|
});
|
|
2641
|
-
|
|
3025
|
+
if (defaultRuntime && !self2.currentLanguage.includes(":")) {
|
|
3026
|
+
self2.currentLanguage = langName + ":" + defaultRuntime.version;
|
|
3027
|
+
}
|
|
3028
|
+
self2.$emit("language-change", langName, self2.code);
|
|
2642
3029
|
}).catch(function(e) {
|
|
2643
|
-
|
|
3030
|
+
self2.error = e.message || "Failed to load runtimes";
|
|
2644
3031
|
}).finally(function() {
|
|
2645
|
-
|
|
3032
|
+
self2.runtimesLoading = false;
|
|
2646
3033
|
});
|
|
2647
3034
|
},
|
|
2648
3035
|
execute: function() {
|
|
2649
|
-
var
|
|
2650
|
-
|
|
2651
|
-
|
|
3036
|
+
var self2 = this;
|
|
3037
|
+
if (this.isRunning) return;
|
|
3038
|
+
this.isRunning = true;
|
|
3039
|
+
this.output = "";
|
|
3040
|
+
this.stderr = "";
|
|
3041
|
+
this.executionTime = null;
|
|
3042
|
+
this.error = null;
|
|
3043
|
+
this.activeTab = "stdout";
|
|
3044
|
+
this.$emit("execute-start");
|
|
3045
|
+
this.client.execute(this.languageName, this.code).then(function(result) {
|
|
3046
|
+
self2.output = result.output;
|
|
3047
|
+
self2.stderr = result.stderr;
|
|
3048
|
+
self2.executionTime = result.executionTime || null;
|
|
3049
|
+
self2.activeTab = result.stderr ? "stderr" : "stdout";
|
|
3050
|
+
self2.$emit("execute-end", result);
|
|
2652
3051
|
}).catch(function(e) {
|
|
2653
|
-
|
|
2654
|
-
|
|
3052
|
+
self2.error = e.message || "Execution failed";
|
|
3053
|
+
self2.$emit("execute-end", {
|
|
3054
|
+
success: false,
|
|
2655
3055
|
output: "",
|
|
2656
|
-
stderr:
|
|
3056
|
+
stderr: self2.error,
|
|
2657
3057
|
code: -1
|
|
2658
3058
|
});
|
|
2659
3059
|
}).finally(function() {
|
|
2660
|
-
|
|
2661
|
-
})
|
|
3060
|
+
self2.isRunning = false;
|
|
3061
|
+
});
|
|
2662
3062
|
},
|
|
2663
3063
|
clearOutput: function() {
|
|
2664
|
-
this.output = ""
|
|
3064
|
+
this.output = "";
|
|
3065
|
+
this.stderr = "";
|
|
3066
|
+
this.executionTime = null;
|
|
3067
|
+
this.error = null;
|
|
2665
3068
|
},
|
|
2666
3069
|
copyCode: function() {
|
|
2667
|
-
var
|
|
2668
|
-
navigator.clipboard.writeText(this.code)
|
|
2669
|
-
|
|
3070
|
+
var self2 = this;
|
|
3071
|
+
navigator.clipboard.writeText(this.code);
|
|
3072
|
+
this.copiedEditor = true;
|
|
3073
|
+
setTimeout(function() {
|
|
3074
|
+
self2.copiedEditor = false;
|
|
2670
3075
|
}, 2e3);
|
|
2671
3076
|
},
|
|
2672
3077
|
copyOutput: function() {
|
|
2673
|
-
var
|
|
2674
|
-
|
|
2675
|
-
|
|
3078
|
+
var self2 = this;
|
|
3079
|
+
var text = this.activeTab === "stdout" ? this.output : this.stderr;
|
|
3080
|
+
navigator.clipboard.writeText(text);
|
|
3081
|
+
this.copiedOutput = true;
|
|
3082
|
+
setTimeout(function() {
|
|
3083
|
+
self2.copiedOutput = false;
|
|
2676
3084
|
}, 2e3);
|
|
2677
3085
|
},
|
|
2678
3086
|
resetCode: function() {
|
|
2679
|
-
this.code =
|
|
3087
|
+
this.code = j(this.languageName);
|
|
2680
3088
|
},
|
|
2681
3089
|
toggleTheme: function() {
|
|
2682
3090
|
this.currentTheme = this.currentTheme === "light" ? "dark" : "light";
|
|
2683
3091
|
},
|
|
2684
|
-
startDrag: function(
|
|
2685
|
-
var
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
3092
|
+
startDrag: function(e) {
|
|
3093
|
+
var self2 = this;
|
|
3094
|
+
var container = document.querySelector(".hep-cr-runner-main");
|
|
3095
|
+
if (!container) return;
|
|
3096
|
+
var onDrag = function(e2) {
|
|
3097
|
+
var rect = container.getBoundingClientRect();
|
|
3098
|
+
var newWidth = (e2.clientX - rect.left) / rect.width * 100;
|
|
3099
|
+
self2.editorWidth = Math.max(20, Math.min(80, newWidth));
|
|
3100
|
+
};
|
|
3101
|
+
var stopDrag = function() {
|
|
3102
|
+
document.removeEventListener("mousemove", onDrag);
|
|
3103
|
+
document.removeEventListener("mouseup", stopDrag);
|
|
3104
|
+
document.body.style.cursor = "";
|
|
3105
|
+
document.body.style.userSelect = "";
|
|
3106
|
+
};
|
|
3107
|
+
document.addEventListener("mousemove", onDrag);
|
|
3108
|
+
document.addEventListener("mouseup", stopDrag);
|
|
3109
|
+
document.body.style.cursor = "col-resize";
|
|
3110
|
+
document.body.style.userSelect = "none";
|
|
2695
3111
|
}
|
|
2696
3112
|
}
|
|
2697
3113
|
};
|
|
2698
|
-
var
|
|
2699
|
-
var
|
|
2700
|
-
return
|
|
2701
|
-
var
|
|
2702
|
-
return
|
|
2703
|
-
}).map(function(
|
|
2704
|
-
var
|
|
2705
|
-
return
|
|
3114
|
+
var _sfc_render$1 = function render2() {
|
|
3115
|
+
var _vm = this, _c = _vm._self._c;
|
|
3116
|
+
return _c("div", { class: ["hep-cr-runner", _vm.themeClass], style: _vm.themeStyle }, [_c("div", { staticClass: "hep-cr-runner-header" }, [_c("div", { staticClass: "hep-cr-runner-controls" }, [_vm.showLanguageSelector ? _c("select", { directives: [{ name: "model", rawName: "v-model", value: _vm.currentLanguage, expression: "currentLanguage" }], staticClass: "hep-cr-language-select", attrs: { "disabled": _vm.isRunning }, on: { "change": function($event) {
|
|
3117
|
+
var $$selectedVal = Array.prototype.filter.call($event.target.options, function(o) {
|
|
3118
|
+
return o.selected;
|
|
3119
|
+
}).map(function(o) {
|
|
3120
|
+
var val = "_value" in o ? o._value : o.value;
|
|
3121
|
+
return val;
|
|
2706
3122
|
});
|
|
2707
|
-
|
|
2708
|
-
} } }, [
|
|
2709
|
-
return
|
|
2710
|
-
})], 2) :
|
|
2711
|
-
|
|
2712
|
-
}, change: function(
|
|
2713
|
-
return
|
|
2714
|
-
} } })], 1) :
|
|
2715
|
-
|
|
2716
|
-
} } }, [
|
|
2717
|
-
|
|
2718
|
-
} } }, [
|
|
2719
|
-
}
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
3123
|
+
_vm.currentLanguage = $event.target.multiple ? $$selectedVal : $$selectedVal[0];
|
|
3124
|
+
} } }, [_vm.runtimesLoading ? _c("option", { attrs: { "value": "" } }, [_vm._v("加载中...")]) : _vm._e(), _vm._l(_vm.languageOptions, function(option) {
|
|
3125
|
+
return _c("option", { key: option.value, domProps: { "value": option.value } }, [_vm._v(" " + _vm._s(option.label) + " ")]);
|
|
3126
|
+
})], 2) : _vm._e()]), _c("div", { staticClass: "hep-cr-runner-actions" }, [_c("button", { staticClass: "hep-cr-btn hep-cr-btn-run", attrs: { "disabled": _vm.isRunning || _vm.runtimesLoading }, on: { "click": _vm.execute } }, [_vm.isRunning ? _c("span", { staticClass: "hep-cr-spinner" }) : _c("span", { staticClass: "hep-cr-run-icon" }, [_vm._v("▶")]), _vm._v(" " + _vm._s(_vm.isRunning ? "运行中..." : _vm.executorLabel) + " ")]), _vm.showEditor && _vm.editable ? _c("button", { staticClass: "hep-cr-btn hep-cr-btn-reset", on: { "click": _vm.resetCode } }, [_vm._v(" 重置 ")]) : _vm._e(), _c("button", { staticClass: "hep-cr-btn hep-cr-btn-theme", attrs: { "title": _vm.currentTheme === "light" ? "Switch to dark mode" : "Switch to light mode" }, on: { "click": _vm.toggleTheme } }, [_vm.currentTheme === "light" ? _c("svg", { attrs: { "width": "16", "height": "16", "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "stroke-width": "2" } }, [_c("path", { attrs: { "d": "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" } })]) : _c("svg", { attrs: { "width": "16", "height": "16", "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "stroke-width": "2" } }, [_c("circle", { attrs: { "cx": "12", "cy": "12", "r": "5" } }), _c("line", { attrs: { "x1": "12", "y1": "1", "x2": "12", "y2": "3" } }), _c("line", { attrs: { "x1": "12", "y1": "21", "x2": "12", "y2": "23" } }), _c("line", { attrs: { "x1": "4.22", "y1": "4.22", "x2": "5.64", "y2": "5.64" } }), _c("line", { attrs: { "x1": "18.36", "y1": "18.36", "x2": "19.78", "y2": "19.78" } }), _c("line", { attrs: { "x1": "1", "y1": "12", "x2": "3", "y2": "12" } }), _c("line", { attrs: { "x1": "21", "y1": "12", "x2": "23", "y2": "12" } }), _c("line", { attrs: { "x1": "4.22", "y1": "19.78", "x2": "5.64", "y2": "18.36" } }), _c("line", { attrs: { "x1": "18.36", "y1": "5.64", "x2": "19.78", "y2": "4.22" } })])])])]), _vm.error ? _c("div", { staticClass: "hep-cr-error-message" }, [_vm._v(" " + _vm._s(_vm.error) + " ")]) : _vm._e(), _c("div", { staticClass: "hep-cr-runner-main" }, [_vm.showEditor ? _c("div", { staticClass: "hep-cr-editor-panel", style: { width: _vm.editorWidth + "%" } }, [_c("div", { staticClass: "hep-cr-panel-header" }, [_c("span", { staticClass: "hep-cr-panel-title" }, [_vm._v("编辑器")]), _c("div", { staticClass: "hep-cr-output-actions" }, [_c("span", { staticClass: "hep-cr-language-badge" }, [_vm._v(_vm._s(_vm.languageName))]), _c("button", { staticClass: "hep-cr-btn-icon", class: { "hep-cr-btn-copied": _vm.copiedEditor }, attrs: { "disabled": _vm.copiedEditor, "title": _vm.copiedEditor ? "已复制" : "复制" }, on: { "click": _vm.copyCode } }, [!_vm.copiedEditor ? _c("svg", { attrs: { "width": "14", "height": "14", "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "stroke-width": "2" } }, [_c("rect", { attrs: { "x": "9", "y": "9", "width": "13", "height": "13", "rx": "2", "ry": "2" } }), _c("path", { attrs: { "d": "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" } })]) : _c("span", { staticClass: "hep-cr-copied-text" }, [_vm._v("已复制")])])])]), _c("CodeEditor", { attrs: { "value": _vm.code, "language": _vm.languageName, "theme": _vm.currentTheme, "disabled": !_vm.editable || _vm.isRunning }, on: { "input": function($event) {
|
|
3127
|
+
_vm.code = $event;
|
|
3128
|
+
}, "change": function($event) {
|
|
3129
|
+
return _vm.$emit("change", $event);
|
|
3130
|
+
} } })], 1) : _vm._e(), _vm.showEditor ? _c("div", { staticClass: "hep-cr-resize-handle", on: { "mousedown": _vm.startDrag } }, [_c("div", { staticClass: "hep-cr-resize-line" })]) : _vm._e(), _c("div", { staticClass: "hep-cr-output-panel", style: { width: _vm.showEditor ? 100 - _vm.editorWidth + "%" : "100%" } }, [_c("div", { staticClass: "hep-cr-panel-header" }, [_c("div", { staticClass: "hep-cr-output-tabs" }, [_c("button", { class: ["hep-cr-tab", { active: _vm.activeTab === "stdout" }], on: { "click": function($event) {
|
|
3131
|
+
_vm.activeTab = "stdout";
|
|
3132
|
+
} } }, [_vm._v(" 输出 ")]), _vm.stderr ? _c("button", { class: ["hep-cr-tab", "hep-cr-tab-error", { active: _vm.activeTab === "stderr" }], on: { "click": function($event) {
|
|
3133
|
+
_vm.activeTab = "stderr";
|
|
3134
|
+
} } }, [_vm._v(" 错误 ")]) : _vm._e()]), _c("div", { staticClass: "hep-cr-output-actions" }, [_vm.executionTime !== null ? _c("span", { staticClass: "hep-cr-execution-time" }, [_vm._v(" " + _vm._s(_vm.executionTime) + "ms ")]) : _vm._e(), _c("button", { staticClass: "hep-cr-btn-icon", class: { "hep-cr-btn-copied": _vm.copiedOutput }, attrs: { "disabled": _vm.copiedOutput, "title": _vm.copiedOutput ? "已复制" : "复制" }, on: { "click": _vm.copyOutput } }, [!_vm.copiedOutput ? _c("svg", { attrs: { "width": "14", "height": "14", "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "stroke-width": "2" } }, [_c("rect", { attrs: { "x": "9", "y": "9", "width": "13", "height": "13", "rx": "2", "ry": "2" } }), _c("path", { attrs: { "d": "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" } })]) : _c("span", { staticClass: "hep-cr-copied-text" }, [_vm._v("已复制")])])])]), _c("div", { staticClass: "hep-cr-output-content" }, [_vm.activeTab === "stdout" ? _c("pre", [_vm._v(_vm._s(_vm.isRunning ? "代码执行中..." : _vm.output || '点击"运行"执行代码'))]) : _c("pre", { staticClass: "hep-cr-stderr" }, [_vm._v(_vm._s(_vm.stderr))])])])])]);
|
|
3135
|
+
};
|
|
3136
|
+
var _sfc_staticRenderFns$1 = [];
|
|
3137
|
+
var __component__$1 = /* @__PURE__ */ normalizeComponent(
|
|
3138
|
+
_sfc_main$1,
|
|
3139
|
+
_sfc_render$1,
|
|
3140
|
+
_sfc_staticRenderFns$1,
|
|
3141
|
+
false,
|
|
2724
3142
|
null,
|
|
2725
3143
|
"b9693b7c"
|
|
2726
3144
|
);
|
|
2727
|
-
const
|
|
3145
|
+
const CodeRunner = __component__$1.exports;
|
|
3146
|
+
const _sfc_main = {
|
|
2728
3147
|
name: "CodeRunnerDialog",
|
|
2729
3148
|
components: {
|
|
2730
|
-
CodeRunner
|
|
3149
|
+
CodeRunner
|
|
2731
3150
|
},
|
|
2732
3151
|
props: {
|
|
2733
3152
|
value: {
|
|
2734
3153
|
type: Boolean,
|
|
2735
|
-
default:
|
|
3154
|
+
default: false
|
|
2736
3155
|
},
|
|
2737
3156
|
title: {
|
|
2738
3157
|
type: String,
|
|
@@ -2754,46 +3173,53 @@ const M = ye.exports, Se = {
|
|
|
2754
3173
|
},
|
|
2755
3174
|
computed: {
|
|
2756
3175
|
dialogWidth() {
|
|
2757
|
-
return typeof this.width
|
|
3176
|
+
return typeof this.width === "number" ? this.width + "px" : this.width;
|
|
2758
3177
|
}
|
|
2759
3178
|
},
|
|
2760
3179
|
watch: {
|
|
2761
|
-
value(
|
|
2762
|
-
this.localVisible =
|
|
3180
|
+
value(val) {
|
|
3181
|
+
this.localVisible = val;
|
|
2763
3182
|
}
|
|
2764
3183
|
},
|
|
2765
3184
|
methods: {
|
|
2766
3185
|
close() {
|
|
2767
|
-
this.localVisible =
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
3186
|
+
this.localVisible = false;
|
|
3187
|
+
this.$emit("input", false);
|
|
3188
|
+
this.$emit("update:value", false);
|
|
3189
|
+
this.$emit("close");
|
|
3190
|
+
},
|
|
3191
|
+
handleOverlayClick(e) {
|
|
3192
|
+
if (e.target === e.currentTarget) {
|
|
3193
|
+
this.close();
|
|
3194
|
+
}
|
|
2771
3195
|
}
|
|
2772
3196
|
},
|
|
2773
3197
|
expose: ["close"]
|
|
2774
3198
|
};
|
|
2775
|
-
var
|
|
2776
|
-
var
|
|
2777
|
-
return
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
3199
|
+
var _sfc_render = function render3() {
|
|
3200
|
+
var _vm = this, _c = _vm._self._c;
|
|
3201
|
+
return _vm.localVisible ? _c("div", { staticClass: "hep-cr-dialog-overlay", on: { "click": _vm.handleOverlayClick } }, [_c("div", { staticClass: "hep-cr-dialog-container", style: { width: _vm.dialogWidth } }, [_c("div", { staticClass: "hep-cr-dialog-header" }, [_c("h3", { staticClass: "hep-cr-dialog-title" }, [_vm._v(_vm._s(_vm.title))]), _c("button", { staticClass: "hep-cr-dialog-close", on: { "click": _vm.close } }, [_c("svg", { attrs: { "width": "16", "height": "16", "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "stroke-width": "2" } }, [_c("line", { attrs: { "x1": "18", "y1": "6", "x2": "6", "y2": "18" } }), _c("line", { attrs: { "x1": "6", "y1": "6", "x2": "18", "y2": "18" } })])])]), _c("div", { staticClass: "hep-cr-dialog-body" }, [_c("CodeRunner", _vm._g(_vm._b({}, "CodeRunner", _vm.$attrs, false), _vm.$listeners))], 1), _c("div", { staticClass: "hep-cr-dialog-footer" }, [_vm._t("footer", null, { "close": _vm.close })], 2)])]) : _vm._e();
|
|
3202
|
+
};
|
|
3203
|
+
var _sfc_staticRenderFns = [];
|
|
3204
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(
|
|
3205
|
+
_sfc_main,
|
|
3206
|
+
_sfc_render,
|
|
3207
|
+
_sfc_staticRenderFns,
|
|
3208
|
+
false,
|
|
2783
3209
|
null,
|
|
2784
3210
|
"518c34f1"
|
|
2785
3211
|
);
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
|
|
3212
|
+
const CodeRunnerDialog = __component__.exports;
|
|
3213
|
+
CodeRunner.install = (app) => {
|
|
3214
|
+
app.component("CodeRunner", CodeRunner);
|
|
2789
3215
|
};
|
|
2790
|
-
const
|
|
2791
|
-
install(
|
|
2792
|
-
|
|
3216
|
+
const index = {
|
|
3217
|
+
install(app) {
|
|
3218
|
+
app.component("CodeRunner", CodeRunner);
|
|
2793
3219
|
}
|
|
2794
3220
|
};
|
|
2795
3221
|
export {
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
3222
|
+
CodeRunner,
|
|
3223
|
+
CodeRunnerDialog,
|
|
3224
|
+
index as default
|
|
2799
3225
|
};
|