@hep-code-runner/vue3 2.1.4 → 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 -238
- package/dist/index.mjs +1690 -1191
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,85 +1,89 @@
|
|
|
1
|
-
import { defineComponent
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { defineComponent, useCssVars, ref, computed, onMounted, watch, onUnmounted, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, withDirectives, createCommentVNode, Fragment, renderList, toDisplayString, vModelSelect, createTextVNode, createStaticVNode, createVNode, createBlock, Teleport, Transition, withCtx, mergeProps, toHandlers, renderSlot } from "vue";
|
|
2
|
+
var w = Object.defineProperty;
|
|
3
|
+
var y = (o, e, t) => e in o ? w(o, e, { enumerable: true, configurable: true, writable: true, value: t }) : o[e] = t;
|
|
4
|
+
var c = (o, e, t) => y(o, typeof e != "symbol" ? e + "" : e, t);
|
|
5
|
+
let u = null;
|
|
6
|
+
class W {
|
|
7
|
+
constructor(e = {}) {
|
|
8
|
+
c(this, "baseUrl");
|
|
9
|
+
c(this, "timeout");
|
|
10
|
+
this.baseUrl = e.pistonUrl || "/api/piston", this.timeout = e.timeout || 3e3;
|
|
7
11
|
}
|
|
8
|
-
async getRuntimes(
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
12
|
+
async getRuntimes(e = false) {
|
|
13
|
+
if (u && !e)
|
|
14
|
+
return u;
|
|
11
15
|
try {
|
|
12
|
-
const
|
|
16
|
+
const t = await fetch(`${this.baseUrl}/runtimes`, {
|
|
13
17
|
method: "GET",
|
|
14
18
|
headers: {
|
|
15
19
|
"Content-Type": "application/json"
|
|
16
20
|
}
|
|
17
21
|
});
|
|
18
|
-
if (!
|
|
19
|
-
throw new Error(`Failed to fetch runtimes: ${
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
} catch (
|
|
23
|
-
throw console.error("Failed to fetch runtimes:",
|
|
22
|
+
if (!t.ok)
|
|
23
|
+
throw new Error(`Failed to fetch runtimes: ${t.statusText}`);
|
|
24
|
+
const n = await t.json();
|
|
25
|
+
return u = n, n;
|
|
26
|
+
} catch (t) {
|
|
27
|
+
throw console.error("Failed to fetch runtimes:", t), t;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
|
-
async execute(
|
|
27
|
-
const
|
|
28
|
-
(
|
|
29
|
-
var
|
|
30
|
-
return
|
|
30
|
+
async execute(e, t, n = {}) {
|
|
31
|
+
const l = (await this.getRuntimes()).find(
|
|
32
|
+
(a) => {
|
|
33
|
+
var r;
|
|
34
|
+
return a.language.toLowerCase() === e.toLowerCase() || ((r = a.aliases) == null ? void 0 : r.some((i) => i.toLowerCase() === e.toLowerCase()));
|
|
31
35
|
}
|
|
32
36
|
);
|
|
33
|
-
if (!
|
|
34
|
-
throw new Error(`Language '${
|
|
35
|
-
const
|
|
36
|
-
language:
|
|
37
|
-
version:
|
|
37
|
+
if (!l)
|
|
38
|
+
throw new Error(`Language '${e}' is not supported`);
|
|
39
|
+
const p = this.getFileName(e), h = {
|
|
40
|
+
language: l.language,
|
|
41
|
+
version: n.version || l.version,
|
|
38
42
|
files: [
|
|
39
43
|
{
|
|
40
|
-
name:
|
|
41
|
-
content:
|
|
44
|
+
name: p,
|
|
45
|
+
content: t
|
|
42
46
|
}
|
|
43
47
|
],
|
|
44
|
-
stdin:
|
|
45
|
-
args:
|
|
46
|
-
run_timeout:
|
|
48
|
+
stdin: n.stdin || "",
|
|
49
|
+
args: n.args || [],
|
|
50
|
+
run_timeout: n.runTimeout || this.timeout,
|
|
47
51
|
compile_timeout: this.timeout
|
|
48
|
-
},
|
|
52
|
+
}, d = Date.now();
|
|
49
53
|
try {
|
|
50
|
-
const
|
|
54
|
+
const a = await fetch(`${this.baseUrl}/execute`, {
|
|
51
55
|
method: "POST",
|
|
52
56
|
headers: {
|
|
53
57
|
"Content-Type": "application/json"
|
|
54
58
|
},
|
|
55
|
-
body: JSON.stringify(
|
|
59
|
+
body: JSON.stringify(h)
|
|
56
60
|
});
|
|
57
|
-
if (!
|
|
58
|
-
throw new Error(`Execute failed: ${
|
|
59
|
-
const
|
|
61
|
+
if (!a.ok)
|
|
62
|
+
throw new Error(`Execute failed: ${a.statusText}`);
|
|
63
|
+
const r = await a.json(), i = Date.now() - d, g = r.run.stdout || "", f = r.run.stderr || "";
|
|
60
64
|
return {
|
|
61
|
-
success:
|
|
62
|
-
output:
|
|
63
|
-
stderr:
|
|
64
|
-
code:
|
|
65
|
-
executionTime:
|
|
66
|
-
compile:
|
|
67
|
-
stdout:
|
|
68
|
-
stderr:
|
|
69
|
-
code:
|
|
65
|
+
success: r.run.code === 0,
|
|
66
|
+
output: g,
|
|
67
|
+
stderr: f,
|
|
68
|
+
code: r.run.code,
|
|
69
|
+
executionTime: i,
|
|
70
|
+
compile: r.compile ? {
|
|
71
|
+
stdout: r.compile.stdout || "",
|
|
72
|
+
stderr: r.compile.stderr || "",
|
|
73
|
+
code: r.compile.code
|
|
70
74
|
} : void 0
|
|
71
75
|
};
|
|
72
|
-
} catch (
|
|
76
|
+
} catch (a) {
|
|
73
77
|
return {
|
|
74
|
-
success:
|
|
78
|
+
success: false,
|
|
75
79
|
output: "",
|
|
76
|
-
stderr:
|
|
80
|
+
stderr: a instanceof Error ? a.message : "Unknown error",
|
|
77
81
|
code: -1,
|
|
78
|
-
executionTime: Date.now() -
|
|
82
|
+
executionTime: Date.now() - d
|
|
79
83
|
};
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
|
-
getFileName(
|
|
86
|
+
getFileName(e) {
|
|
83
87
|
return {
|
|
84
88
|
javascript: "main.js",
|
|
85
89
|
typescript: "main.ts",
|
|
@@ -106,10 +110,10 @@ class De {
|
|
|
106
110
|
css: "style.css",
|
|
107
111
|
sql: "query.sql",
|
|
108
112
|
markdown: "readme.md"
|
|
109
|
-
}[
|
|
113
|
+
}[e.toLowerCase()] || `main.${e}`;
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
|
-
const
|
|
116
|
+
const m = {
|
|
113
117
|
javascript: 'console.log("Hello, World!");',
|
|
114
118
|
typescript: 'console.log("Hello, World!");',
|
|
115
119
|
python: 'print("Hello, World!")',
|
|
@@ -207,18 +211,18 @@ h1 {
|
|
|
207
211
|
|
|
208
212
|
This is a sample markdown document.`
|
|
209
213
|
};
|
|
210
|
-
function
|
|
211
|
-
const
|
|
212
|
-
return
|
|
214
|
+
function j(o) {
|
|
215
|
+
const e = o.toLowerCase();
|
|
216
|
+
return m[e] || `// ${o}
|
|
213
217
|
// Write your code here`;
|
|
214
218
|
}
|
|
215
|
-
var
|
|
216
|
-
function
|
|
217
|
-
return
|
|
219
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
220
|
+
function getDefaultExportFromCjs(x) {
|
|
221
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
218
222
|
}
|
|
219
|
-
var
|
|
220
|
-
(function(
|
|
221
|
-
var
|
|
223
|
+
var prism = { exports: {} };
|
|
224
|
+
(function(module) {
|
|
225
|
+
var _self = typeof window !== "undefined" ? window : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
|
|
222
226
|
/**
|
|
223
227
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
224
228
|
*
|
|
@@ -227,8 +231,11 @@ var fe = { exports: {} };
|
|
|
227
231
|
* @namespace
|
|
228
232
|
* @public
|
|
229
233
|
*/
|
|
230
|
-
var
|
|
231
|
-
var
|
|
234
|
+
var Prism2 = function(_self2) {
|
|
235
|
+
var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
|
|
236
|
+
var uniqueId = 0;
|
|
237
|
+
var plainTextGrammar = {};
|
|
238
|
+
var _ = {
|
|
232
239
|
/**
|
|
233
240
|
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
234
241
|
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
@@ -250,7 +257,7 @@ var fe = { exports: {} };
|
|
|
250
257
|
* @memberof Prism
|
|
251
258
|
* @public
|
|
252
259
|
*/
|
|
253
|
-
manual:
|
|
260
|
+
manual: _self2.Prism && _self2.Prism.manual,
|
|
254
261
|
/**
|
|
255
262
|
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
256
263
|
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
@@ -272,7 +279,7 @@ var fe = { exports: {} };
|
|
|
272
279
|
* @memberof Prism
|
|
273
280
|
* @public
|
|
274
281
|
*/
|
|
275
|
-
disableWorkerMessageHandler:
|
|
282
|
+
disableWorkerMessageHandler: _self2.Prism && _self2.Prism.disableWorkerMessageHandler,
|
|
276
283
|
/**
|
|
277
284
|
* A namespace for utility methods.
|
|
278
285
|
*
|
|
@@ -283,8 +290,14 @@ var fe = { exports: {} };
|
|
|
283
290
|
* @memberof Prism
|
|
284
291
|
*/
|
|
285
292
|
util: {
|
|
286
|
-
encode: function
|
|
287
|
-
|
|
293
|
+
encode: function encode(tokens) {
|
|
294
|
+
if (tokens instanceof Token) {
|
|
295
|
+
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
296
|
+
} else if (Array.isArray(tokens)) {
|
|
297
|
+
return tokens.map(encode);
|
|
298
|
+
} else {
|
|
299
|
+
return tokens.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
300
|
+
}
|
|
288
301
|
},
|
|
289
302
|
/**
|
|
290
303
|
* Returns the name of the type of the given value.
|
|
@@ -302,8 +315,8 @@ var fe = { exports: {} };
|
|
|
302
315
|
* type(String) === 'Function'
|
|
303
316
|
* type(/abc+/) === 'RegExp'
|
|
304
317
|
*/
|
|
305
|
-
type: function(
|
|
306
|
-
return Object.prototype.toString.call(
|
|
318
|
+
type: function(o) {
|
|
319
|
+
return Object.prototype.toString.call(o).slice(8, -1);
|
|
307
320
|
},
|
|
308
321
|
/**
|
|
309
322
|
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
@@ -311,8 +324,11 @@ var fe = { exports: {} };
|
|
|
311
324
|
* @param {Object} obj
|
|
312
325
|
* @returns {number}
|
|
313
326
|
*/
|
|
314
|
-
objId: function(
|
|
315
|
-
|
|
327
|
+
objId: function(obj) {
|
|
328
|
+
if (!obj["__id"]) {
|
|
329
|
+
Object.defineProperty(obj, "__id", { value: ++uniqueId });
|
|
330
|
+
}
|
|
331
|
+
return obj["__id"];
|
|
316
332
|
},
|
|
317
333
|
/**
|
|
318
334
|
* Creates a deep clone of the given object.
|
|
@@ -324,30 +340,46 @@ var fe = { exports: {} };
|
|
|
324
340
|
* @returns {T}
|
|
325
341
|
* @template T
|
|
326
342
|
*/
|
|
327
|
-
clone: function
|
|
328
|
-
|
|
329
|
-
var
|
|
330
|
-
|
|
343
|
+
clone: function deepClone(o, visited) {
|
|
344
|
+
visited = visited || {};
|
|
345
|
+
var clone;
|
|
346
|
+
var id;
|
|
347
|
+
switch (_.util.type(o)) {
|
|
331
348
|
case "Object":
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
349
|
+
id = _.util.objId(o);
|
|
350
|
+
if (visited[id]) {
|
|
351
|
+
return visited[id];
|
|
352
|
+
}
|
|
353
|
+
clone = /** @type {Record<string, any>} */
|
|
354
|
+
{};
|
|
355
|
+
visited[id] = clone;
|
|
356
|
+
for (var key in o) {
|
|
357
|
+
if (o.hasOwnProperty(key)) {
|
|
358
|
+
clone[key] = deepClone(o[key], visited);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
338
361
|
return (
|
|
339
362
|
/** @type {any} */
|
|
340
|
-
|
|
363
|
+
clone
|
|
341
364
|
);
|
|
342
365
|
case "Array":
|
|
343
|
-
|
|
366
|
+
id = _.util.objId(o);
|
|
367
|
+
if (visited[id]) {
|
|
368
|
+
return visited[id];
|
|
369
|
+
}
|
|
370
|
+
clone = [];
|
|
371
|
+
visited[id] = clone;
|
|
372
|
+
/** @type {Array} */
|
|
344
373
|
/** @type {any} */
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
})
|
|
348
|
-
|
|
374
|
+
o.forEach(function(v, i) {
|
|
375
|
+
clone[i] = deepClone(v, visited);
|
|
376
|
+
});
|
|
377
|
+
return (
|
|
378
|
+
/** @type {any} */
|
|
379
|
+
clone
|
|
380
|
+
);
|
|
349
381
|
default:
|
|
350
|
-
return
|
|
382
|
+
return o;
|
|
351
383
|
}
|
|
352
384
|
},
|
|
353
385
|
/**
|
|
@@ -358,12 +390,13 @@ var fe = { exports: {} };
|
|
|
358
390
|
* @param {Element} element
|
|
359
391
|
* @returns {string}
|
|
360
392
|
*/
|
|
361
|
-
getLanguage: function(
|
|
362
|
-
|
|
363
|
-
var
|
|
364
|
-
if (
|
|
365
|
-
return
|
|
366
|
-
|
|
393
|
+
getLanguage: function(element) {
|
|
394
|
+
while (element) {
|
|
395
|
+
var m2 = lang.exec(element.className);
|
|
396
|
+
if (m2) {
|
|
397
|
+
return m2[1].toLowerCase();
|
|
398
|
+
}
|
|
399
|
+
element = element.parentElement;
|
|
367
400
|
}
|
|
368
401
|
return "none";
|
|
369
402
|
},
|
|
@@ -374,8 +407,9 @@ var fe = { exports: {} };
|
|
|
374
407
|
* @param {string} language
|
|
375
408
|
* @returns {void}
|
|
376
409
|
*/
|
|
377
|
-
setLanguage: function(
|
|
378
|
-
|
|
410
|
+
setLanguage: function(element, language) {
|
|
411
|
+
element.className = element.className.replace(RegExp(lang, "gi"), "");
|
|
412
|
+
element.classList.add("language-" + language);
|
|
379
413
|
},
|
|
380
414
|
/**
|
|
381
415
|
* Returns the script element that is currently executing.
|
|
@@ -385,22 +419,26 @@ var fe = { exports: {} };
|
|
|
385
419
|
* @returns {HTMLScriptElement | null}
|
|
386
420
|
*/
|
|
387
421
|
currentScript: function() {
|
|
388
|
-
if (typeof document
|
|
422
|
+
if (typeof document === "undefined") {
|
|
389
423
|
return null;
|
|
390
|
-
|
|
424
|
+
}
|
|
425
|
+
if (document.currentScript && document.currentScript.tagName === "SCRIPT" && 1 < 2) {
|
|
391
426
|
return (
|
|
392
427
|
/** @type {any} */
|
|
393
428
|
document.currentScript
|
|
394
429
|
);
|
|
430
|
+
}
|
|
395
431
|
try {
|
|
396
432
|
throw new Error();
|
|
397
|
-
} catch (
|
|
398
|
-
var
|
|
399
|
-
if (
|
|
400
|
-
var
|
|
401
|
-
for (var
|
|
402
|
-
if (
|
|
403
|
-
return
|
|
433
|
+
} catch (err) {
|
|
434
|
+
var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
|
|
435
|
+
if (src) {
|
|
436
|
+
var scripts = document.getElementsByTagName("script");
|
|
437
|
+
for (var i in scripts) {
|
|
438
|
+
if (scripts[i].src == src) {
|
|
439
|
+
return scripts[i];
|
|
440
|
+
}
|
|
441
|
+
}
|
|
404
442
|
}
|
|
405
443
|
return null;
|
|
406
444
|
}
|
|
@@ -424,16 +462,19 @@ var fe = { exports: {} };
|
|
|
424
462
|
* @param {boolean} [defaultActivation=false]
|
|
425
463
|
* @returns {boolean}
|
|
426
464
|
*/
|
|
427
|
-
isActive: function(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
465
|
+
isActive: function(element, className, defaultActivation) {
|
|
466
|
+
var no = "no-" + className;
|
|
467
|
+
while (element) {
|
|
468
|
+
var classList = element.classList;
|
|
469
|
+
if (classList.contains(className)) {
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
if (classList.contains(no)) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
element = element.parentElement;
|
|
435
476
|
}
|
|
436
|
-
return !!
|
|
477
|
+
return !!defaultActivation;
|
|
437
478
|
}
|
|
438
479
|
},
|
|
439
480
|
/**
|
|
@@ -447,10 +488,10 @@ var fe = { exports: {} };
|
|
|
447
488
|
/**
|
|
448
489
|
* The grammar for plain, unformatted text.
|
|
449
490
|
*/
|
|
450
|
-
plain:
|
|
451
|
-
plaintext:
|
|
452
|
-
text:
|
|
453
|
-
txt:
|
|
491
|
+
plain: plainTextGrammar,
|
|
492
|
+
plaintext: plainTextGrammar,
|
|
493
|
+
text: plainTextGrammar,
|
|
494
|
+
txt: plainTextGrammar,
|
|
454
495
|
/**
|
|
455
496
|
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
456
497
|
*
|
|
@@ -479,11 +520,12 @@ var fe = { exports: {} };
|
|
|
479
520
|
* 'color': /\b(?:red|green|blue)\b/
|
|
480
521
|
* });
|
|
481
522
|
*/
|
|
482
|
-
extend: function(
|
|
483
|
-
var
|
|
484
|
-
for (var
|
|
485
|
-
|
|
486
|
-
|
|
523
|
+
extend: function(id, redef) {
|
|
524
|
+
var lang2 = _.util.clone(_.languages[id]);
|
|
525
|
+
for (var key in redef) {
|
|
526
|
+
lang2[key] = redef[key];
|
|
527
|
+
}
|
|
528
|
+
return lang2;
|
|
487
529
|
},
|
|
488
530
|
/**
|
|
489
531
|
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
@@ -560,32 +602,52 @@ var fe = { exports: {} };
|
|
|
560
602
|
* @returns {Grammar} The new grammar object.
|
|
561
603
|
* @public
|
|
562
604
|
*/
|
|
563
|
-
insertBefore: function(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
var
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
605
|
+
insertBefore: function(inside, before, insert, root) {
|
|
606
|
+
root = root || /** @type {any} */
|
|
607
|
+
_.languages;
|
|
608
|
+
var grammar = root[inside];
|
|
609
|
+
var ret = {};
|
|
610
|
+
for (var token in grammar) {
|
|
611
|
+
if (grammar.hasOwnProperty(token)) {
|
|
612
|
+
if (token == before) {
|
|
613
|
+
for (var newToken in insert) {
|
|
614
|
+
if (insert.hasOwnProperty(newToken)) {
|
|
615
|
+
ret[newToken] = insert[newToken];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (!insert.hasOwnProperty(token)) {
|
|
620
|
+
ret[token] = grammar[token];
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
var old = root[inside];
|
|
625
|
+
root[inside] = ret;
|
|
626
|
+
_.languages.DFS(_.languages, function(key, value) {
|
|
627
|
+
if (value === old && key != inside) {
|
|
628
|
+
this[key] = ret;
|
|
573
629
|
}
|
|
574
|
-
|
|
575
|
-
return
|
|
576
|
-
U === T && F != e && (this[F] = u);
|
|
577
|
-
}), u;
|
|
630
|
+
});
|
|
631
|
+
return ret;
|
|
578
632
|
},
|
|
579
633
|
// Traverse a language definition with Depth First Search
|
|
580
|
-
DFS: function
|
|
581
|
-
|
|
582
|
-
var
|
|
583
|
-
for (var
|
|
584
|
-
if (
|
|
585
|
-
|
|
586
|
-
var
|
|
587
|
-
|
|
634
|
+
DFS: function DFS(o, callback, type, visited) {
|
|
635
|
+
visited = visited || {};
|
|
636
|
+
var objId = _.util.objId;
|
|
637
|
+
for (var i in o) {
|
|
638
|
+
if (o.hasOwnProperty(i)) {
|
|
639
|
+
callback.call(o, i, o[i], type || i);
|
|
640
|
+
var property = o[i];
|
|
641
|
+
var propertyType = _.util.type(property);
|
|
642
|
+
if (propertyType === "Object" && !visited[objId(property)]) {
|
|
643
|
+
visited[objId(property)] = true;
|
|
644
|
+
DFS(property, callback, null, visited);
|
|
645
|
+
} else if (propertyType === "Array" && !visited[objId(property)]) {
|
|
646
|
+
visited[objId(property)] = true;
|
|
647
|
+
DFS(property, callback, i, visited);
|
|
648
|
+
}
|
|
588
649
|
}
|
|
650
|
+
}
|
|
589
651
|
}
|
|
590
652
|
},
|
|
591
653
|
plugins: {},
|
|
@@ -601,8 +663,8 @@ var fe = { exports: {} };
|
|
|
601
663
|
* @memberof Prism
|
|
602
664
|
* @public
|
|
603
665
|
*/
|
|
604
|
-
highlightAll: function(
|
|
605
|
-
|
|
666
|
+
highlightAll: function(async, callback) {
|
|
667
|
+
_.highlightAllUnder(document, async, callback);
|
|
606
668
|
},
|
|
607
669
|
/**
|
|
608
670
|
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
@@ -619,15 +681,18 @@ var fe = { exports: {} };
|
|
|
619
681
|
* @memberof Prism
|
|
620
682
|
* @public
|
|
621
683
|
*/
|
|
622
|
-
highlightAllUnder: function(
|
|
623
|
-
var
|
|
624
|
-
callback
|
|
625
|
-
container
|
|
684
|
+
highlightAllUnder: function(container, async, callback) {
|
|
685
|
+
var env = {
|
|
686
|
+
callback,
|
|
687
|
+
container,
|
|
626
688
|
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
627
689
|
};
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
690
|
+
_.hooks.run("before-highlightall", env);
|
|
691
|
+
env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
|
|
692
|
+
_.hooks.run("before-all-elements-highlight", env);
|
|
693
|
+
for (var i = 0, element; element = env.elements[i++]; ) {
|
|
694
|
+
_.highlightElement(element, async === true, env.callback);
|
|
695
|
+
}
|
|
631
696
|
},
|
|
632
697
|
/**
|
|
633
698
|
* Highlights the code inside a single element.
|
|
@@ -657,39 +722,57 @@ var fe = { exports: {} };
|
|
|
657
722
|
* @memberof Prism
|
|
658
723
|
* @public
|
|
659
724
|
*/
|
|
660
|
-
highlightElement: function(
|
|
661
|
-
var
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
725
|
+
highlightElement: function(element, async, callback) {
|
|
726
|
+
var language = _.util.getLanguage(element);
|
|
727
|
+
var grammar = _.languages[language];
|
|
728
|
+
_.util.setLanguage(element, language);
|
|
729
|
+
var parent = element.parentElement;
|
|
730
|
+
if (parent && parent.nodeName.toLowerCase() === "pre") {
|
|
731
|
+
_.util.setLanguage(parent, language);
|
|
732
|
+
}
|
|
733
|
+
var code = element.textContent;
|
|
734
|
+
var env = {
|
|
735
|
+
element,
|
|
736
|
+
language,
|
|
737
|
+
grammar,
|
|
738
|
+
code
|
|
670
739
|
};
|
|
671
|
-
function
|
|
672
|
-
|
|
740
|
+
function insertHighlightedCode(highlightedCode) {
|
|
741
|
+
env.highlightedCode = highlightedCode;
|
|
742
|
+
_.hooks.run("before-insert", env);
|
|
743
|
+
env.element.innerHTML = env.highlightedCode;
|
|
744
|
+
_.hooks.run("after-highlight", env);
|
|
745
|
+
_.hooks.run("complete", env);
|
|
746
|
+
callback && callback.call(env.element);
|
|
747
|
+
}
|
|
748
|
+
_.hooks.run("before-sanity-check", env);
|
|
749
|
+
parent = env.element.parentElement;
|
|
750
|
+
if (parent && parent.nodeName.toLowerCase() === "pre" && !parent.hasAttribute("tabindex")) {
|
|
751
|
+
parent.setAttribute("tabindex", "0");
|
|
673
752
|
}
|
|
674
|
-
if (
|
|
675
|
-
|
|
753
|
+
if (!env.code) {
|
|
754
|
+
_.hooks.run("complete", env);
|
|
755
|
+
callback && callback.call(env.element);
|
|
676
756
|
return;
|
|
677
757
|
}
|
|
678
|
-
|
|
679
|
-
|
|
758
|
+
_.hooks.run("before-highlight", env);
|
|
759
|
+
if (!env.grammar) {
|
|
760
|
+
insertHighlightedCode(_.util.encode(env.code));
|
|
680
761
|
return;
|
|
681
762
|
}
|
|
682
|
-
if (
|
|
683
|
-
var
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
763
|
+
if (async && _self2.Worker) {
|
|
764
|
+
var worker = new Worker(_.filename);
|
|
765
|
+
worker.onmessage = function(evt) {
|
|
766
|
+
insertHighlightedCode(evt.data);
|
|
767
|
+
};
|
|
768
|
+
worker.postMessage(JSON.stringify({
|
|
769
|
+
language: env.language,
|
|
770
|
+
code: env.code,
|
|
771
|
+
immediateClose: true
|
|
690
772
|
}));
|
|
691
|
-
} else
|
|
692
|
-
|
|
773
|
+
} else {
|
|
774
|
+
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
|
|
775
|
+
}
|
|
693
776
|
},
|
|
694
777
|
/**
|
|
695
778
|
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
@@ -711,15 +794,19 @@ var fe = { exports: {} };
|
|
|
711
794
|
* @example
|
|
712
795
|
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
713
796
|
*/
|
|
714
|
-
highlight: function(
|
|
715
|
-
var
|
|
716
|
-
code:
|
|
717
|
-
grammar
|
|
718
|
-
language
|
|
797
|
+
highlight: function(text, grammar, language) {
|
|
798
|
+
var env = {
|
|
799
|
+
code: text,
|
|
800
|
+
grammar,
|
|
801
|
+
language
|
|
719
802
|
};
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
803
|
+
_.hooks.run("before-tokenize", env);
|
|
804
|
+
if (!env.grammar) {
|
|
805
|
+
throw new Error('The language "' + env.language + '" has no grammar.');
|
|
806
|
+
}
|
|
807
|
+
env.tokens = _.tokenize(env.code, env.grammar);
|
|
808
|
+
_.hooks.run("after-tokenize", env);
|
|
809
|
+
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
723
810
|
},
|
|
724
811
|
/**
|
|
725
812
|
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
@@ -745,15 +832,18 @@ var fe = { exports: {} };
|
|
|
745
832
|
* }
|
|
746
833
|
* });
|
|
747
834
|
*/
|
|
748
|
-
tokenize: function(
|
|
749
|
-
var
|
|
750
|
-
if (
|
|
751
|
-
for (var
|
|
752
|
-
|
|
753
|
-
|
|
835
|
+
tokenize: function(text, grammar) {
|
|
836
|
+
var rest = grammar.rest;
|
|
837
|
+
if (rest) {
|
|
838
|
+
for (var token in rest) {
|
|
839
|
+
grammar[token] = rest[token];
|
|
840
|
+
}
|
|
841
|
+
delete grammar.rest;
|
|
754
842
|
}
|
|
755
|
-
var
|
|
756
|
-
|
|
843
|
+
var tokenList = new LinkedList();
|
|
844
|
+
addAfter(tokenList, tokenList.head, text);
|
|
845
|
+
matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
|
846
|
+
return toArray(tokenList);
|
|
757
847
|
},
|
|
758
848
|
/**
|
|
759
849
|
* @namespace
|
|
@@ -774,9 +864,10 @@ var fe = { exports: {} };
|
|
|
774
864
|
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
775
865
|
* @public
|
|
776
866
|
*/
|
|
777
|
-
add: function(
|
|
778
|
-
var
|
|
779
|
-
|
|
867
|
+
add: function(name, callback) {
|
|
868
|
+
var hooks = _.hooks.all;
|
|
869
|
+
hooks[name] = hooks[name] || [];
|
|
870
|
+
hooks[name].push(callback);
|
|
780
871
|
},
|
|
781
872
|
/**
|
|
782
873
|
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
@@ -787,214 +878,337 @@ var fe = { exports: {} };
|
|
|
787
878
|
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
788
879
|
* @public
|
|
789
880
|
*/
|
|
790
|
-
run: function(
|
|
791
|
-
var
|
|
792
|
-
if (!
|
|
793
|
-
|
|
794
|
-
|
|
881
|
+
run: function(name, env) {
|
|
882
|
+
var callbacks = _.hooks.all[name];
|
|
883
|
+
if (!callbacks || !callbacks.length) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
for (var i = 0, callback; callback = callbacks[i++]; ) {
|
|
887
|
+
callback(env);
|
|
888
|
+
}
|
|
795
889
|
}
|
|
796
890
|
},
|
|
797
|
-
Token
|
|
891
|
+
Token
|
|
798
892
|
};
|
|
799
|
-
|
|
800
|
-
function
|
|
801
|
-
this.type =
|
|
893
|
+
_self2.Prism = _;
|
|
894
|
+
function Token(type, content, alias, matchedStr) {
|
|
895
|
+
this.type = type;
|
|
896
|
+
this.content = content;
|
|
897
|
+
this.alias = alias;
|
|
898
|
+
this.length = (matchedStr || "").length | 0;
|
|
802
899
|
}
|
|
803
|
-
|
|
804
|
-
if (typeof
|
|
805
|
-
return
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
900
|
+
Token.stringify = function stringify(o, language) {
|
|
901
|
+
if (typeof o == "string") {
|
|
902
|
+
return o;
|
|
903
|
+
}
|
|
904
|
+
if (Array.isArray(o)) {
|
|
905
|
+
var s = "";
|
|
906
|
+
o.forEach(function(e) {
|
|
907
|
+
s += stringify(e, language);
|
|
908
|
+
});
|
|
909
|
+
return s;
|
|
811
910
|
}
|
|
812
|
-
var
|
|
813
|
-
type:
|
|
814
|
-
content:
|
|
911
|
+
var env = {
|
|
912
|
+
type: o.type,
|
|
913
|
+
content: stringify(o.content, language),
|
|
815
914
|
tag: "span",
|
|
816
|
-
classes: ["token",
|
|
915
|
+
classes: ["token", o.type],
|
|
817
916
|
attributes: {},
|
|
818
|
-
language
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
917
|
+
language
|
|
918
|
+
};
|
|
919
|
+
var aliases = o.alias;
|
|
920
|
+
if (aliases) {
|
|
921
|
+
if (Array.isArray(aliases)) {
|
|
922
|
+
Array.prototype.push.apply(env.classes, aliases);
|
|
923
|
+
} else {
|
|
924
|
+
env.classes.push(aliases);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
_.hooks.run("wrap", env);
|
|
928
|
+
var attributes = "";
|
|
929
|
+
for (var name in env.attributes) {
|
|
930
|
+
attributes += " " + name + '="' + (env.attributes[name] || "").replace(/"/g, """) + '"';
|
|
931
|
+
}
|
|
932
|
+
return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + attributes + ">" + env.content + "</" + env.tag + ">";
|
|
825
933
|
};
|
|
826
|
-
function
|
|
827
|
-
|
|
828
|
-
var
|
|
829
|
-
if (
|
|
830
|
-
var
|
|
831
|
-
|
|
934
|
+
function matchPattern(pattern, pos, text, lookbehind) {
|
|
935
|
+
pattern.lastIndex = pos;
|
|
936
|
+
var match = pattern.exec(text);
|
|
937
|
+
if (match && lookbehind && match[1]) {
|
|
938
|
+
var lookbehindLength = match[1].length;
|
|
939
|
+
match.index += lookbehindLength;
|
|
940
|
+
match[0] = match[0].slice(lookbehindLength);
|
|
832
941
|
}
|
|
833
|
-
return
|
|
942
|
+
return match;
|
|
834
943
|
}
|
|
835
|
-
function
|
|
836
|
-
for (var
|
|
837
|
-
if (!
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
944
|
+
function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
|
945
|
+
for (var token in grammar) {
|
|
946
|
+
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
var patterns = grammar[token];
|
|
950
|
+
patterns = Array.isArray(patterns) ? patterns : [patterns];
|
|
951
|
+
for (var j2 = 0; j2 < patterns.length; ++j2) {
|
|
952
|
+
if (rematch && rematch.cause == token + "," + j2) {
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
var patternObj = patterns[j2];
|
|
956
|
+
var inside = patternObj.inside;
|
|
957
|
+
var lookbehind = !!patternObj.lookbehind;
|
|
958
|
+
var greedy = !!patternObj.greedy;
|
|
959
|
+
var alias = patternObj.alias;
|
|
960
|
+
if (greedy && !patternObj.pattern.global) {
|
|
961
|
+
var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
|
962
|
+
patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
|
|
963
|
+
}
|
|
964
|
+
var pattern = patternObj.pattern || patternObj;
|
|
965
|
+
for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
|
|
966
|
+
if (rematch && pos >= rematch.reach) {
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
var str = currentNode.value;
|
|
970
|
+
if (tokenList.length > text.length) {
|
|
842
971
|
return;
|
|
843
|
-
var F = c[T], U = F.inside, X = !!F.lookbehind, Z = !!F.greedy, V = F.alias;
|
|
844
|
-
if (Z && !F.pattern.global) {
|
|
845
|
-
var te = F.pattern.toString().match(/[imsuy]*$/)[0];
|
|
846
|
-
F.pattern = RegExp(F.pattern.source, te + "g");
|
|
847
972
|
}
|
|
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
|
-
|
|
878
|
-
|
|
973
|
+
if (str instanceof Token) {
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
976
|
+
var removeCount = 1;
|
|
977
|
+
var match;
|
|
978
|
+
if (greedy) {
|
|
979
|
+
match = matchPattern(pattern, pos, text, lookbehind);
|
|
980
|
+
if (!match || match.index >= text.length) {
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
var from = match.index;
|
|
984
|
+
var to = match.index + match[0].length;
|
|
985
|
+
var p = pos;
|
|
986
|
+
p += currentNode.value.length;
|
|
987
|
+
while (from >= p) {
|
|
988
|
+
currentNode = currentNode.next;
|
|
989
|
+
p += currentNode.value.length;
|
|
990
|
+
}
|
|
991
|
+
p -= currentNode.value.length;
|
|
992
|
+
pos = p;
|
|
993
|
+
if (currentNode.value instanceof Token) {
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
|
|
997
|
+
removeCount++;
|
|
998
|
+
p += k.value.length;
|
|
999
|
+
}
|
|
1000
|
+
removeCount--;
|
|
1001
|
+
str = text.slice(pos, p);
|
|
1002
|
+
match.index -= pos;
|
|
1003
|
+
} else {
|
|
1004
|
+
match = matchPattern(pattern, 0, str, lookbehind);
|
|
1005
|
+
if (!match) {
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
var from = match.index;
|
|
1010
|
+
var matchStr = match[0];
|
|
1011
|
+
var before = str.slice(0, from);
|
|
1012
|
+
var after = str.slice(from + matchStr.length);
|
|
1013
|
+
var reach = pos + str.length;
|
|
1014
|
+
if (rematch && reach > rematch.reach) {
|
|
1015
|
+
rematch.reach = reach;
|
|
1016
|
+
}
|
|
1017
|
+
var removeFrom = currentNode.prev;
|
|
1018
|
+
if (before) {
|
|
1019
|
+
removeFrom = addAfter(tokenList, removeFrom, before);
|
|
1020
|
+
pos += before.length;
|
|
1021
|
+
}
|
|
1022
|
+
removeRange(tokenList, removeFrom, removeCount);
|
|
1023
|
+
var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
|
1024
|
+
currentNode = addAfter(tokenList, removeFrom, wrapped);
|
|
1025
|
+
if (after) {
|
|
1026
|
+
addAfter(tokenList, currentNode, after);
|
|
1027
|
+
}
|
|
1028
|
+
if (removeCount > 1) {
|
|
1029
|
+
var nestedRematch = {
|
|
1030
|
+
cause: token + "," + j2,
|
|
1031
|
+
reach
|
|
1032
|
+
};
|
|
1033
|
+
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
|
1034
|
+
if (rematch && nestedRematch.reach > rematch.reach) {
|
|
1035
|
+
rematch.reach = nestedRematch.reach;
|
|
879
1036
|
}
|
|
880
1037
|
}
|
|
881
1038
|
}
|
|
882
1039
|
}
|
|
1040
|
+
}
|
|
883
1041
|
}
|
|
884
|
-
function
|
|
885
|
-
var
|
|
886
|
-
|
|
1042
|
+
function LinkedList() {
|
|
1043
|
+
var head = { value: null, prev: null, next: null };
|
|
1044
|
+
var tail = { value: null, prev: head, next: null };
|
|
1045
|
+
head.next = tail;
|
|
1046
|
+
this.head = head;
|
|
1047
|
+
this.tail = tail;
|
|
1048
|
+
this.length = 0;
|
|
887
1049
|
}
|
|
888
|
-
function
|
|
889
|
-
var
|
|
890
|
-
|
|
1050
|
+
function addAfter(list, node, value) {
|
|
1051
|
+
var next = node.next;
|
|
1052
|
+
var newNode = { value, prev: node, next };
|
|
1053
|
+
node.next = newNode;
|
|
1054
|
+
next.prev = newNode;
|
|
1055
|
+
list.length++;
|
|
1056
|
+
return newNode;
|
|
891
1057
|
}
|
|
892
|
-
function
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1058
|
+
function removeRange(list, node, count) {
|
|
1059
|
+
var next = node.next;
|
|
1060
|
+
for (var i = 0; i < count && next !== list.tail; i++) {
|
|
1061
|
+
next = next.next;
|
|
1062
|
+
}
|
|
1063
|
+
node.next = next;
|
|
1064
|
+
next.prev = node;
|
|
1065
|
+
list.length -= i;
|
|
896
1066
|
}
|
|
897
|
-
function
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1067
|
+
function toArray(list) {
|
|
1068
|
+
var array = [];
|
|
1069
|
+
var node = list.head.next;
|
|
1070
|
+
while (node !== list.tail) {
|
|
1071
|
+
array.push(node.value);
|
|
1072
|
+
node = node.next;
|
|
1073
|
+
}
|
|
1074
|
+
return array;
|
|
901
1075
|
}
|
|
902
|
-
if (!
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1076
|
+
if (!_self2.document) {
|
|
1077
|
+
if (!_self2.addEventListener) {
|
|
1078
|
+
return _;
|
|
1079
|
+
}
|
|
1080
|
+
if (!_.disableWorkerMessageHandler) {
|
|
1081
|
+
_self2.addEventListener("message", function(evt) {
|
|
1082
|
+
var message = JSON.parse(evt.data);
|
|
1083
|
+
var lang2 = message.language;
|
|
1084
|
+
var code = message.code;
|
|
1085
|
+
var immediateClose = message.immediateClose;
|
|
1086
|
+
_self2.postMessage(_.highlight(code, _.languages[lang2], lang2));
|
|
1087
|
+
if (immediateClose) {
|
|
1088
|
+
_self2.close();
|
|
1089
|
+
}
|
|
1090
|
+
}, false);
|
|
1091
|
+
}
|
|
1092
|
+
return _;
|
|
911
1093
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1094
|
+
var script = _.util.currentScript();
|
|
1095
|
+
if (script) {
|
|
1096
|
+
_.filename = script.src;
|
|
1097
|
+
if (script.hasAttribute("data-manual")) {
|
|
1098
|
+
_.manual = true;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
function highlightAutomaticallyCallback() {
|
|
1102
|
+
if (!_.manual) {
|
|
1103
|
+
_.highlightAll();
|
|
1104
|
+
}
|
|
915
1105
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1106
|
+
if (!_.manual) {
|
|
1107
|
+
var readyState = document.readyState;
|
|
1108
|
+
if (readyState === "loading" || readyState === "interactive" && script && script.defer) {
|
|
1109
|
+
document.addEventListener("DOMContentLoaded", highlightAutomaticallyCallback);
|
|
1110
|
+
} else {
|
|
1111
|
+
if (window.requestAnimationFrame) {
|
|
1112
|
+
window.requestAnimationFrame(highlightAutomaticallyCallback);
|
|
1113
|
+
} else {
|
|
1114
|
+
window.setTimeout(highlightAutomaticallyCallback, 16);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
return _;
|
|
1119
|
+
}(_self);
|
|
1120
|
+
if (module.exports) {
|
|
1121
|
+
module.exports = Prism2;
|
|
1122
|
+
}
|
|
1123
|
+
if (typeof commonjsGlobal !== "undefined") {
|
|
1124
|
+
commonjsGlobal.Prism = Prism2;
|
|
1125
|
+
}
|
|
1126
|
+
Prism2.languages.markup = {
|
|
1127
|
+
"comment": {
|
|
920
1128
|
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
921
|
-
greedy:
|
|
1129
|
+
greedy: true
|
|
922
1130
|
},
|
|
923
|
-
prolog: {
|
|
1131
|
+
"prolog": {
|
|
924
1132
|
pattern: /<\?[\s\S]+?\?>/,
|
|
925
|
-
greedy:
|
|
1133
|
+
greedy: true
|
|
926
1134
|
},
|
|
927
|
-
doctype: {
|
|
1135
|
+
"doctype": {
|
|
928
1136
|
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
929
1137
|
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
930
|
-
greedy:
|
|
1138
|
+
greedy: true,
|
|
931
1139
|
inside: {
|
|
932
1140
|
"internal-subset": {
|
|
933
1141
|
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
934
|
-
lookbehind:
|
|
935
|
-
greedy:
|
|
1142
|
+
lookbehind: true,
|
|
1143
|
+
greedy: true,
|
|
936
1144
|
inside: null
|
|
937
1145
|
// see below
|
|
938
1146
|
},
|
|
939
|
-
string: {
|
|
1147
|
+
"string": {
|
|
940
1148
|
pattern: /"[^"]*"|'[^']*'/,
|
|
941
|
-
greedy:
|
|
1149
|
+
greedy: true
|
|
942
1150
|
},
|
|
943
|
-
punctuation: /^<!|>$|[[\]]/,
|
|
1151
|
+
"punctuation": /^<!|>$|[[\]]/,
|
|
944
1152
|
"doctype-tag": /^DOCTYPE/i,
|
|
945
|
-
name: /[^\s<>'"]+/
|
|
1153
|
+
"name": /[^\s<>'"]+/
|
|
946
1154
|
}
|
|
947
1155
|
},
|
|
948
|
-
cdata: {
|
|
1156
|
+
"cdata": {
|
|
949
1157
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
950
|
-
greedy:
|
|
1158
|
+
greedy: true
|
|
951
1159
|
},
|
|
952
|
-
tag: {
|
|
1160
|
+
"tag": {
|
|
953
1161
|
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
954
|
-
greedy:
|
|
1162
|
+
greedy: true,
|
|
955
1163
|
inside: {
|
|
956
|
-
tag: {
|
|
1164
|
+
"tag": {
|
|
957
1165
|
pattern: /^<\/?[^\s>\/]+/,
|
|
958
1166
|
inside: {
|
|
959
|
-
punctuation: /^<\/?/,
|
|
960
|
-
namespace: /^[^\s>\/:]+:/
|
|
1167
|
+
"punctuation": /^<\/?/,
|
|
1168
|
+
"namespace": /^[^\s>\/:]+:/
|
|
961
1169
|
}
|
|
962
1170
|
},
|
|
963
1171
|
"special-attr": [],
|
|
964
1172
|
"attr-value": {
|
|
965
1173
|
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
966
1174
|
inside: {
|
|
967
|
-
punctuation: [
|
|
1175
|
+
"punctuation": [
|
|
968
1176
|
{
|
|
969
1177
|
pattern: /^=/,
|
|
970
1178
|
alias: "attr-equals"
|
|
971
1179
|
},
|
|
972
1180
|
{
|
|
973
1181
|
pattern: /^(\s*)["']|["']$/,
|
|
974
|
-
lookbehind:
|
|
1182
|
+
lookbehind: true
|
|
975
1183
|
}
|
|
976
1184
|
]
|
|
977
1185
|
}
|
|
978
1186
|
},
|
|
979
|
-
punctuation: /\/?>/,
|
|
1187
|
+
"punctuation": /\/?>/,
|
|
980
1188
|
"attr-name": {
|
|
981
1189
|
pattern: /[^\s>\/]+/,
|
|
982
1190
|
inside: {
|
|
983
|
-
namespace: /^[^\s>\/:]+:/
|
|
1191
|
+
"namespace": /^[^\s>\/:]+:/
|
|
984
1192
|
}
|
|
985
1193
|
}
|
|
986
1194
|
}
|
|
987
1195
|
},
|
|
988
|
-
entity: [
|
|
1196
|
+
"entity": [
|
|
989
1197
|
{
|
|
990
1198
|
pattern: /&[\da-z]{1,8};/i,
|
|
991
1199
|
alias: "named-entity"
|
|
992
1200
|
},
|
|
993
1201
|
/&#x?[\da-f]{1,8};/i
|
|
994
1202
|
]
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
|
|
1203
|
+
};
|
|
1204
|
+
Prism2.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism2.languages.markup["entity"];
|
|
1205
|
+
Prism2.languages.markup["doctype"].inside["internal-subset"].inside = Prism2.languages.markup;
|
|
1206
|
+
Prism2.hooks.add("wrap", function(env) {
|
|
1207
|
+
if (env.type === "entity") {
|
|
1208
|
+
env.attributes["title"] = env.content.replace(/&/, "&");
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
Object.defineProperty(Prism2.languages.markup.tag, "addInlined", {
|
|
998
1212
|
/**
|
|
999
1213
|
* Adds an inlined language to markup.
|
|
1000
1214
|
*
|
|
@@ -1006,34 +1220,37 @@ var fe = { exports: {} };
|
|
|
1006
1220
|
* @example
|
|
1007
1221
|
* addInlined('style', 'css');
|
|
1008
1222
|
*/
|
|
1009
|
-
value: function(
|
|
1010
|
-
var
|
|
1011
|
-
|
|
1223
|
+
value: function addInlined(tagName, lang) {
|
|
1224
|
+
var includedCdataInside = {};
|
|
1225
|
+
includedCdataInside["language-" + lang] = {
|
|
1012
1226
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1013
|
-
lookbehind:
|
|
1014
|
-
inside:
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1227
|
+
lookbehind: true,
|
|
1228
|
+
inside: Prism2.languages[lang]
|
|
1229
|
+
};
|
|
1230
|
+
includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
|
|
1231
|
+
var inside = {
|
|
1017
1232
|
"included-cdata": {
|
|
1018
1233
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1019
|
-
inside:
|
|
1234
|
+
inside: includedCdataInside
|
|
1020
1235
|
}
|
|
1021
1236
|
};
|
|
1022
|
-
|
|
1237
|
+
inside["language-" + lang] = {
|
|
1023
1238
|
pattern: /[\s\S]+/,
|
|
1024
|
-
inside:
|
|
1239
|
+
inside: Prism2.languages[lang]
|
|
1025
1240
|
};
|
|
1026
|
-
var
|
|
1027
|
-
|
|
1241
|
+
var def = {};
|
|
1242
|
+
def[tagName] = {
|
|
1028
1243
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1029
|
-
return
|
|
1244
|
+
return tagName;
|
|
1030
1245
|
}), "i"),
|
|
1031
|
-
lookbehind:
|
|
1032
|
-
greedy:
|
|
1033
|
-
inside
|
|
1034
|
-
}
|
|
1246
|
+
lookbehind: true,
|
|
1247
|
+
greedy: true,
|
|
1248
|
+
inside
|
|
1249
|
+
};
|
|
1250
|
+
Prism2.languages.insertBefore("markup", "cdata", def);
|
|
1035
1251
|
}
|
|
1036
|
-
})
|
|
1252
|
+
});
|
|
1253
|
+
Object.defineProperty(Prism2.languages.markup.tag, "addAttribute", {
|
|
1037
1254
|
/**
|
|
1038
1255
|
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
1039
1256
|
*
|
|
@@ -1045,25 +1262,25 @@ var fe = { exports: {} };
|
|
|
1045
1262
|
* @example
|
|
1046
1263
|
* addAttribute('style', 'css');
|
|
1047
1264
|
*/
|
|
1048
|
-
value: function(
|
|
1049
|
-
|
|
1265
|
+
value: function(attrName, lang) {
|
|
1266
|
+
Prism2.languages.markup.tag.inside["special-attr"].push({
|
|
1050
1267
|
pattern: RegExp(
|
|
1051
|
-
/(^|["'\s])/.source + "(?:" +
|
|
1268
|
+
/(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1052
1269
|
"i"
|
|
1053
1270
|
),
|
|
1054
|
-
lookbehind:
|
|
1271
|
+
lookbehind: true,
|
|
1055
1272
|
inside: {
|
|
1056
1273
|
"attr-name": /^[^\s=]+/,
|
|
1057
1274
|
"attr-value": {
|
|
1058
1275
|
pattern: /=[\s\S]+/,
|
|
1059
1276
|
inside: {
|
|
1060
|
-
value: {
|
|
1277
|
+
"value": {
|
|
1061
1278
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1062
|
-
lookbehind:
|
|
1063
|
-
alias: [
|
|
1064
|
-
inside:
|
|
1279
|
+
lookbehind: true,
|
|
1280
|
+
alias: [lang, "language-" + lang],
|
|
1281
|
+
inside: Prism2.languages[lang]
|
|
1065
1282
|
},
|
|
1066
|
-
punctuation: [
|
|
1283
|
+
"punctuation": [
|
|
1067
1284
|
{
|
|
1068
1285
|
pattern: /^=/,
|
|
1069
1286
|
alias: "attr-equals"
|
|
@@ -1075,111 +1292,125 @@ var fe = { exports: {} };
|
|
|
1075
1292
|
}
|
|
1076
1293
|
});
|
|
1077
1294
|
}
|
|
1078
|
-
})
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1295
|
+
});
|
|
1296
|
+
Prism2.languages.html = Prism2.languages.markup;
|
|
1297
|
+
Prism2.languages.mathml = Prism2.languages.markup;
|
|
1298
|
+
Prism2.languages.svg = Prism2.languages.markup;
|
|
1299
|
+
Prism2.languages.xml = Prism2.languages.extend("markup", {});
|
|
1300
|
+
Prism2.languages.ssml = Prism2.languages.xml;
|
|
1301
|
+
Prism2.languages.atom = Prism2.languages.xml;
|
|
1302
|
+
Prism2.languages.rss = Prism2.languages.xml;
|
|
1303
|
+
(function(Prism3) {
|
|
1304
|
+
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1305
|
+
Prism3.languages.css = {
|
|
1306
|
+
"comment": /\/\*[\s\S]*?\*\//,
|
|
1307
|
+
"atrule": {
|
|
1308
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + string.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1084
1309
|
inside: {
|
|
1085
|
-
rule: /^@[\w-]+/,
|
|
1310
|
+
"rule": /^@[\w-]+/,
|
|
1086
1311
|
"selector-function-argument": {
|
|
1087
1312
|
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
1088
|
-
lookbehind:
|
|
1313
|
+
lookbehind: true,
|
|
1089
1314
|
alias: "selector"
|
|
1090
1315
|
},
|
|
1091
|
-
keyword: {
|
|
1316
|
+
"keyword": {
|
|
1092
1317
|
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
1093
|
-
lookbehind:
|
|
1318
|
+
lookbehind: true
|
|
1094
1319
|
}
|
|
1095
1320
|
// See rest below
|
|
1096
1321
|
}
|
|
1097
1322
|
},
|
|
1098
|
-
url: {
|
|
1323
|
+
"url": {
|
|
1099
1324
|
// https://drafts.csswg.org/css-values-3/#urls
|
|
1100
|
-
pattern: RegExp("\\burl\\((?:" +
|
|
1101
|
-
greedy:
|
|
1325
|
+
pattern: RegExp("\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1326
|
+
greedy: true,
|
|
1102
1327
|
inside: {
|
|
1103
|
-
function: /^url/i,
|
|
1104
|
-
punctuation: /^\(|\)$/,
|
|
1105
|
-
string: {
|
|
1106
|
-
pattern: RegExp("^" +
|
|
1328
|
+
"function": /^url/i,
|
|
1329
|
+
"punctuation": /^\(|\)$/,
|
|
1330
|
+
"string": {
|
|
1331
|
+
pattern: RegExp("^" + string.source + "$"),
|
|
1107
1332
|
alias: "url"
|
|
1108
1333
|
}
|
|
1109
1334
|
}
|
|
1110
1335
|
},
|
|
1111
|
-
selector: {
|
|
1112
|
-
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` +
|
|
1113
|
-
lookbehind:
|
|
1336
|
+
"selector": {
|
|
1337
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"),
|
|
1338
|
+
lookbehind: true
|
|
1114
1339
|
},
|
|
1115
|
-
string: {
|
|
1116
|
-
pattern:
|
|
1117
|
-
greedy:
|
|
1340
|
+
"string": {
|
|
1341
|
+
pattern: string,
|
|
1342
|
+
greedy: true
|
|
1118
1343
|
},
|
|
1119
|
-
property: {
|
|
1344
|
+
"property": {
|
|
1120
1345
|
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
1121
|
-
lookbehind:
|
|
1346
|
+
lookbehind: true
|
|
1122
1347
|
},
|
|
1123
|
-
important: /!important\b/i,
|
|
1124
|
-
function: {
|
|
1348
|
+
"important": /!important\b/i,
|
|
1349
|
+
"function": {
|
|
1125
1350
|
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
1126
|
-
lookbehind:
|
|
1351
|
+
lookbehind: true
|
|
1127
1352
|
},
|
|
1128
|
-
punctuation: /[(){};:,]/
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1353
|
+
"punctuation": /[(){};:,]/
|
|
1354
|
+
};
|
|
1355
|
+
Prism3.languages.css["atrule"].inside.rest = Prism3.languages.css;
|
|
1356
|
+
var markup = Prism3.languages.markup;
|
|
1357
|
+
if (markup) {
|
|
1358
|
+
markup.tag.addInlined("style", "css");
|
|
1359
|
+
markup.tag.addAttribute("style", "css");
|
|
1360
|
+
}
|
|
1361
|
+
})(Prism2);
|
|
1362
|
+
Prism2.languages.clike = {
|
|
1363
|
+
"comment": [
|
|
1134
1364
|
{
|
|
1135
1365
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1136
|
-
lookbehind:
|
|
1137
|
-
greedy:
|
|
1366
|
+
lookbehind: true,
|
|
1367
|
+
greedy: true
|
|
1138
1368
|
},
|
|
1139
1369
|
{
|
|
1140
1370
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
1141
|
-
lookbehind:
|
|
1142
|
-
greedy:
|
|
1371
|
+
lookbehind: true,
|
|
1372
|
+
greedy: true
|
|
1143
1373
|
}
|
|
1144
1374
|
],
|
|
1145
|
-
string: {
|
|
1375
|
+
"string": {
|
|
1146
1376
|
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1147
|
-
greedy:
|
|
1377
|
+
greedy: true
|
|
1148
1378
|
},
|
|
1149
1379
|
"class-name": {
|
|
1150
1380
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1151
|
-
lookbehind:
|
|
1381
|
+
lookbehind: true,
|
|
1152
1382
|
inside: {
|
|
1153
|
-
punctuation: /[.\\]/
|
|
1383
|
+
"punctuation": /[.\\]/
|
|
1154
1384
|
}
|
|
1155
1385
|
},
|
|
1156
|
-
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1157
|
-
boolean: /\b(?:false|true)\b/,
|
|
1158
|
-
function: /\b\w+(?=\()/,
|
|
1159
|
-
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1160
|
-
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1161
|
-
punctuation: /[{}[\];(),.:]/
|
|
1162
|
-
}
|
|
1386
|
+
"keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1387
|
+
"boolean": /\b(?:false|true)\b/,
|
|
1388
|
+
"function": /\b\w+(?=\()/,
|
|
1389
|
+
"number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1390
|
+
"operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1391
|
+
"punctuation": /[{}[\];(),.:]/
|
|
1392
|
+
};
|
|
1393
|
+
Prism2.languages.javascript = Prism2.languages.extend("clike", {
|
|
1163
1394
|
"class-name": [
|
|
1164
|
-
|
|
1395
|
+
Prism2.languages.clike["class-name"],
|
|
1165
1396
|
{
|
|
1166
1397
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1167
|
-
lookbehind:
|
|
1398
|
+
lookbehind: true
|
|
1168
1399
|
}
|
|
1169
1400
|
],
|
|
1170
|
-
keyword: [
|
|
1401
|
+
"keyword": [
|
|
1171
1402
|
{
|
|
1172
1403
|
pattern: /((?:^|\})\s*)catch\b/,
|
|
1173
|
-
lookbehind:
|
|
1404
|
+
lookbehind: true
|
|
1174
1405
|
},
|
|
1175
1406
|
{
|
|
1176
1407
|
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/,
|
|
1177
|
-
lookbehind:
|
|
1408
|
+
lookbehind: true
|
|
1178
1409
|
}
|
|
1179
1410
|
],
|
|
1180
1411
|
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1181
|
-
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1182
|
-
number: {
|
|
1412
|
+
"function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1413
|
+
"number": {
|
|
1183
1414
|
pattern: RegExp(
|
|
1184
1415
|
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1185
1416
|
(/NaN|Infinity/.source + "|" + // binary integer
|
|
@@ -1189,11 +1420,13 @@ var fe = { exports: {} };
|
|
|
1189
1420
|
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1190
1421
|
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1191
1422
|
),
|
|
1192
|
-
lookbehind:
|
|
1423
|
+
lookbehind: true
|
|
1193
1424
|
},
|
|
1194
|
-
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1195
|
-
})
|
|
1196
|
-
|
|
1425
|
+
"operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1426
|
+
});
|
|
1427
|
+
Prism2.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
1428
|
+
Prism2.languages.insertBefore("javascript", "keyword", {
|
|
1429
|
+
"regex": {
|
|
1197
1430
|
pattern: RegExp(
|
|
1198
1431
|
// lookbehind
|
|
1199
1432
|
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
@@ -1205,14 +1438,14 @@ var fe = { exports: {} };
|
|
|
1205
1438
|
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1206
1439
|
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1207
1440
|
),
|
|
1208
|
-
lookbehind:
|
|
1209
|
-
greedy:
|
|
1441
|
+
lookbehind: true,
|
|
1442
|
+
greedy: true,
|
|
1210
1443
|
inside: {
|
|
1211
1444
|
"regex-source": {
|
|
1212
1445
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1213
|
-
lookbehind:
|
|
1446
|
+
lookbehind: true,
|
|
1214
1447
|
alias: "language-regex",
|
|
1215
|
-
inside:
|
|
1448
|
+
inside: Prism2.languages.regex
|
|
1216
1449
|
},
|
|
1217
1450
|
"regex-delimiter": /^\/|\/$/,
|
|
1218
1451
|
"regex-flags": /^[a-z]+$/
|
|
@@ -1223,138 +1456,200 @@ var fe = { exports: {} };
|
|
|
1223
1456
|
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*=>))/,
|
|
1224
1457
|
alias: "function"
|
|
1225
1458
|
},
|
|
1226
|
-
parameter: [
|
|
1459
|
+
"parameter": [
|
|
1227
1460
|
{
|
|
1228
1461
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1229
|
-
lookbehind:
|
|
1230
|
-
inside:
|
|
1462
|
+
lookbehind: true,
|
|
1463
|
+
inside: Prism2.languages.javascript
|
|
1231
1464
|
},
|
|
1232
1465
|
{
|
|
1233
1466
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1234
|
-
lookbehind:
|
|
1235
|
-
inside:
|
|
1467
|
+
lookbehind: true,
|
|
1468
|
+
inside: Prism2.languages.javascript
|
|
1236
1469
|
},
|
|
1237
1470
|
{
|
|
1238
1471
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1239
|
-
lookbehind:
|
|
1240
|
-
inside:
|
|
1472
|
+
lookbehind: true,
|
|
1473
|
+
inside: Prism2.languages.javascript
|
|
1241
1474
|
},
|
|
1242
1475
|
{
|
|
1243
1476
|
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*\{)/,
|
|
1244
|
-
lookbehind:
|
|
1245
|
-
inside:
|
|
1477
|
+
lookbehind: true,
|
|
1478
|
+
inside: Prism2.languages.javascript
|
|
1246
1479
|
}
|
|
1247
1480
|
],
|
|
1248
|
-
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1249
|
-
})
|
|
1250
|
-
|
|
1481
|
+
"constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1482
|
+
});
|
|
1483
|
+
Prism2.languages.insertBefore("javascript", "string", {
|
|
1484
|
+
"hashbang": {
|
|
1251
1485
|
pattern: /^#!.*/,
|
|
1252
|
-
greedy:
|
|
1486
|
+
greedy: true,
|
|
1253
1487
|
alias: "comment"
|
|
1254
1488
|
},
|
|
1255
1489
|
"template-string": {
|
|
1256
1490
|
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1257
|
-
greedy:
|
|
1491
|
+
greedy: true,
|
|
1258
1492
|
inside: {
|
|
1259
1493
|
"template-punctuation": {
|
|
1260
1494
|
pattern: /^`|`$/,
|
|
1261
1495
|
alias: "string"
|
|
1262
1496
|
},
|
|
1263
|
-
interpolation: {
|
|
1497
|
+
"interpolation": {
|
|
1264
1498
|
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1265
|
-
lookbehind:
|
|
1499
|
+
lookbehind: true,
|
|
1266
1500
|
inside: {
|
|
1267
1501
|
"interpolation-punctuation": {
|
|
1268
1502
|
pattern: /^\$\{|\}$/,
|
|
1269
1503
|
alias: "punctuation"
|
|
1270
1504
|
},
|
|
1271
|
-
rest:
|
|
1505
|
+
rest: Prism2.languages.javascript
|
|
1272
1506
|
}
|
|
1273
1507
|
},
|
|
1274
|
-
string: /[\s\S]+/
|
|
1508
|
+
"string": /[\s\S]+/
|
|
1275
1509
|
}
|
|
1276
1510
|
},
|
|
1277
1511
|
"string-property": {
|
|
1278
1512
|
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1279
|
-
lookbehind:
|
|
1280
|
-
greedy:
|
|
1513
|
+
lookbehind: true,
|
|
1514
|
+
greedy: true,
|
|
1281
1515
|
alias: "property"
|
|
1282
1516
|
}
|
|
1283
|
-
})
|
|
1517
|
+
});
|
|
1518
|
+
Prism2.languages.insertBefore("javascript", "operator", {
|
|
1284
1519
|
"literal-property": {
|
|
1285
1520
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1286
|
-
lookbehind:
|
|
1521
|
+
lookbehind: true,
|
|
1287
1522
|
alias: "property"
|
|
1288
1523
|
}
|
|
1289
|
-
})
|
|
1290
|
-
|
|
1291
|
-
"javascript"
|
|
1292
|
-
|
|
1293
|
-
|
|
1524
|
+
});
|
|
1525
|
+
if (Prism2.languages.markup) {
|
|
1526
|
+
Prism2.languages.markup.tag.addInlined("script", "javascript");
|
|
1527
|
+
Prism2.languages.markup.tag.addAttribute(
|
|
1528
|
+
/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,
|
|
1529
|
+
"javascript"
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
Prism2.languages.js = Prism2.languages.javascript;
|
|
1533
|
+
(function() {
|
|
1534
|
+
if (typeof Prism2 === "undefined" || typeof document === "undefined") {
|
|
1294
1535
|
return;
|
|
1295
|
-
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1296
|
-
var l = "Loading…", v = function(w, E) {
|
|
1297
|
-
return "✖ Error " + w + " while fetching file: " + E;
|
|
1298
|
-
}, _ = "✖ Error: File does not exist or is empty", S = {
|
|
1299
|
-
js: "javascript",
|
|
1300
|
-
py: "python",
|
|
1301
|
-
rb: "ruby",
|
|
1302
|
-
ps1: "powershell",
|
|
1303
|
-
psm1: "powershell",
|
|
1304
|
-
sh: "bash",
|
|
1305
|
-
bat: "batch",
|
|
1306
|
-
h: "c",
|
|
1307
|
-
tex: "latex"
|
|
1308
|
-
}, o = "data-src-status", f = "loading", b = "loaded", k = "failed", C = "pre[data-src]:not([" + o + '="' + b + '"]):not([' + o + '="' + f + '"])';
|
|
1309
|
-
function O(w, E, h) {
|
|
1310
|
-
var e = new XMLHttpRequest();
|
|
1311
|
-
e.open("GET", w, !0), e.onreadystatechange = function() {
|
|
1312
|
-
e.readyState == 4 && (e.status < 400 && e.responseText ? E(e.responseText) : e.status >= 400 ? h(v(e.status, e.statusText)) : h(_));
|
|
1313
|
-
}, e.send(null);
|
|
1314
1536
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1537
|
+
if (!Element.prototype.matches) {
|
|
1538
|
+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
1539
|
+
}
|
|
1540
|
+
var LOADING_MESSAGE = "Loading…";
|
|
1541
|
+
var FAILURE_MESSAGE = function(status, message) {
|
|
1542
|
+
return "✖ Error " + status + " while fetching file: " + message;
|
|
1543
|
+
};
|
|
1544
|
+
var FAILURE_EMPTY_MESSAGE = "✖ Error: File does not exist or is empty";
|
|
1545
|
+
var EXTENSIONS = {
|
|
1546
|
+
"js": "javascript",
|
|
1547
|
+
"py": "python",
|
|
1548
|
+
"rb": "ruby",
|
|
1549
|
+
"ps1": "powershell",
|
|
1550
|
+
"psm1": "powershell",
|
|
1551
|
+
"sh": "bash",
|
|
1552
|
+
"bat": "batch",
|
|
1553
|
+
"h": "c",
|
|
1554
|
+
"tex": "latex"
|
|
1555
|
+
};
|
|
1556
|
+
var STATUS_ATTR = "data-src-status";
|
|
1557
|
+
var STATUS_LOADING = "loading";
|
|
1558
|
+
var STATUS_LOADED = "loaded";
|
|
1559
|
+
var STATUS_FAILED = "failed";
|
|
1560
|
+
var SELECTOR = "pre[data-src]:not([" + STATUS_ATTR + '="' + STATUS_LOADED + '"]):not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
|
|
1561
|
+
function loadFile(src, success, error) {
|
|
1562
|
+
var xhr = new XMLHttpRequest();
|
|
1563
|
+
xhr.open("GET", src, true);
|
|
1564
|
+
xhr.onreadystatechange = function() {
|
|
1565
|
+
if (xhr.readyState == 4) {
|
|
1566
|
+
if (xhr.status < 400 && xhr.responseText) {
|
|
1567
|
+
success(xhr.responseText);
|
|
1568
|
+
} else {
|
|
1569
|
+
if (xhr.status >= 400) {
|
|
1570
|
+
error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
|
|
1571
|
+
} else {
|
|
1572
|
+
error(FAILURE_EMPTY_MESSAGE);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
xhr.send(null);
|
|
1578
|
+
}
|
|
1579
|
+
function parseRange(range) {
|
|
1580
|
+
var m2 = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || "");
|
|
1581
|
+
if (m2) {
|
|
1582
|
+
var start = Number(m2[1]);
|
|
1583
|
+
var comma = m2[2];
|
|
1584
|
+
var end = m2[3];
|
|
1585
|
+
if (!comma) {
|
|
1586
|
+
return [start, start];
|
|
1587
|
+
}
|
|
1588
|
+
if (!end) {
|
|
1589
|
+
return [start, void 0];
|
|
1590
|
+
}
|
|
1591
|
+
return [start, Number(end)];
|
|
1320
1592
|
}
|
|
1593
|
+
return void 0;
|
|
1321
1594
|
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
})
|
|
1325
|
-
|
|
1595
|
+
Prism2.hooks.add("before-highlightall", function(env) {
|
|
1596
|
+
env.selector += ", " + SELECTOR;
|
|
1597
|
+
});
|
|
1598
|
+
Prism2.hooks.add("before-sanity-check", function(env) {
|
|
1599
|
+
var pre = (
|
|
1326
1600
|
/** @type {HTMLPreElement} */
|
|
1327
|
-
|
|
1601
|
+
env.element
|
|
1328
1602
|
);
|
|
1329
|
-
if (
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1603
|
+
if (pre.matches(SELECTOR)) {
|
|
1604
|
+
env.code = "";
|
|
1605
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADING);
|
|
1606
|
+
var code = pre.appendChild(document.createElement("CODE"));
|
|
1607
|
+
code.textContent = LOADING_MESSAGE;
|
|
1608
|
+
var src = pre.getAttribute("data-src");
|
|
1609
|
+
var language = env.language;
|
|
1610
|
+
if (language === "none") {
|
|
1611
|
+
var extension = (/\.(\w+)$/.exec(src) || [, "none"])[1];
|
|
1612
|
+
language = EXTENSIONS[extension] || extension;
|
|
1337
1613
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1614
|
+
Prism2.util.setLanguage(code, language);
|
|
1615
|
+
Prism2.util.setLanguage(pre, language);
|
|
1616
|
+
var autoloader = Prism2.plugins.autoloader;
|
|
1617
|
+
if (autoloader) {
|
|
1618
|
+
autoloader.loadLanguages(language);
|
|
1619
|
+
}
|
|
1620
|
+
loadFile(
|
|
1621
|
+
src,
|
|
1622
|
+
function(text) {
|
|
1623
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
|
|
1624
|
+
var range = parseRange(pre.getAttribute("data-range"));
|
|
1625
|
+
if (range) {
|
|
1626
|
+
var lines = text.split(/\r\n?|\n/g);
|
|
1627
|
+
var start = range[0];
|
|
1628
|
+
var end = range[1] == null ? lines.length : range[1];
|
|
1629
|
+
if (start < 0) {
|
|
1630
|
+
start += lines.length;
|
|
1631
|
+
}
|
|
1632
|
+
start = Math.max(0, Math.min(start - 1, lines.length));
|
|
1633
|
+
if (end < 0) {
|
|
1634
|
+
end += lines.length;
|
|
1635
|
+
}
|
|
1636
|
+
end = Math.max(0, Math.min(end, lines.length));
|
|
1637
|
+
text = lines.slice(start, end).join("\n");
|
|
1638
|
+
if (!pre.hasAttribute("data-start")) {
|
|
1639
|
+
pre.setAttribute("data-start", String(start + 1));
|
|
1640
|
+
}
|
|
1349
1641
|
}
|
|
1350
|
-
|
|
1642
|
+
code.textContent = text;
|
|
1643
|
+
Prism2.highlightElement(code);
|
|
1351
1644
|
},
|
|
1352
|
-
function(
|
|
1353
|
-
|
|
1645
|
+
function(error) {
|
|
1646
|
+
pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
|
|
1647
|
+
code.textContent = error;
|
|
1354
1648
|
}
|
|
1355
1649
|
);
|
|
1356
1650
|
}
|
|
1357
|
-
})
|
|
1651
|
+
});
|
|
1652
|
+
Prism2.plugins.fileHighlight = {
|
|
1358
1653
|
/**
|
|
1359
1654
|
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
1360
1655
|
*
|
|
@@ -1362,71 +1657,77 @@ var fe = { exports: {} };
|
|
|
1362
1657
|
*
|
|
1363
1658
|
* @param {ParentNode} [container=document]
|
|
1364
1659
|
*/
|
|
1365
|
-
highlight: function(
|
|
1366
|
-
|
|
1367
|
-
|
|
1660
|
+
highlight: function highlight(container) {
|
|
1661
|
+
var elements = (container || document).querySelectorAll(SELECTOR);
|
|
1662
|
+
for (var i = 0, element; element = elements[i++]; ) {
|
|
1663
|
+
Prism2.highlightElement(element);
|
|
1664
|
+
}
|
|
1368
1665
|
}
|
|
1369
1666
|
};
|
|
1370
|
-
var
|
|
1371
|
-
|
|
1372
|
-
|
|
1667
|
+
var logged = false;
|
|
1668
|
+
Prism2.fileHighlight = function() {
|
|
1669
|
+
if (!logged) {
|
|
1670
|
+
console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.");
|
|
1671
|
+
logged = true;
|
|
1672
|
+
}
|
|
1673
|
+
Prism2.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1373
1674
|
};
|
|
1374
|
-
}();
|
|
1375
|
-
})(
|
|
1376
|
-
var
|
|
1377
|
-
const
|
|
1675
|
+
})();
|
|
1676
|
+
})(prism);
|
|
1677
|
+
var prismExports = prism.exports;
|
|
1678
|
+
const Prism$1 = /* @__PURE__ */ getDefaultExportFromCjs(prismExports);
|
|
1378
1679
|
Prism.languages.clike = {
|
|
1379
|
-
comment: [
|
|
1680
|
+
"comment": [
|
|
1380
1681
|
{
|
|
1381
1682
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1382
|
-
lookbehind:
|
|
1383
|
-
greedy:
|
|
1683
|
+
lookbehind: true,
|
|
1684
|
+
greedy: true
|
|
1384
1685
|
},
|
|
1385
1686
|
{
|
|
1386
1687
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
1387
|
-
lookbehind:
|
|
1388
|
-
greedy:
|
|
1688
|
+
lookbehind: true,
|
|
1689
|
+
greedy: true
|
|
1389
1690
|
}
|
|
1390
1691
|
],
|
|
1391
|
-
string: {
|
|
1692
|
+
"string": {
|
|
1392
1693
|
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1393
|
-
greedy:
|
|
1694
|
+
greedy: true
|
|
1394
1695
|
},
|
|
1395
1696
|
"class-name": {
|
|
1396
1697
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1397
|
-
lookbehind:
|
|
1698
|
+
lookbehind: true,
|
|
1398
1699
|
inside: {
|
|
1399
|
-
punctuation: /[.\\]/
|
|
1700
|
+
"punctuation": /[.\\]/
|
|
1400
1701
|
}
|
|
1401
1702
|
},
|
|
1402
|
-
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1403
|
-
boolean: /\b(?:false|true)\b/,
|
|
1404
|
-
function: /\b\w+(?=\()/,
|
|
1405
|
-
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1406
|
-
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1407
|
-
punctuation: /[{}[\];(),.:]/
|
|
1703
|
+
"keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1704
|
+
"boolean": /\b(?:false|true)\b/,
|
|
1705
|
+
"function": /\b\w+(?=\()/,
|
|
1706
|
+
"number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1707
|
+
"operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1708
|
+
"punctuation": /[{}[\];(),.:]/
|
|
1408
1709
|
};
|
|
1409
1710
|
Prism.languages.javascript = Prism.languages.extend("clike", {
|
|
1410
1711
|
"class-name": [
|
|
1411
1712
|
Prism.languages.clike["class-name"],
|
|
1412
1713
|
{
|
|
1413
1714
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1414
|
-
lookbehind:
|
|
1715
|
+
lookbehind: true
|
|
1415
1716
|
}
|
|
1416
1717
|
],
|
|
1417
|
-
keyword: [
|
|
1718
|
+
"keyword": [
|
|
1418
1719
|
{
|
|
1419
1720
|
pattern: /((?:^|\})\s*)catch\b/,
|
|
1420
|
-
lookbehind:
|
|
1721
|
+
lookbehind: true
|
|
1421
1722
|
},
|
|
1422
1723
|
{
|
|
1423
1724
|
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/,
|
|
1424
|
-
lookbehind:
|
|
1725
|
+
lookbehind: true
|
|
1425
1726
|
}
|
|
1426
1727
|
],
|
|
1427
1728
|
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1428
|
-
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1429
|
-
number: {
|
|
1729
|
+
"function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1730
|
+
"number": {
|
|
1430
1731
|
pattern: RegExp(
|
|
1431
1732
|
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1432
1733
|
(/NaN|Infinity/.source + "|" + // binary integer
|
|
@@ -1436,13 +1737,13 @@ Prism.languages.javascript = Prism.languages.extend("clike", {
|
|
|
1436
1737
|
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1437
1738
|
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1438
1739
|
),
|
|
1439
|
-
lookbehind:
|
|
1740
|
+
lookbehind: true
|
|
1440
1741
|
},
|
|
1441
|
-
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1742
|
+
"operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1442
1743
|
});
|
|
1443
1744
|
Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
1444
1745
|
Prism.languages.insertBefore("javascript", "keyword", {
|
|
1445
|
-
regex: {
|
|
1746
|
+
"regex": {
|
|
1446
1747
|
pattern: RegExp(
|
|
1447
1748
|
// lookbehind
|
|
1448
1749
|
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
@@ -1454,12 +1755,12 @@ Prism.languages.insertBefore("javascript", "keyword", {
|
|
|
1454
1755
|
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1455
1756
|
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1456
1757
|
),
|
|
1457
|
-
lookbehind:
|
|
1458
|
-
greedy:
|
|
1758
|
+
lookbehind: true,
|
|
1759
|
+
greedy: true,
|
|
1459
1760
|
inside: {
|
|
1460
1761
|
"regex-source": {
|
|
1461
1762
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1462
|
-
lookbehind:
|
|
1763
|
+
lookbehind: true,
|
|
1463
1764
|
alias: "language-regex",
|
|
1464
1765
|
inside: Prism.languages.regex
|
|
1465
1766
|
},
|
|
@@ -1472,47 +1773,47 @@ Prism.languages.insertBefore("javascript", "keyword", {
|
|
|
1472
1773
|
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*=>))/,
|
|
1473
1774
|
alias: "function"
|
|
1474
1775
|
},
|
|
1475
|
-
parameter: [
|
|
1776
|
+
"parameter": [
|
|
1476
1777
|
{
|
|
1477
1778
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1478
|
-
lookbehind:
|
|
1779
|
+
lookbehind: true,
|
|
1479
1780
|
inside: Prism.languages.javascript
|
|
1480
1781
|
},
|
|
1481
1782
|
{
|
|
1482
1783
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1483
|
-
lookbehind:
|
|
1784
|
+
lookbehind: true,
|
|
1484
1785
|
inside: Prism.languages.javascript
|
|
1485
1786
|
},
|
|
1486
1787
|
{
|
|
1487
1788
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1488
|
-
lookbehind:
|
|
1789
|
+
lookbehind: true,
|
|
1489
1790
|
inside: Prism.languages.javascript
|
|
1490
1791
|
},
|
|
1491
1792
|
{
|
|
1492
1793
|
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*\{)/,
|
|
1493
|
-
lookbehind:
|
|
1794
|
+
lookbehind: true,
|
|
1494
1795
|
inside: Prism.languages.javascript
|
|
1495
1796
|
}
|
|
1496
1797
|
],
|
|
1497
|
-
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1798
|
+
"constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1498
1799
|
});
|
|
1499
1800
|
Prism.languages.insertBefore("javascript", "string", {
|
|
1500
|
-
hashbang: {
|
|
1801
|
+
"hashbang": {
|
|
1501
1802
|
pattern: /^#!.*/,
|
|
1502
|
-
greedy:
|
|
1803
|
+
greedy: true,
|
|
1503
1804
|
alias: "comment"
|
|
1504
1805
|
},
|
|
1505
1806
|
"template-string": {
|
|
1506
1807
|
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1507
|
-
greedy:
|
|
1808
|
+
greedy: true,
|
|
1508
1809
|
inside: {
|
|
1509
1810
|
"template-punctuation": {
|
|
1510
1811
|
pattern: /^`|`$/,
|
|
1511
1812
|
alias: "string"
|
|
1512
1813
|
},
|
|
1513
|
-
interpolation: {
|
|
1814
|
+
"interpolation": {
|
|
1514
1815
|
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1515
|
-
lookbehind:
|
|
1816
|
+
lookbehind: true,
|
|
1516
1817
|
inside: {
|
|
1517
1818
|
"interpolation-punctuation": {
|
|
1518
1819
|
pattern: /^\$\{|\}$/,
|
|
@@ -1521,46 +1822,49 @@ Prism.languages.insertBefore("javascript", "string", {
|
|
|
1521
1822
|
rest: Prism.languages.javascript
|
|
1522
1823
|
}
|
|
1523
1824
|
},
|
|
1524
|
-
string: /[\s\S]+/
|
|
1825
|
+
"string": /[\s\S]+/
|
|
1525
1826
|
}
|
|
1526
1827
|
},
|
|
1527
1828
|
"string-property": {
|
|
1528
1829
|
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1529
|
-
lookbehind:
|
|
1530
|
-
greedy:
|
|
1830
|
+
lookbehind: true,
|
|
1831
|
+
greedy: true,
|
|
1531
1832
|
alias: "property"
|
|
1532
1833
|
}
|
|
1533
1834
|
});
|
|
1534
1835
|
Prism.languages.insertBefore("javascript", "operator", {
|
|
1535
1836
|
"literal-property": {
|
|
1536
1837
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1537
|
-
lookbehind:
|
|
1838
|
+
lookbehind: true,
|
|
1538
1839
|
alias: "property"
|
|
1539
1840
|
}
|
|
1540
1841
|
});
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
))
|
|
1842
|
+
if (Prism.languages.markup) {
|
|
1843
|
+
Prism.languages.markup.tag.addInlined("script", "javascript");
|
|
1844
|
+
Prism.languages.markup.tag.addAttribute(
|
|
1845
|
+
/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,
|
|
1846
|
+
"javascript"
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1545
1849
|
Prism.languages.js = Prism.languages.javascript;
|
|
1546
1850
|
Prism.languages.python = {
|
|
1547
|
-
comment: {
|
|
1851
|
+
"comment": {
|
|
1548
1852
|
pattern: /(^|[^\\])#.*/,
|
|
1549
|
-
lookbehind:
|
|
1550
|
-
greedy:
|
|
1853
|
+
lookbehind: true,
|
|
1854
|
+
greedy: true
|
|
1551
1855
|
},
|
|
1552
1856
|
"string-interpolation": {
|
|
1553
1857
|
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
1554
|
-
greedy:
|
|
1858
|
+
greedy: true,
|
|
1555
1859
|
inside: {
|
|
1556
|
-
interpolation: {
|
|
1860
|
+
"interpolation": {
|
|
1557
1861
|
// "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
|
1558
1862
|
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
1559
|
-
lookbehind:
|
|
1863
|
+
lookbehind: true,
|
|
1560
1864
|
inside: {
|
|
1561
1865
|
"format-spec": {
|
|
1562
1866
|
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
1563
|
-
lookbehind:
|
|
1867
|
+
lookbehind: true
|
|
1564
1868
|
},
|
|
1565
1869
|
"conversion-option": {
|
|
1566
1870
|
pattern: //,
|
|
@@ -1569,52 +1873,52 @@ Prism.languages.python = {
|
|
|
1569
1873
|
rest: null
|
|
1570
1874
|
}
|
|
1571
1875
|
},
|
|
1572
|
-
string: /[\s\S]+/
|
|
1876
|
+
"string": /[\s\S]+/
|
|
1573
1877
|
}
|
|
1574
1878
|
},
|
|
1575
1879
|
"triple-quoted-string": {
|
|
1576
1880
|
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
1577
|
-
greedy:
|
|
1881
|
+
greedy: true,
|
|
1578
1882
|
alias: "string"
|
|
1579
1883
|
},
|
|
1580
|
-
string: {
|
|
1884
|
+
"string": {
|
|
1581
1885
|
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
1582
|
-
greedy:
|
|
1886
|
+
greedy: true
|
|
1583
1887
|
},
|
|
1584
|
-
function: {
|
|
1888
|
+
"function": {
|
|
1585
1889
|
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
1586
|
-
lookbehind:
|
|
1890
|
+
lookbehind: true
|
|
1587
1891
|
},
|
|
1588
1892
|
"class-name": {
|
|
1589
1893
|
pattern: /(\bclass\s+)\w+/i,
|
|
1590
|
-
lookbehind:
|
|
1894
|
+
lookbehind: true
|
|
1591
1895
|
},
|
|
1592
|
-
decorator: {
|
|
1896
|
+
"decorator": {
|
|
1593
1897
|
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
1594
|
-
lookbehind:
|
|
1898
|
+
lookbehind: true,
|
|
1595
1899
|
alias: ["annotation", "punctuation"],
|
|
1596
1900
|
inside: {
|
|
1597
|
-
punctuation: /\./
|
|
1901
|
+
"punctuation": /\./
|
|
1598
1902
|
}
|
|
1599
1903
|
},
|
|
1600
|
-
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/,
|
|
1601
|
-
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/,
|
|
1602
|
-
boolean: /\b(?:False|None|True)\b/,
|
|
1603
|
-
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,
|
|
1604
|
-
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
1605
|
-
punctuation: /[{}[\];(),.:]/
|
|
1904
|
+
"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/,
|
|
1905
|
+
"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/,
|
|
1906
|
+
"boolean": /\b(?:False|None|True)\b/,
|
|
1907
|
+
"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,
|
|
1908
|
+
"operator": /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
1909
|
+
"punctuation": /[{}[\];(),.:]/
|
|
1606
1910
|
};
|
|
1607
|
-
Prism.languages.python["string-interpolation"].inside
|
|
1911
|
+
Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
|
|
1608
1912
|
Prism.languages.py = Prism.languages.python;
|
|
1609
1913
|
Prism.languages.go = Prism.languages.extend("clike", {
|
|
1610
|
-
string: {
|
|
1914
|
+
"string": {
|
|
1611
1915
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
|
|
1612
|
-
lookbehind:
|
|
1613
|
-
greedy:
|
|
1916
|
+
lookbehind: true,
|
|
1917
|
+
greedy: true
|
|
1614
1918
|
},
|
|
1615
|
-
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/,
|
|
1616
|
-
boolean: /\b(?:_|false|iota|nil|true)\b/,
|
|
1617
|
-
number: [
|
|
1919
|
+
"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/,
|
|
1920
|
+
"boolean": /\b(?:_|false|iota|nil|true)\b/,
|
|
1921
|
+
"number": [
|
|
1618
1922
|
// binary and octal integers
|
|
1619
1923
|
/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
|
|
1620
1924
|
// hexadecimal integers and floats
|
|
@@ -1622,195 +1926,199 @@ Prism.languages.go = Prism.languages.extend("clike", {
|
|
|
1622
1926
|
// decimal integers and floats
|
|
1623
1927
|
/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
|
|
1624
1928
|
],
|
|
1625
|
-
operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
1626
|
-
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/
|
|
1929
|
+
"operator": /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
1930
|
+
"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/
|
|
1627
1931
|
});
|
|
1628
1932
|
Prism.languages.insertBefore("go", "string", {
|
|
1629
|
-
char: {
|
|
1933
|
+
"char": {
|
|
1630
1934
|
pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
|
|
1631
|
-
greedy:
|
|
1935
|
+
greedy: true
|
|
1632
1936
|
}
|
|
1633
1937
|
});
|
|
1634
1938
|
delete Prism.languages.go["class-name"];
|
|
1635
|
-
(function(
|
|
1636
|
-
var
|
|
1637
|
-
|
|
1638
|
-
|
|
1939
|
+
(function(Prism2) {
|
|
1940
|
+
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/;
|
|
1941
|
+
var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
|
|
1942
|
+
var className = {
|
|
1943
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
|
|
1944
|
+
lookbehind: true,
|
|
1639
1945
|
inside: {
|
|
1640
|
-
namespace: {
|
|
1946
|
+
"namespace": {
|
|
1641
1947
|
pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
|
|
1642
1948
|
inside: {
|
|
1643
|
-
punctuation: /\./
|
|
1949
|
+
"punctuation": /\./
|
|
1644
1950
|
}
|
|
1645
1951
|
},
|
|
1646
|
-
punctuation: /\./
|
|
1952
|
+
"punctuation": /\./
|
|
1647
1953
|
}
|
|
1648
1954
|
};
|
|
1649
|
-
|
|
1650
|
-
string: {
|
|
1955
|
+
Prism2.languages.java = Prism2.languages.extend("clike", {
|
|
1956
|
+
"string": {
|
|
1651
1957
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
|
|
1652
|
-
lookbehind:
|
|
1653
|
-
greedy:
|
|
1958
|
+
lookbehind: true,
|
|
1959
|
+
greedy: true
|
|
1654
1960
|
},
|
|
1655
1961
|
"class-name": [
|
|
1656
|
-
|
|
1962
|
+
className,
|
|
1657
1963
|
{
|
|
1658
1964
|
// variables, parameters, and constructor references
|
|
1659
1965
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
1660
|
-
pattern: RegExp(/(^|[^\w.])/.source +
|
|
1661
|
-
lookbehind:
|
|
1662
|
-
inside:
|
|
1966
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
|
|
1967
|
+
lookbehind: true,
|
|
1968
|
+
inside: className.inside
|
|
1663
1969
|
},
|
|
1664
1970
|
{
|
|
1665
1971
|
// class names based on keyword
|
|
1666
1972
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
1667
|
-
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source +
|
|
1668
|
-
lookbehind:
|
|
1669
|
-
inside:
|
|
1973
|
+
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
|
|
1974
|
+
lookbehind: true,
|
|
1975
|
+
inside: className.inside
|
|
1670
1976
|
}
|
|
1671
1977
|
],
|
|
1672
|
-
keyword:
|
|
1673
|
-
function: [
|
|
1674
|
-
|
|
1978
|
+
"keyword": keywords,
|
|
1979
|
+
"function": [
|
|
1980
|
+
Prism2.languages.clike.function,
|
|
1675
1981
|
{
|
|
1676
1982
|
pattern: /(::\s*)[a-z_]\w*/,
|
|
1677
|
-
lookbehind:
|
|
1983
|
+
lookbehind: true
|
|
1678
1984
|
}
|
|
1679
1985
|
],
|
|
1680
|
-
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,
|
|
1681
|
-
operator: {
|
|
1986
|
+
"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,
|
|
1987
|
+
"operator": {
|
|
1682
1988
|
pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
|
1683
|
-
lookbehind:
|
|
1989
|
+
lookbehind: true
|
|
1684
1990
|
},
|
|
1685
|
-
constant: /\b[A-Z][A-Z_\d]+\b/
|
|
1686
|
-
})
|
|
1991
|
+
"constant": /\b[A-Z][A-Z_\d]+\b/
|
|
1992
|
+
});
|
|
1993
|
+
Prism2.languages.insertBefore("java", "string", {
|
|
1687
1994
|
"triple-quoted-string": {
|
|
1688
1995
|
// http://openjdk.java.net/jeps/355#Description
|
|
1689
1996
|
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
1690
|
-
greedy:
|
|
1997
|
+
greedy: true,
|
|
1691
1998
|
alias: "string"
|
|
1692
1999
|
},
|
|
1693
|
-
char: {
|
|
2000
|
+
"char": {
|
|
1694
2001
|
pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
|
|
1695
|
-
greedy:
|
|
2002
|
+
greedy: true
|
|
1696
2003
|
}
|
|
1697
|
-
})
|
|
1698
|
-
|
|
2004
|
+
});
|
|
2005
|
+
Prism2.languages.insertBefore("java", "class-name", {
|
|
2006
|
+
"annotation": {
|
|
1699
2007
|
pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
|
|
1700
|
-
lookbehind:
|
|
2008
|
+
lookbehind: true,
|
|
1701
2009
|
alias: "punctuation"
|
|
1702
2010
|
},
|
|
1703
|
-
generics: {
|
|
2011
|
+
"generics": {
|
|
1704
2012
|
pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
|
|
1705
2013
|
inside: {
|
|
1706
|
-
"class-name":
|
|
1707
|
-
keyword:
|
|
1708
|
-
punctuation: /[<>(),.:]/,
|
|
1709
|
-
operator: /[?&|]/
|
|
2014
|
+
"class-name": className,
|
|
2015
|
+
"keyword": keywords,
|
|
2016
|
+
"punctuation": /[<>(),.:]/,
|
|
2017
|
+
"operator": /[?&|]/
|
|
1710
2018
|
}
|
|
1711
2019
|
},
|
|
1712
|
-
import: [
|
|
2020
|
+
"import": [
|
|
1713
2021
|
{
|
|
1714
|
-
pattern: RegExp(/(\bimport\s+)/.source +
|
|
1715
|
-
lookbehind:
|
|
2022
|
+
pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
|
|
2023
|
+
lookbehind: true,
|
|
1716
2024
|
inside: {
|
|
1717
|
-
namespace:
|
|
1718
|
-
punctuation: /\./,
|
|
1719
|
-
operator: /\*/,
|
|
2025
|
+
"namespace": className.inside.namespace,
|
|
2026
|
+
"punctuation": /\./,
|
|
2027
|
+
"operator": /\*/,
|
|
1720
2028
|
"class-name": /\w+/
|
|
1721
2029
|
}
|
|
1722
2030
|
},
|
|
1723
2031
|
{
|
|
1724
|
-
pattern: RegExp(/(\bimport\s+static\s+)/.source +
|
|
1725
|
-
lookbehind:
|
|
2032
|
+
pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
|
|
2033
|
+
lookbehind: true,
|
|
1726
2034
|
alias: "static",
|
|
1727
2035
|
inside: {
|
|
1728
|
-
namespace:
|
|
1729
|
-
static: /\b\w+$/,
|
|
1730
|
-
punctuation: /\./,
|
|
1731
|
-
operator: /\*/,
|
|
2036
|
+
"namespace": className.inside.namespace,
|
|
2037
|
+
"static": /\b\w+$/,
|
|
2038
|
+
"punctuation": /\./,
|
|
2039
|
+
"operator": /\*/,
|
|
1732
2040
|
"class-name": /\w+/
|
|
1733
2041
|
}
|
|
1734
2042
|
}
|
|
1735
2043
|
],
|
|
1736
|
-
namespace: {
|
|
2044
|
+
"namespace": {
|
|
1737
2045
|
pattern: RegExp(
|
|
1738
2046
|
/(\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() {
|
|
1739
|
-
return
|
|
2047
|
+
return keywords.source;
|
|
1740
2048
|
})
|
|
1741
2049
|
),
|
|
1742
|
-
lookbehind:
|
|
2050
|
+
lookbehind: true,
|
|
1743
2051
|
inside: {
|
|
1744
|
-
punctuation: /\./
|
|
2052
|
+
"punctuation": /\./
|
|
1745
2053
|
}
|
|
1746
2054
|
}
|
|
1747
2055
|
});
|
|
1748
2056
|
})(Prism);
|
|
1749
2057
|
Prism.languages.c = Prism.languages.extend("clike", {
|
|
1750
|
-
comment: {
|
|
2058
|
+
"comment": {
|
|
1751
2059
|
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1752
|
-
greedy:
|
|
2060
|
+
greedy: true
|
|
1753
2061
|
},
|
|
1754
|
-
string: {
|
|
2062
|
+
"string": {
|
|
1755
2063
|
// https://en.cppreference.com/w/c/language/string_literal
|
|
1756
2064
|
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
1757
|
-
greedy:
|
|
2065
|
+
greedy: true
|
|
1758
2066
|
},
|
|
1759
2067
|
"class-name": {
|
|
1760
2068
|
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
1761
|
-
lookbehind:
|
|
2069
|
+
lookbehind: true
|
|
1762
2070
|
},
|
|
1763
|
-
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/,
|
|
1764
|
-
function: /\b[a-z_]\w*(?=\s*\()/i,
|
|
1765
|
-
number: /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
1766
|
-
operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
2071
|
+
"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/,
|
|
2072
|
+
"function": /\b[a-z_]\w*(?=\s*\()/i,
|
|
2073
|
+
"number": /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
2074
|
+
"operator": />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
1767
2075
|
});
|
|
1768
2076
|
Prism.languages.insertBefore("c", "string", {
|
|
1769
|
-
char: {
|
|
2077
|
+
"char": {
|
|
1770
2078
|
// https://en.cppreference.com/w/c/language/character_constant
|
|
1771
2079
|
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
1772
|
-
greedy:
|
|
2080
|
+
greedy: true
|
|
1773
2081
|
}
|
|
1774
2082
|
});
|
|
1775
2083
|
Prism.languages.insertBefore("c", "string", {
|
|
1776
|
-
macro: {
|
|
2084
|
+
"macro": {
|
|
1777
2085
|
// allow for multiline macro definitions
|
|
1778
2086
|
// spaces after the # character compile fine with gcc
|
|
1779
2087
|
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
1780
|
-
lookbehind:
|
|
1781
|
-
greedy:
|
|
2088
|
+
lookbehind: true,
|
|
2089
|
+
greedy: true,
|
|
1782
2090
|
alias: "property",
|
|
1783
2091
|
inside: {
|
|
1784
|
-
string: [
|
|
2092
|
+
"string": [
|
|
1785
2093
|
{
|
|
1786
2094
|
// highlight the path of the include statement as a string
|
|
1787
2095
|
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
1788
|
-
lookbehind:
|
|
2096
|
+
lookbehind: true
|
|
1789
2097
|
},
|
|
1790
|
-
Prism.languages.c
|
|
2098
|
+
Prism.languages.c["string"]
|
|
1791
2099
|
],
|
|
1792
|
-
char: Prism.languages.c
|
|
1793
|
-
comment: Prism.languages.c
|
|
2100
|
+
"char": Prism.languages.c["char"],
|
|
2101
|
+
"comment": Prism.languages.c["comment"],
|
|
1794
2102
|
"macro-name": [
|
|
1795
2103
|
{
|
|
1796
2104
|
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
1797
|
-
lookbehind:
|
|
2105
|
+
lookbehind: true
|
|
1798
2106
|
},
|
|
1799
2107
|
{
|
|
1800
2108
|
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
1801
|
-
lookbehind:
|
|
2109
|
+
lookbehind: true,
|
|
1802
2110
|
alias: "function"
|
|
1803
2111
|
}
|
|
1804
2112
|
],
|
|
1805
2113
|
// highlight macro directives as keywords
|
|
1806
|
-
directive: {
|
|
2114
|
+
"directive": {
|
|
1807
2115
|
pattern: /^(#\s*)[a-z]+/,
|
|
1808
|
-
lookbehind:
|
|
2116
|
+
lookbehind: true,
|
|
1809
2117
|
alias: "keyword"
|
|
1810
2118
|
},
|
|
1811
2119
|
"directive-hash": /^#/,
|
|
1812
|
-
punctuation: /##|\\(?=[\r\n])/,
|
|
1813
|
-
expression: {
|
|
2120
|
+
"punctuation": /##|\\(?=[\r\n])/,
|
|
2121
|
+
"expression": {
|
|
1814
2122
|
pattern: /\S[\s\S]*/,
|
|
1815
2123
|
inside: Prism.languages.c
|
|
1816
2124
|
}
|
|
@@ -1819,51 +2127,54 @@ Prism.languages.insertBefore("c", "string", {
|
|
|
1819
2127
|
});
|
|
1820
2128
|
Prism.languages.insertBefore("c", "function", {
|
|
1821
2129
|
// highlight predefined macros as constants
|
|
1822
|
-
constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
2130
|
+
"constant": /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
1823
2131
|
});
|
|
1824
|
-
delete Prism.languages.c
|
|
1825
|
-
(function(
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2132
|
+
delete Prism.languages.c["boolean"];
|
|
2133
|
+
(function(Prism2) {
|
|
2134
|
+
var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
|
|
2135
|
+
for (var i = 0; i < 2; i++) {
|
|
2136
|
+
multilineComment = multilineComment.replace(/<self>/g, function() {
|
|
2137
|
+
return multilineComment;
|
|
1829
2138
|
});
|
|
1830
|
-
|
|
2139
|
+
}
|
|
2140
|
+
multilineComment = multilineComment.replace(/<self>/g, function() {
|
|
1831
2141
|
return /[^\s\S]/.source;
|
|
1832
|
-
})
|
|
1833
|
-
|
|
2142
|
+
});
|
|
2143
|
+
Prism2.languages.rust = {
|
|
2144
|
+
"comment": [
|
|
1834
2145
|
{
|
|
1835
|
-
pattern: RegExp(/(^|[^\\])/.source +
|
|
1836
|
-
lookbehind:
|
|
1837
|
-
greedy:
|
|
2146
|
+
pattern: RegExp(/(^|[^\\])/.source + multilineComment),
|
|
2147
|
+
lookbehind: true,
|
|
2148
|
+
greedy: true
|
|
1838
2149
|
},
|
|
1839
2150
|
{
|
|
1840
2151
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
1841
|
-
lookbehind:
|
|
1842
|
-
greedy:
|
|
2152
|
+
lookbehind: true,
|
|
2153
|
+
greedy: true
|
|
1843
2154
|
}
|
|
1844
2155
|
],
|
|
1845
|
-
string: {
|
|
2156
|
+
"string": {
|
|
1846
2157
|
pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
|
|
1847
|
-
greedy:
|
|
2158
|
+
greedy: true
|
|
1848
2159
|
},
|
|
1849
|
-
char: {
|
|
2160
|
+
"char": {
|
|
1850
2161
|
pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
|
|
1851
|
-
greedy:
|
|
2162
|
+
greedy: true
|
|
1852
2163
|
},
|
|
1853
|
-
attribute: {
|
|
2164
|
+
"attribute": {
|
|
1854
2165
|
pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
|
|
1855
|
-
greedy:
|
|
2166
|
+
greedy: true,
|
|
1856
2167
|
alias: "attr-name",
|
|
1857
2168
|
inside: {
|
|
1858
|
-
string: null
|
|
2169
|
+
"string": null
|
|
1859
2170
|
// see below
|
|
1860
2171
|
}
|
|
1861
2172
|
},
|
|
1862
2173
|
// Closure params should not be confused with bitwise OR |
|
|
1863
2174
|
"closure-params": {
|
|
1864
2175
|
pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
|
|
1865
|
-
lookbehind:
|
|
1866
|
-
greedy:
|
|
2176
|
+
lookbehind: true,
|
|
2177
|
+
greedy: true,
|
|
1867
2178
|
inside: {
|
|
1868
2179
|
"closure-punctuation": {
|
|
1869
2180
|
pattern: /^\||\|$/,
|
|
@@ -1879,36 +2190,36 @@ delete Prism.languages.c.boolean;
|
|
|
1879
2190
|
},
|
|
1880
2191
|
"fragment-specifier": {
|
|
1881
2192
|
pattern: /(\$\w+:)[a-z]+/,
|
|
1882
|
-
lookbehind:
|
|
2193
|
+
lookbehind: true,
|
|
1883
2194
|
alias: "punctuation"
|
|
1884
2195
|
},
|
|
1885
|
-
variable: /\$\w+/,
|
|
2196
|
+
"variable": /\$\w+/,
|
|
1886
2197
|
"function-definition": {
|
|
1887
2198
|
pattern: /(\bfn\s+)\w+/,
|
|
1888
|
-
lookbehind:
|
|
2199
|
+
lookbehind: true,
|
|
1889
2200
|
alias: "function"
|
|
1890
2201
|
},
|
|
1891
2202
|
"type-definition": {
|
|
1892
2203
|
pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
|
|
1893
|
-
lookbehind:
|
|
2204
|
+
lookbehind: true,
|
|
1894
2205
|
alias: "class-name"
|
|
1895
2206
|
},
|
|
1896
2207
|
"module-declaration": [
|
|
1897
2208
|
{
|
|
1898
2209
|
pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
|
|
1899
|
-
lookbehind:
|
|
2210
|
+
lookbehind: true,
|
|
1900
2211
|
alias: "namespace"
|
|
1901
2212
|
},
|
|
1902
2213
|
{
|
|
1903
2214
|
pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
|
|
1904
|
-
lookbehind:
|
|
2215
|
+
lookbehind: true,
|
|
1905
2216
|
alias: "namespace",
|
|
1906
2217
|
inside: {
|
|
1907
|
-
punctuation: /::/
|
|
2218
|
+
"punctuation": /::/
|
|
1908
2219
|
}
|
|
1909
2220
|
}
|
|
1910
2221
|
],
|
|
1911
|
-
keyword: [
|
|
2222
|
+
"keyword": [
|
|
1912
2223
|
// https://github.com/rust-lang/reference/blob/master/src/keywords.md
|
|
1913
2224
|
/\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/,
|
|
1914
2225
|
// primitives and str
|
|
@@ -1918,112 +2229,116 @@ delete Prism.languages.c.boolean;
|
|
|
1918
2229
|
// functions can technically start with an upper-case letter, but this will introduce a lot of false positives
|
|
1919
2230
|
// and Rust's naming conventions recommend snake_case anyway.
|
|
1920
2231
|
// https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
|
|
1921
|
-
function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
1922
|
-
macro: {
|
|
2232
|
+
"function": /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
2233
|
+
"macro": {
|
|
1923
2234
|
pattern: /\b\w+!/,
|
|
1924
2235
|
alias: "property"
|
|
1925
2236
|
},
|
|
1926
|
-
constant: /\b[A-Z_][A-Z_\d]+\b/,
|
|
2237
|
+
"constant": /\b[A-Z_][A-Z_\d]+\b/,
|
|
1927
2238
|
"class-name": /\b[A-Z]\w*\b/,
|
|
1928
|
-
namespace: {
|
|
2239
|
+
"namespace": {
|
|
1929
2240
|
pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
|
|
1930
2241
|
inside: {
|
|
1931
|
-
punctuation: /::/
|
|
2242
|
+
"punctuation": /::/
|
|
1932
2243
|
}
|
|
1933
2244
|
},
|
|
1934
2245
|
// Hex, oct, bin, dec numbers with visual separators and type suffix
|
|
1935
|
-
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/,
|
|
1936
|
-
boolean: /\b(?:false|true)\b/,
|
|
1937
|
-
punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
1938
|
-
operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
1939
|
-
}
|
|
2246
|
+
"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/,
|
|
2247
|
+
"boolean": /\b(?:false|true)\b/,
|
|
2248
|
+
"punctuation": /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
2249
|
+
"operator": /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
2250
|
+
};
|
|
2251
|
+
Prism2.languages.rust["closure-params"].inside.rest = Prism2.languages.rust;
|
|
2252
|
+
Prism2.languages.rust["attribute"].inside["string"] = Prism2.languages.rust["string"];
|
|
1940
2253
|
})(Prism);
|
|
1941
2254
|
Prism.languages.sql = {
|
|
1942
|
-
comment: {
|
|
2255
|
+
"comment": {
|
|
1943
2256
|
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
|
1944
|
-
lookbehind:
|
|
2257
|
+
lookbehind: true
|
|
1945
2258
|
},
|
|
1946
|
-
variable: [
|
|
2259
|
+
"variable": [
|
|
1947
2260
|
{
|
|
1948
2261
|
pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
|
|
1949
|
-
greedy:
|
|
2262
|
+
greedy: true
|
|
1950
2263
|
},
|
|
1951
2264
|
/@[\w.$]+/
|
|
1952
2265
|
],
|
|
1953
|
-
string: {
|
|
2266
|
+
"string": {
|
|
1954
2267
|
pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
|
|
1955
|
-
greedy:
|
|
1956
|
-
lookbehind:
|
|
2268
|
+
greedy: true,
|
|
2269
|
+
lookbehind: true
|
|
1957
2270
|
},
|
|
1958
|
-
identifier: {
|
|
2271
|
+
"identifier": {
|
|
1959
2272
|
pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
|
|
1960
|
-
greedy:
|
|
1961
|
-
lookbehind:
|
|
2273
|
+
greedy: true,
|
|
2274
|
+
lookbehind: true,
|
|
1962
2275
|
inside: {
|
|
1963
|
-
punctuation: /^`|`$/
|
|
2276
|
+
"punctuation": /^`|`$/
|
|
1964
2277
|
}
|
|
1965
2278
|
},
|
|
1966
|
-
function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
2279
|
+
"function": /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
1967
2280
|
// Should we highlight user defined functions too?
|
|
1968
|
-
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,
|
|
1969
|
-
boolean: /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
1970
|
-
number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
1971
|
-
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
1972
|
-
punctuation: /[;[\]()`,.]/
|
|
2281
|
+
"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,
|
|
2282
|
+
"boolean": /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
2283
|
+
"number": /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
2284
|
+
"operator": /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
2285
|
+
"punctuation": /[;[\]()`,.]/
|
|
1973
2286
|
};
|
|
1974
|
-
(function(
|
|
1975
|
-
var
|
|
2287
|
+
(function(Prism2) {
|
|
2288
|
+
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";
|
|
2289
|
+
var commandAfterHeredoc = {
|
|
1976
2290
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
1977
|
-
lookbehind:
|
|
2291
|
+
lookbehind: true,
|
|
1978
2292
|
alias: "punctuation",
|
|
1979
2293
|
// this looks reasonably well in all themes
|
|
1980
2294
|
inside: null
|
|
1981
2295
|
// see below
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
2296
|
+
};
|
|
2297
|
+
var insideString = {
|
|
2298
|
+
"bash": commandAfterHeredoc,
|
|
2299
|
+
"environment": {
|
|
2300
|
+
pattern: RegExp("\\$" + envVars),
|
|
1986
2301
|
alias: "constant"
|
|
1987
2302
|
},
|
|
1988
|
-
variable: [
|
|
2303
|
+
"variable": [
|
|
1989
2304
|
// [0]: Arithmetic Environment
|
|
1990
2305
|
{
|
|
1991
2306
|
pattern: /\$?\(\([\s\S]+?\)\)/,
|
|
1992
|
-
greedy:
|
|
2307
|
+
greedy: true,
|
|
1993
2308
|
inside: {
|
|
1994
2309
|
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
|
1995
|
-
variable: [
|
|
2310
|
+
"variable": [
|
|
1996
2311
|
{
|
|
1997
2312
|
pattern: /(^\$\(\([\s\S]+)\)\)/,
|
|
1998
|
-
lookbehind:
|
|
2313
|
+
lookbehind: true
|
|
1999
2314
|
},
|
|
2000
2315
|
/^\$\(\(/
|
|
2001
2316
|
],
|
|
2002
|
-
number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
2317
|
+
"number": /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
2003
2318
|
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
|
2004
|
-
operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
2319
|
+
"operator": /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
2005
2320
|
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
|
2006
|
-
punctuation: /\(\(?|\)\)?|,|;/
|
|
2321
|
+
"punctuation": /\(\(?|\)\)?|,|;/
|
|
2007
2322
|
}
|
|
2008
2323
|
},
|
|
2009
2324
|
// [1]: Command Substitution
|
|
2010
2325
|
{
|
|
2011
2326
|
pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
|
2012
|
-
greedy:
|
|
2327
|
+
greedy: true,
|
|
2013
2328
|
inside: {
|
|
2014
|
-
variable: /^\$\(|^`|\)$|`$/
|
|
2329
|
+
"variable": /^\$\(|^`|\)$|`$/
|
|
2015
2330
|
}
|
|
2016
2331
|
},
|
|
2017
2332
|
// [2]: Brace expansion
|
|
2018
2333
|
{
|
|
2019
2334
|
pattern: /\$\{[^}]+\}/,
|
|
2020
|
-
greedy:
|
|
2335
|
+
greedy: true,
|
|
2021
2336
|
inside: {
|
|
2022
|
-
operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
2023
|
-
punctuation: /[\[\]]/,
|
|
2024
|
-
environment: {
|
|
2025
|
-
pattern: RegExp("(\\{)" +
|
|
2026
|
-
lookbehind:
|
|
2337
|
+
"operator": /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
2338
|
+
"punctuation": /[\[\]]/,
|
|
2339
|
+
"environment": {
|
|
2340
|
+
pattern: RegExp("(\\{)" + envVars),
|
|
2341
|
+
lookbehind: true,
|
|
2027
2342
|
alias: "constant"
|
|
2028
2343
|
}
|
|
2029
2344
|
}
|
|
@@ -2031,16 +2346,16 @@ Prism.languages.sql = {
|
|
|
2031
2346
|
/\$(?:\w+|[#?*!@$])/
|
|
2032
2347
|
],
|
|
2033
2348
|
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
2034
|
-
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})/
|
|
2349
|
+
"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})/
|
|
2035
2350
|
};
|
|
2036
|
-
|
|
2037
|
-
shebang: {
|
|
2351
|
+
Prism2.languages.bash = {
|
|
2352
|
+
"shebang": {
|
|
2038
2353
|
pattern: /^#!\s*\/.*/,
|
|
2039
2354
|
alias: "important"
|
|
2040
2355
|
},
|
|
2041
|
-
comment: {
|
|
2356
|
+
"comment": {
|
|
2042
2357
|
pattern: /(^|[^"{\\$])#.*/,
|
|
2043
|
-
lookbehind:
|
|
2358
|
+
lookbehind: true
|
|
2044
2359
|
},
|
|
2045
2360
|
"function-name": [
|
|
2046
2361
|
// a) function foo {
|
|
@@ -2050,7 +2365,7 @@ Prism.languages.sql = {
|
|
|
2050
2365
|
{
|
|
2051
2366
|
// a) and c)
|
|
2052
2367
|
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
|
2053
|
-
lookbehind:
|
|
2368
|
+
lookbehind: true,
|
|
2054
2369
|
alias: "function"
|
|
2055
2370
|
},
|
|
2056
2371
|
{
|
|
@@ -2063,98 +2378,98 @@ Prism.languages.sql = {
|
|
|
2063
2378
|
"for-or-select": {
|
|
2064
2379
|
pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
|
2065
2380
|
alias: "variable",
|
|
2066
|
-
lookbehind:
|
|
2381
|
+
lookbehind: true
|
|
2067
2382
|
},
|
|
2068
2383
|
// Highlight variable names as variables in the left-hand part
|
|
2069
2384
|
// of assignments (“=” and “+=”).
|
|
2070
2385
|
"assign-left": {
|
|
2071
2386
|
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
2072
2387
|
inside: {
|
|
2073
|
-
environment: {
|
|
2074
|
-
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" +
|
|
2075
|
-
lookbehind:
|
|
2388
|
+
"environment": {
|
|
2389
|
+
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
|
|
2390
|
+
lookbehind: true,
|
|
2076
2391
|
alias: "constant"
|
|
2077
2392
|
}
|
|
2078
2393
|
},
|
|
2079
2394
|
alias: "variable",
|
|
2080
|
-
lookbehind:
|
|
2395
|
+
lookbehind: true
|
|
2081
2396
|
},
|
|
2082
2397
|
// Highlight parameter names as variables
|
|
2083
|
-
parameter: {
|
|
2398
|
+
"parameter": {
|
|
2084
2399
|
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
|
|
2085
2400
|
alias: "variable",
|
|
2086
|
-
lookbehind:
|
|
2401
|
+
lookbehind: true
|
|
2087
2402
|
},
|
|
2088
|
-
string: [
|
|
2403
|
+
"string": [
|
|
2089
2404
|
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
|
|
2090
2405
|
{
|
|
2091
2406
|
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
2092
|
-
lookbehind:
|
|
2093
|
-
greedy:
|
|
2094
|
-
inside:
|
|
2407
|
+
lookbehind: true,
|
|
2408
|
+
greedy: true,
|
|
2409
|
+
inside: insideString
|
|
2095
2410
|
},
|
|
2096
2411
|
// Here-document with quotes around the tag
|
|
2097
2412
|
// → No expansion (so no “inside”).
|
|
2098
2413
|
{
|
|
2099
2414
|
pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
|
2100
|
-
lookbehind:
|
|
2101
|
-
greedy:
|
|
2415
|
+
lookbehind: true,
|
|
2416
|
+
greedy: true,
|
|
2102
2417
|
inside: {
|
|
2103
|
-
bash:
|
|
2418
|
+
"bash": commandAfterHeredoc
|
|
2104
2419
|
}
|
|
2105
2420
|
},
|
|
2106
2421
|
// “Normal” string
|
|
2107
2422
|
{
|
|
2108
2423
|
// https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
|
|
2109
2424
|
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
2110
|
-
lookbehind:
|
|
2111
|
-
greedy:
|
|
2112
|
-
inside:
|
|
2425
|
+
lookbehind: true,
|
|
2426
|
+
greedy: true,
|
|
2427
|
+
inside: insideString
|
|
2113
2428
|
},
|
|
2114
2429
|
{
|
|
2115
2430
|
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
2116
2431
|
pattern: /(^|[^$\\])'[^']*'/,
|
|
2117
|
-
lookbehind:
|
|
2118
|
-
greedy:
|
|
2432
|
+
lookbehind: true,
|
|
2433
|
+
greedy: true
|
|
2119
2434
|
},
|
|
2120
2435
|
{
|
|
2121
2436
|
// https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
|
|
2122
2437
|
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
2123
|
-
greedy:
|
|
2438
|
+
greedy: true,
|
|
2124
2439
|
inside: {
|
|
2125
|
-
entity:
|
|
2440
|
+
"entity": insideString.entity
|
|
2126
2441
|
}
|
|
2127
2442
|
}
|
|
2128
2443
|
],
|
|
2129
|
-
environment: {
|
|
2130
|
-
pattern: RegExp("\\$?" +
|
|
2444
|
+
"environment": {
|
|
2445
|
+
pattern: RegExp("\\$?" + envVars),
|
|
2131
2446
|
alias: "constant"
|
|
2132
2447
|
},
|
|
2133
|
-
variable:
|
|
2134
|
-
function: {
|
|
2448
|
+
"variable": insideString.variable,
|
|
2449
|
+
"function": {
|
|
2135
2450
|
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;|&])/,
|
|
2136
|
-
lookbehind:
|
|
2451
|
+
lookbehind: true
|
|
2137
2452
|
},
|
|
2138
|
-
keyword: {
|
|
2453
|
+
"keyword": {
|
|
2139
2454
|
pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
|
2140
|
-
lookbehind:
|
|
2455
|
+
lookbehind: true
|
|
2141
2456
|
},
|
|
2142
2457
|
// https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
|
2143
|
-
builtin: {
|
|
2458
|
+
"builtin": {
|
|
2144
2459
|
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;|&])/,
|
|
2145
|
-
lookbehind:
|
|
2460
|
+
lookbehind: true,
|
|
2146
2461
|
// Alias added to make those easier to distinguish from strings.
|
|
2147
2462
|
alias: "class-name"
|
|
2148
2463
|
},
|
|
2149
|
-
boolean: {
|
|
2464
|
+
"boolean": {
|
|
2150
2465
|
pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
|
|
2151
|
-
lookbehind:
|
|
2466
|
+
lookbehind: true
|
|
2152
2467
|
},
|
|
2153
2468
|
"file-descriptor": {
|
|
2154
2469
|
pattern: /\B&\d\b/,
|
|
2155
2470
|
alias: "important"
|
|
2156
2471
|
},
|
|
2157
|
-
operator: {
|
|
2472
|
+
"operator": {
|
|
2158
2473
|
// Lots of redirections here, but not just that.
|
|
2159
2474
|
pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
|
2160
2475
|
inside: {
|
|
@@ -2164,13 +2479,14 @@ Prism.languages.sql = {
|
|
|
2164
2479
|
}
|
|
2165
2480
|
}
|
|
2166
2481
|
},
|
|
2167
|
-
punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
2168
|
-
number: {
|
|
2482
|
+
"punctuation": /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
2483
|
+
"number": {
|
|
2169
2484
|
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
2170
|
-
lookbehind:
|
|
2485
|
+
lookbehind: true
|
|
2171
2486
|
}
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2487
|
+
};
|
|
2488
|
+
commandAfterHeredoc.inside = Prism2.languages.bash;
|
|
2489
|
+
var toBeCopied = [
|
|
2174
2490
|
"comment",
|
|
2175
2491
|
"function-name",
|
|
2176
2492
|
"for-or-select",
|
|
@@ -2186,36 +2502,40 @@ Prism.languages.sql = {
|
|
|
2186
2502
|
"operator",
|
|
2187
2503
|
"punctuation",
|
|
2188
2504
|
"number"
|
|
2189
|
-
]
|
|
2190
|
-
|
|
2191
|
-
i
|
|
2505
|
+
];
|
|
2506
|
+
var inside = insideString.variable[1].inside;
|
|
2507
|
+
for (var i = 0; i < toBeCopied.length; i++) {
|
|
2508
|
+
inside[toBeCopied[i]] = Prism2.languages.bash[toBeCopied[i]];
|
|
2509
|
+
}
|
|
2510
|
+
Prism2.languages.sh = Prism2.languages.bash;
|
|
2511
|
+
Prism2.languages.shell = Prism2.languages.bash;
|
|
2192
2512
|
})(Prism);
|
|
2193
2513
|
Prism.languages.json = {
|
|
2194
|
-
property: {
|
|
2514
|
+
"property": {
|
|
2195
2515
|
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
2196
|
-
lookbehind:
|
|
2197
|
-
greedy:
|
|
2516
|
+
lookbehind: true,
|
|
2517
|
+
greedy: true
|
|
2198
2518
|
},
|
|
2199
|
-
string: {
|
|
2519
|
+
"string": {
|
|
2200
2520
|
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
|
2201
|
-
lookbehind:
|
|
2202
|
-
greedy:
|
|
2521
|
+
lookbehind: true,
|
|
2522
|
+
greedy: true
|
|
2203
2523
|
},
|
|
2204
|
-
comment: {
|
|
2524
|
+
"comment": {
|
|
2205
2525
|
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2206
|
-
greedy:
|
|
2526
|
+
greedy: true
|
|
2207
2527
|
},
|
|
2208
|
-
number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
2209
|
-
punctuation: /[{}[\],]/,
|
|
2210
|
-
operator: /:/,
|
|
2211
|
-
boolean: /\b(?:false|true)\b/,
|
|
2212
|
-
null: {
|
|
2528
|
+
"number": /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
2529
|
+
"punctuation": /[{}[\],]/,
|
|
2530
|
+
"operator": /:/,
|
|
2531
|
+
"boolean": /\b(?:false|true)\b/,
|
|
2532
|
+
"null": {
|
|
2213
2533
|
pattern: /\bnull\b/,
|
|
2214
2534
|
alias: "keyword"
|
|
2215
2535
|
}
|
|
2216
2536
|
};
|
|
2217
2537
|
Prism.languages.webmanifest = Prism.languages.json;
|
|
2218
|
-
const
|
|
2538
|
+
const prismDarkTheme = `
|
|
2219
2539
|
/* 默认代码颜色 */
|
|
2220
2540
|
.hep-cr-editor .hep-cr-highlight code,
|
|
2221
2541
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -2301,7 +2621,8 @@ const Ue = `
|
|
|
2301
2621
|
.hep-cr-editor .token.console {
|
|
2302
2622
|
color: #f8f8f2 !important;
|
|
2303
2623
|
}
|
|
2304
|
-
|
|
2624
|
+
`;
|
|
2625
|
+
const prismLightTheme = `
|
|
2305
2626
|
/* 默认代码颜色 */
|
|
2306
2627
|
.hep-cr-editor .hep-cr-highlight code,
|
|
2307
2628
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -2378,34 +2699,53 @@ const Ue = `
|
|
|
2378
2699
|
.hep-cr-editor .token.console {
|
|
2379
2700
|
color: #333 !important;
|
|
2380
2701
|
}
|
|
2381
|
-
|
|
2702
|
+
`;
|
|
2703
|
+
const _hoisted_1$2 = ["innerHTML"];
|
|
2704
|
+
const _hoisted_2$2 = ["value", "disabled"];
|
|
2705
|
+
const CHANGE_DEBOUNCE_MS = 500;
|
|
2706
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
2382
2707
|
__name: "CodeEditor",
|
|
2383
2708
|
props: {
|
|
2384
2709
|
modelValue: {},
|
|
2385
2710
|
language: {},
|
|
2386
2711
|
theme: { default: "dark" },
|
|
2387
|
-
disabled: { type: Boolean, default:
|
|
2712
|
+
disabled: { type: Boolean, default: false }
|
|
2388
2713
|
},
|
|
2389
2714
|
emits: ["update:modelValue", "change"],
|
|
2390
|
-
setup(
|
|
2391
|
-
|
|
2392
|
-
v2b19bab6:
|
|
2393
|
-
}))
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2715
|
+
setup(__props, { emit: __emit }) {
|
|
2716
|
+
useCssVars((_ctx) => ({
|
|
2717
|
+
"v2b19bab6": editorBackground.value
|
|
2718
|
+
}));
|
|
2719
|
+
if (typeof window !== "undefined") {
|
|
2720
|
+
window.Prism = Prism$1;
|
|
2721
|
+
}
|
|
2722
|
+
function loadPrismTheme(theme) {
|
|
2723
|
+
if (typeof document === "undefined") return;
|
|
2724
|
+
const styleId = "hep-cr-prism-styles";
|
|
2725
|
+
const oldStyleEl = document.getElementById(styleId);
|
|
2726
|
+
const themeContent = theme === "dark" ? prismDarkTheme : prismLightTheme;
|
|
2727
|
+
if (oldStyleEl) {
|
|
2728
|
+
oldStyleEl.remove();
|
|
2729
|
+
}
|
|
2730
|
+
const styleEl = document.createElement("style");
|
|
2731
|
+
styleEl.id = styleId;
|
|
2732
|
+
styleEl.textContent = themeContent;
|
|
2733
|
+
document.head.appendChild(styleEl);
|
|
2400
2734
|
}
|
|
2401
|
-
const
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2735
|
+
const props = __props;
|
|
2736
|
+
const emit = __emit;
|
|
2737
|
+
const codeRef = ref(null);
|
|
2738
|
+
const highlightRef = ref(null);
|
|
2739
|
+
let changeTimer = null;
|
|
2740
|
+
function emitChange(value) {
|
|
2741
|
+
if (changeTimer) {
|
|
2742
|
+
clearTimeout(changeTimer);
|
|
2743
|
+
}
|
|
2744
|
+
changeTimer = setTimeout(() => {
|
|
2745
|
+
emit("change", value);
|
|
2746
|
+
}, CHANGE_DEBOUNCE_MS);
|
|
2407
2747
|
}
|
|
2408
|
-
const
|
|
2748
|
+
const languageMap = {
|
|
2409
2749
|
javascript: "javascript",
|
|
2410
2750
|
js: "javascript",
|
|
2411
2751
|
typescript: "typescript",
|
|
@@ -2436,79 +2776,119 @@ const Ue = `
|
|
|
2436
2776
|
yml: "yaml",
|
|
2437
2777
|
markdown: "markdown",
|
|
2438
2778
|
md: "markdown"
|
|
2439
|
-
}
|
|
2779
|
+
};
|
|
2780
|
+
const prismLanguage = computed(() => {
|
|
2781
|
+
return languageMap[props.language.toLowerCase()] || "javascript";
|
|
2782
|
+
});
|
|
2783
|
+
const editorBackground = computed(() => {
|
|
2784
|
+
return props.theme === "dark" ? "#1e1e1e" : "#fafafa";
|
|
2785
|
+
});
|
|
2786
|
+
const highlightedCode = computed(() => {
|
|
2440
2787
|
try {
|
|
2441
|
-
const
|
|
2442
|
-
if (
|
|
2443
|
-
return
|
|
2444
|
-
|
|
2788
|
+
const grammar = Prism$1.languages[prismLanguage.value];
|
|
2789
|
+
if (grammar) {
|
|
2790
|
+
return Prism$1.highlight(props.modelValue || "", grammar, prismLanguage.value);
|
|
2791
|
+
}
|
|
2792
|
+
} catch (e) {
|
|
2445
2793
|
}
|
|
2446
|
-
return
|
|
2794
|
+
return escapeHtml(props.modelValue || "");
|
|
2447
2795
|
});
|
|
2448
|
-
function
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2796
|
+
function escapeHtml(text) {
|
|
2797
|
+
const div = document.createElement("div");
|
|
2798
|
+
div.textContent = text;
|
|
2799
|
+
return div.innerHTML;
|
|
2451
2800
|
}
|
|
2452
|
-
function
|
|
2453
|
-
const
|
|
2454
|
-
|
|
2801
|
+
function handleInput(e) {
|
|
2802
|
+
const target = e.target;
|
|
2803
|
+
emit("update:modelValue", target.value);
|
|
2804
|
+
emitChange(target.value);
|
|
2455
2805
|
}
|
|
2456
|
-
function
|
|
2457
|
-
|
|
2806
|
+
function handleScroll() {
|
|
2807
|
+
if (codeRef.value && highlightRef.value) {
|
|
2808
|
+
highlightRef.value.scrollTop = codeRef.value.scrollTop;
|
|
2809
|
+
highlightRef.value.scrollLeft = codeRef.value.scrollLeft;
|
|
2810
|
+
}
|
|
2458
2811
|
}
|
|
2459
|
-
function
|
|
2460
|
-
if (
|
|
2461
|
-
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2812
|
+
function handleKeydown(e) {
|
|
2813
|
+
if (e.key === "Tab") {
|
|
2814
|
+
e.preventDefault();
|
|
2815
|
+
const target = e.target;
|
|
2816
|
+
const start = target.selectionStart;
|
|
2817
|
+
const end = target.selectionEnd;
|
|
2818
|
+
const value = target.value;
|
|
2819
|
+
target.value = value.substring(0, start) + " " + value.substring(end);
|
|
2820
|
+
target.selectionStart = target.selectionEnd = start + 2;
|
|
2821
|
+
emit("update:modelValue", target.value);
|
|
2822
|
+
emitChange(target.value);
|
|
2464
2823
|
}
|
|
2465
2824
|
}
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
})
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
"
|
|
2825
|
+
onMounted(() => {
|
|
2826
|
+
loadPrismTheme(props.theme);
|
|
2827
|
+
});
|
|
2828
|
+
watch(() => props.theme, (newTheme) => {
|
|
2829
|
+
loadPrismTheme(newTheme);
|
|
2830
|
+
});
|
|
2831
|
+
onUnmounted(() => {
|
|
2832
|
+
if (changeTimer) {
|
|
2833
|
+
clearTimeout(changeTimer);
|
|
2834
|
+
}
|
|
2835
|
+
});
|
|
2836
|
+
return (_ctx, _cache) => {
|
|
2837
|
+
return openBlock(), createElementBlock("div", {
|
|
2838
|
+
class: normalizeClass(["hep-cr-editor", `hep-cr-theme-${__props.theme}`])
|
|
2480
2839
|
}, [
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2840
|
+
createElementVNode("pre", {
|
|
2841
|
+
ref_key: "highlightRef",
|
|
2842
|
+
ref: highlightRef,
|
|
2843
|
+
class: normalizeClass(["hep-cr-highlight", [`language-${prismLanguage.value}`, `hep-cr-prism-${__props.theme}`]]),
|
|
2844
|
+
"aria-hidden": "true"
|
|
2845
|
+
}, [
|
|
2846
|
+
createElementVNode("code", { innerHTML: highlightedCode.value }, null, 8, _hoisted_1$2)
|
|
2847
|
+
], 2),
|
|
2848
|
+
createElementVNode("textarea", {
|
|
2849
|
+
ref_key: "codeRef",
|
|
2850
|
+
ref: codeRef,
|
|
2851
|
+
class: "hep-cr-input",
|
|
2852
|
+
value: __props.modelValue,
|
|
2853
|
+
disabled: __props.disabled,
|
|
2854
|
+
onInput: handleInput,
|
|
2855
|
+
onScroll: handleScroll,
|
|
2856
|
+
onKeydown: handleKeydown,
|
|
2857
|
+
spellcheck: "false",
|
|
2858
|
+
placeholder: "Write your code here..."
|
|
2859
|
+
}, null, 40, _hoisted_2$2)
|
|
2860
|
+
], 2);
|
|
2861
|
+
};
|
|
2496
2862
|
}
|
|
2497
|
-
})
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
}
|
|
2863
|
+
});
|
|
2864
|
+
const _export_sfc = (sfc, props) => {
|
|
2865
|
+
const target = sfc.__vccOpts || sfc;
|
|
2866
|
+
for (const [key, val] of props) {
|
|
2867
|
+
target[key] = val;
|
|
2868
|
+
}
|
|
2869
|
+
return target;
|
|
2870
|
+
};
|
|
2871
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a988ca2a"]]);
|
|
2872
|
+
const _hoisted_1$1 = { class: "hep-cr-header" };
|
|
2873
|
+
const _hoisted_2$1 = { class: "hep-cr-controls" };
|
|
2874
|
+
const _hoisted_3$1 = ["disabled"];
|
|
2875
|
+
const _hoisted_4$1 = {
|
|
2503
2876
|
key: 0,
|
|
2504
2877
|
value: ""
|
|
2505
|
-
}
|
|
2878
|
+
};
|
|
2879
|
+
const _hoisted_5 = ["value"];
|
|
2880
|
+
const _hoisted_6 = { class: "hep-cr-actions" };
|
|
2881
|
+
const _hoisted_7 = ["disabled"];
|
|
2882
|
+
const _hoisted_8 = {
|
|
2506
2883
|
key: 0,
|
|
2507
2884
|
class: "hep-cr-spinner"
|
|
2508
|
-
}
|
|
2885
|
+
};
|
|
2886
|
+
const _hoisted_9 = {
|
|
2509
2887
|
key: 1,
|
|
2510
2888
|
class: "hep-cr-run-icon"
|
|
2511
|
-
}
|
|
2889
|
+
};
|
|
2890
|
+
const _hoisted_10 = ["title"];
|
|
2891
|
+
const _hoisted_11 = {
|
|
2512
2892
|
key: 0,
|
|
2513
2893
|
width: "16",
|
|
2514
2894
|
height: "16",
|
|
@@ -2516,7 +2896,8 @@ const Ue = `
|
|
|
2516
2896
|
fill: "none",
|
|
2517
2897
|
stroke: "currentColor",
|
|
2518
2898
|
"stroke-width": "2"
|
|
2519
|
-
}
|
|
2899
|
+
};
|
|
2900
|
+
const _hoisted_12 = {
|
|
2520
2901
|
key: 1,
|
|
2521
2902
|
width: "16",
|
|
2522
2903
|
height: "16",
|
|
@@ -2524,10 +2905,17 @@ const Ue = `
|
|
|
2524
2905
|
fill: "none",
|
|
2525
2906
|
stroke: "currentColor",
|
|
2526
2907
|
"stroke-width": "2"
|
|
2527
|
-
}
|
|
2908
|
+
};
|
|
2909
|
+
const _hoisted_13 = {
|
|
2528
2910
|
key: 0,
|
|
2529
2911
|
class: "hep-cr-error"
|
|
2530
|
-
}
|
|
2912
|
+
};
|
|
2913
|
+
const _hoisted_14 = { class: "hep-cr-main" };
|
|
2914
|
+
const _hoisted_15 = { class: "hep-cr-panel-header" };
|
|
2915
|
+
const _hoisted_16 = { class: "hep-cr-output-actions" };
|
|
2916
|
+
const _hoisted_17 = { class: "hep-cr-language-badge" };
|
|
2917
|
+
const _hoisted_18 = ["disabled", "title"];
|
|
2918
|
+
const _hoisted_19 = {
|
|
2531
2919
|
key: 0,
|
|
2532
2920
|
width: "14",
|
|
2533
2921
|
height: "14",
|
|
@@ -2535,13 +2923,20 @@ const Ue = `
|
|
|
2535
2923
|
fill: "none",
|
|
2536
2924
|
stroke: "currentColor",
|
|
2537
2925
|
"stroke-width": "2"
|
|
2538
|
-
}
|
|
2926
|
+
};
|
|
2927
|
+
const _hoisted_20 = {
|
|
2539
2928
|
key: 1,
|
|
2540
2929
|
class: "hep-cr-copied-text"
|
|
2541
|
-
}
|
|
2930
|
+
};
|
|
2931
|
+
const _hoisted_21 = { class: "hep-cr-panel-header" };
|
|
2932
|
+
const _hoisted_22 = { class: "hep-cr-output-tabs" };
|
|
2933
|
+
const _hoisted_23 = { class: "hep-cr-output-actions" };
|
|
2934
|
+
const _hoisted_24 = {
|
|
2542
2935
|
key: 0,
|
|
2543
2936
|
class: "hep-cr-execution-time"
|
|
2544
|
-
}
|
|
2937
|
+
};
|
|
2938
|
+
const _hoisted_25 = ["disabled", "title"];
|
|
2939
|
+
const _hoisted_26 = {
|
|
2545
2940
|
key: 0,
|
|
2546
2941
|
width: "14",
|
|
2547
2942
|
height: "14",
|
|
@@ -2549,370 +2944,474 @@ const Ue = `
|
|
|
2549
2944
|
fill: "none",
|
|
2550
2945
|
stroke: "currentColor",
|
|
2551
2946
|
"stroke-width": "2"
|
|
2552
|
-
}
|
|
2947
|
+
};
|
|
2948
|
+
const _hoisted_27 = {
|
|
2553
2949
|
key: 1,
|
|
2554
2950
|
class: "hep-cr-copied-text"
|
|
2555
|
-
}
|
|
2951
|
+
};
|
|
2952
|
+
const _hoisted_28 = { class: "hep-cr-output-content" };
|
|
2953
|
+
const _hoisted_29 = { key: 0 };
|
|
2954
|
+
const _hoisted_30 = {
|
|
2556
2955
|
key: 1,
|
|
2557
2956
|
class: "hep-cr-stderr"
|
|
2558
|
-
}
|
|
2957
|
+
};
|
|
2958
|
+
const STORAGE_KEY = "hep-cr-default-language";
|
|
2959
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
2559
2960
|
__name: "CodeRunner",
|
|
2560
2961
|
props: {
|
|
2561
2962
|
pistonUrl: { default: "/api/piston" },
|
|
2562
2963
|
language: { default: "javascript" },
|
|
2563
2964
|
theme: { default: "light" },
|
|
2564
2965
|
themeColor: { default: "" },
|
|
2565
|
-
showLanguageSelector: { type: Boolean, default:
|
|
2566
|
-
showEditor: { type: Boolean, default:
|
|
2567
|
-
editable: { type: Boolean, default:
|
|
2966
|
+
showLanguageSelector: { type: Boolean, default: true },
|
|
2967
|
+
showEditor: { type: Boolean, default: true },
|
|
2968
|
+
editable: { type: Boolean, default: true },
|
|
2568
2969
|
defaultCode: {},
|
|
2569
2970
|
executorLabel: { default: "运行" }
|
|
2570
2971
|
},
|
|
2571
2972
|
emits: ["execute-start", "execute-end", "language-change", "change"],
|
|
2572
|
-
setup(
|
|
2573
|
-
const
|
|
2574
|
-
|
|
2575
|
-
|
|
2973
|
+
setup(__props, { emit: __emit }) {
|
|
2974
|
+
const props = __props;
|
|
2975
|
+
const themeStyle = computed(() => {
|
|
2976
|
+
if (!props.themeColor) return {};
|
|
2977
|
+
const isDark = props.theme === "dark";
|
|
2978
|
+
const color = props.themeColor;
|
|
2979
|
+
const isLightColor = isColorLight(color);
|
|
2980
|
+
const textColor = isLightColor ? "#000" : "#fff";
|
|
2576
2981
|
return {
|
|
2577
|
-
"--hep-cr-theme-color":
|
|
2578
|
-
"--hep-cr-theme-color-hover":
|
|
2579
|
-
"--hep-cr-tab-active-color":
|
|
2982
|
+
"--hep-cr-theme-color": color,
|
|
2983
|
+
"--hep-cr-theme-color-hover": isDark ? adjustColorBrightness(color, 20) : adjustColorBrightness(color, -20),
|
|
2984
|
+
"--hep-cr-tab-active-color": textColor
|
|
2580
2985
|
};
|
|
2581
2986
|
});
|
|
2582
|
-
function
|
|
2583
|
-
const
|
|
2584
|
-
|
|
2987
|
+
function isColorLight(hex) {
|
|
2988
|
+
const num = parseInt(hex.replace("#", ""), 16);
|
|
2989
|
+
const r = num >> 16 & 255;
|
|
2990
|
+
const g = num >> 8 & 255;
|
|
2991
|
+
const b = num & 255;
|
|
2992
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
2993
|
+
return luminance > 0.5;
|
|
2585
2994
|
}
|
|
2586
|
-
function
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2995
|
+
function adjustColorBrightness(hex, percent) {
|
|
2996
|
+
const num = parseInt(hex.replace("#", ""), 16);
|
|
2997
|
+
const amt = Math.round(2.55 * percent);
|
|
2998
|
+
const R = Math.min(255, Math.max(0, (num >> 16) + amt));
|
|
2999
|
+
const G = Math.min(255, Math.max(0, (num >> 8 & 255) + amt));
|
|
3000
|
+
const B = Math.min(255, Math.max(0, (num & 255) + amt));
|
|
3001
|
+
return "#" + (16777216 + R * 65536 + G * 256 + B).toString(16).slice(1);
|
|
2589
3002
|
}
|
|
2590
|
-
const
|
|
2591
|
-
|
|
2592
|
-
|
|
3003
|
+
const emit = __emit;
|
|
3004
|
+
const runtimes = ref([]);
|
|
3005
|
+
const currentLanguage = ref(getStoredLanguage());
|
|
3006
|
+
const currentTheme = ref(props.theme);
|
|
3007
|
+
const code = ref("");
|
|
3008
|
+
const output = ref("");
|
|
3009
|
+
const stderr = ref("");
|
|
3010
|
+
const isRunning = ref(false);
|
|
3011
|
+
const executionTime = ref(null);
|
|
3012
|
+
const activeTab = ref("stdout");
|
|
3013
|
+
const error = ref(null);
|
|
3014
|
+
const runtimesLoading = ref(false);
|
|
3015
|
+
const editorWidth = ref(60);
|
|
3016
|
+
function getStoredLanguage() {
|
|
3017
|
+
if (typeof window === "undefined") return props.language;
|
|
3018
|
+
return localStorage.getItem(STORAGE_KEY) || props.language;
|
|
2593
3019
|
}
|
|
2594
|
-
function
|
|
2595
|
-
|
|
3020
|
+
function toggleTheme() {
|
|
3021
|
+
currentTheme.value = currentTheme.value === "light" ? "dark" : "light";
|
|
2596
3022
|
}
|
|
2597
|
-
const
|
|
2598
|
-
() => new
|
|
2599
|
-
)
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
3023
|
+
const client = computed(
|
|
3024
|
+
() => new W({ pistonUrl: props.pistonUrl })
|
|
3025
|
+
);
|
|
3026
|
+
const languageOptions = computed(() => {
|
|
3027
|
+
return runtimes.value.map((r) => ({
|
|
3028
|
+
value: `${r.language}:${r.version}`,
|
|
3029
|
+
label: `${r.language.charAt(0).toUpperCase() + r.language.slice(1)} ${r.version}`
|
|
3030
|
+
}));
|
|
3031
|
+
});
|
|
3032
|
+
const languageName = computed(() => {
|
|
3033
|
+
const lang = currentLanguage.value;
|
|
3034
|
+
return lang.includes(":") ? lang.split(":")[0] : lang;
|
|
2605
3035
|
});
|
|
2606
|
-
async function
|
|
2607
|
-
|
|
3036
|
+
async function loadRuntimes() {
|
|
3037
|
+
runtimesLoading.value = true;
|
|
3038
|
+
error.value = null;
|
|
2608
3039
|
try {
|
|
2609
|
-
|
|
2610
|
-
const
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
3040
|
+
runtimes.value = await client.value.getRuntimes();
|
|
3041
|
+
const langName = currentLanguage.value.split(":")[0];
|
|
3042
|
+
const defaultRuntime = runtimes.value.find((r) => r.language === langName);
|
|
3043
|
+
if (defaultRuntime && !currentLanguage.value.includes(":")) {
|
|
3044
|
+
currentLanguage.value = `${langName}:${defaultRuntime.version}`;
|
|
3045
|
+
}
|
|
3046
|
+
if (!code.value) {
|
|
3047
|
+
code.value = props.defaultCode || j(langName);
|
|
3048
|
+
emit("change", code.value);
|
|
3049
|
+
}
|
|
3050
|
+
emit("language-change", langName, code.value);
|
|
3051
|
+
} catch (e) {
|
|
3052
|
+
error.value = e instanceof Error ? e.message : "Failed to load runtimes";
|
|
2614
3053
|
} finally {
|
|
2615
|
-
|
|
3054
|
+
runtimesLoading.value = false;
|
|
2616
3055
|
}
|
|
2617
3056
|
}
|
|
2618
|
-
|
|
2619
|
-
const
|
|
2620
|
-
|
|
3057
|
+
watch(currentLanguage, (newLang) => {
|
|
3058
|
+
const langName = newLang.includes(":") ? newLang.split(":")[0] : newLang;
|
|
3059
|
+
const newCode = j(langName);
|
|
3060
|
+
code.value = newCode;
|
|
3061
|
+
emit("language-change", langName, newCode);
|
|
3062
|
+
if (typeof window !== "undefined") {
|
|
3063
|
+
localStorage.setItem(STORAGE_KEY, newLang);
|
|
3064
|
+
}
|
|
2621
3065
|
});
|
|
2622
|
-
async function
|
|
2623
|
-
if (
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
3066
|
+
async function execute() {
|
|
3067
|
+
if (isRunning.value) return;
|
|
3068
|
+
isRunning.value = true;
|
|
3069
|
+
output.value = "";
|
|
3070
|
+
stderr.value = "";
|
|
3071
|
+
executionTime.value = null;
|
|
3072
|
+
error.value = null;
|
|
3073
|
+
activeTab.value = "stdout";
|
|
3074
|
+
emit("execute-start");
|
|
3075
|
+
try {
|
|
3076
|
+
const result = await client.value.execute(languageName.value, code.value);
|
|
3077
|
+
output.value = result.output;
|
|
3078
|
+
stderr.value = result.stderr;
|
|
3079
|
+
executionTime.value = result.executionTime || null;
|
|
3080
|
+
activeTab.value = result.stderr ? "stderr" : "stdout";
|
|
3081
|
+
emit("execute-end", result);
|
|
3082
|
+
} catch (e) {
|
|
3083
|
+
error.value = e instanceof Error ? e.message : "Execution failed";
|
|
3084
|
+
emit("execute-end", {
|
|
3085
|
+
success: false,
|
|
3086
|
+
output: "",
|
|
3087
|
+
stderr: error.value,
|
|
3088
|
+
code: -1
|
|
3089
|
+
});
|
|
3090
|
+
} finally {
|
|
3091
|
+
isRunning.value = false;
|
|
2638
3092
|
}
|
|
2639
3093
|
}
|
|
2640
|
-
const
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
3094
|
+
const copiedEditor = ref(false);
|
|
3095
|
+
const copiedOutput = ref(false);
|
|
3096
|
+
async function copyCode() {
|
|
3097
|
+
await navigator.clipboard.writeText(code.value);
|
|
3098
|
+
copiedEditor.value = true;
|
|
3099
|
+
setTimeout(() => {
|
|
3100
|
+
copiedEditor.value = false;
|
|
2644
3101
|
}, 2e3);
|
|
2645
3102
|
}
|
|
2646
|
-
async function
|
|
2647
|
-
const
|
|
2648
|
-
await navigator.clipboard.writeText(
|
|
2649
|
-
|
|
3103
|
+
async function copyOutput() {
|
|
3104
|
+
const text = activeTab.value === "stdout" ? output.value : stderr.value;
|
|
3105
|
+
await navigator.clipboard.writeText(text);
|
|
3106
|
+
copiedOutput.value = true;
|
|
3107
|
+
setTimeout(() => {
|
|
3108
|
+
copiedOutput.value = false;
|
|
2650
3109
|
}, 2e3);
|
|
2651
3110
|
}
|
|
2652
|
-
function
|
|
2653
|
-
|
|
3111
|
+
function resetCode() {
|
|
3112
|
+
code.value = j(languageName.value);
|
|
2654
3113
|
}
|
|
2655
|
-
let
|
|
2656
|
-
function
|
|
2657
|
-
|
|
3114
|
+
let isDragging = false;
|
|
3115
|
+
function startDrag(e) {
|
|
3116
|
+
isDragging = true;
|
|
3117
|
+
document.addEventListener("mousemove", onDrag);
|
|
3118
|
+
document.addEventListener("mouseup", stopDrag);
|
|
3119
|
+
document.body.style.cursor = "col-resize";
|
|
3120
|
+
document.body.style.userSelect = "none";
|
|
2658
3121
|
}
|
|
2659
|
-
function
|
|
2660
|
-
if (!
|
|
2661
|
-
const
|
|
3122
|
+
function onDrag(e) {
|
|
3123
|
+
if (!isDragging) return;
|
|
3124
|
+
const container = document.querySelector(
|
|
2662
3125
|
".hep-cr-main"
|
|
2663
3126
|
);
|
|
2664
|
-
if (!
|
|
2665
|
-
const
|
|
2666
|
-
e.
|
|
3127
|
+
if (!container) return;
|
|
3128
|
+
const rect = container.getBoundingClientRect();
|
|
3129
|
+
const newWidth = (e.clientX - rect.left) / rect.width * 100;
|
|
3130
|
+
editorWidth.value = Math.max(20, Math.min(80, newWidth));
|
|
2667
3131
|
}
|
|
2668
|
-
function
|
|
2669
|
-
|
|
3132
|
+
function stopDrag() {
|
|
3133
|
+
isDragging = false;
|
|
3134
|
+
document.removeEventListener("mousemove", onDrag);
|
|
3135
|
+
document.removeEventListener("mouseup", stopDrag);
|
|
3136
|
+
document.body.style.cursor = "";
|
|
3137
|
+
document.body.style.userSelect = "";
|
|
2670
3138
|
}
|
|
2671
|
-
|
|
2672
|
-
await
|
|
3139
|
+
onMounted(async () => {
|
|
3140
|
+
await loadRuntimes();
|
|
3141
|
+
if (!code.value) {
|
|
3142
|
+
code.value = props.defaultCode || j(currentLanguage.value);
|
|
3143
|
+
emit("change", code.value);
|
|
3144
|
+
}
|
|
2673
3145
|
});
|
|
2674
|
-
const
|
|
2675
|
-
return (
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
3146
|
+
const themeClass = computed(() => `hep-cr-runner-${currentTheme.value}`);
|
|
3147
|
+
return (_ctx, _cache) => {
|
|
3148
|
+
return openBlock(), createElementBlock("div", {
|
|
3149
|
+
class: normalizeClass(["hep-cr-runner", themeClass.value]),
|
|
3150
|
+
style: normalizeStyle(themeStyle.value)
|
|
3151
|
+
}, [
|
|
3152
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
3153
|
+
createElementVNode("div", _hoisted_2$1, [
|
|
3154
|
+
__props.showLanguageSelector ? withDirectives((openBlock(), createElementBlock("select", {
|
|
3155
|
+
key: 0,
|
|
3156
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentLanguage.value = $event),
|
|
3157
|
+
class: "hep-cr-language-select",
|
|
3158
|
+
disabled: isRunning.value
|
|
3159
|
+
}, [
|
|
3160
|
+
runtimesLoading.value ? (openBlock(), createElementBlock("option", _hoisted_4$1, "加载中...")) : createCommentVNode("", true),
|
|
3161
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(languageOptions.value, (option) => {
|
|
3162
|
+
return openBlock(), createElementBlock("option", {
|
|
3163
|
+
key: option.value,
|
|
3164
|
+
value: option.value
|
|
3165
|
+
}, toDisplayString(option.label), 9, _hoisted_5);
|
|
3166
|
+
}), 128))
|
|
3167
|
+
], 8, _hoisted_3$1)), [
|
|
3168
|
+
[vModelSelect, currentLanguage.value]
|
|
3169
|
+
]) : createCommentVNode("", true)
|
|
3170
|
+
]),
|
|
3171
|
+
createElementVNode("div", _hoisted_6, [
|
|
3172
|
+
createElementVNode("button", {
|
|
3173
|
+
class: "hep-cr-btn hep-cr-btn-run",
|
|
3174
|
+
disabled: isRunning.value || runtimesLoading.value,
|
|
3175
|
+
onClick: execute
|
|
3176
|
+
}, [
|
|
3177
|
+
isRunning.value ? (openBlock(), createElementBlock("span", _hoisted_8)) : (openBlock(), createElementBlock("span", _hoisted_9, "▶")),
|
|
3178
|
+
createTextVNode(" " + toDisplayString(isRunning.value ? "运行中..." : __props.executorLabel), 1)
|
|
3179
|
+
], 8, _hoisted_7),
|
|
3180
|
+
__props.showEditor && __props.editable ? (openBlock(), createElementBlock("button", {
|
|
3181
|
+
key: 0,
|
|
3182
|
+
class: "hep-cr-btn hep-cr-btn-reset",
|
|
3183
|
+
onClick: resetCode
|
|
3184
|
+
}, " 重置 ")) : createCommentVNode("", true),
|
|
3185
|
+
createElementVNode("button", {
|
|
3186
|
+
class: "hep-cr-btn hep-cr-btn-theme",
|
|
3187
|
+
onClick: toggleTheme,
|
|
3188
|
+
title: currentTheme.value === "light" ? "Switch to dark mode" : "Switch to light mode"
|
|
3189
|
+
}, [
|
|
3190
|
+
currentTheme.value === "light" ? (openBlock(), createElementBlock("svg", _hoisted_11, [..._cache[5] || (_cache[5] = [
|
|
3191
|
+
createElementVNode("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }, null, -1)
|
|
3192
|
+
])])) : (openBlock(), createElementBlock("svg", _hoisted_12, [..._cache[6] || (_cache[6] = [
|
|
3193
|
+
createStaticVNode('<circle cx="12" cy="12" r="5" data-v-41977f3b></circle><line x1="12" y1="1" x2="12" y2="3" data-v-41977f3b></line><line x1="12" y1="21" x2="12" y2="23" data-v-41977f3b></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64" data-v-41977f3b></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78" data-v-41977f3b></line><line x1="1" y1="12" x2="3" y2="12" data-v-41977f3b></line><line x1="21" y1="12" x2="23" y2="12" data-v-41977f3b></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36" data-v-41977f3b></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22" data-v-41977f3b></line>', 9)
|
|
3194
|
+
])]))
|
|
3195
|
+
], 8, _hoisted_10)
|
|
3196
|
+
])
|
|
2695
3197
|
]),
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
disabled: L.value || h.value,
|
|
2700
|
-
onClick: c
|
|
2701
|
-
}, [
|
|
2702
|
-
L.value ? (x(), I("span", Qe)) : (x(), I("span", et, "▶")),
|
|
2703
|
-
we(" " + z(L.value ? "运行中..." : i.executorLabel), 1)
|
|
2704
|
-
], 8, Je),
|
|
2705
|
-
i.showEditor && i.editable ? (x(), I("button", {
|
|
3198
|
+
error.value ? (openBlock(), createElementBlock("div", _hoisted_13, toDisplayString(error.value), 1)) : createCommentVNode("", true),
|
|
3199
|
+
createElementVNode("div", _hoisted_14, [
|
|
3200
|
+
__props.showEditor ? (openBlock(), createElementBlock("div", {
|
|
2706
3201
|
key: 0,
|
|
2707
|
-
class: "hep-cr-
|
|
2708
|
-
|
|
2709
|
-
}, " 重置 ")) : B("", !0),
|
|
2710
|
-
A("button", {
|
|
2711
|
-
class: "hep-cr-btn hep-cr-btn-theme",
|
|
2712
|
-
onClick: r,
|
|
2713
|
-
title: b.value === "light" ? "Switch to dark mode" : "Switch to light mode"
|
|
3202
|
+
class: "hep-cr-editor-panel",
|
|
3203
|
+
style: normalizeStyle({ width: editorWidth.value + "%" })
|
|
2714
3204
|
}, [
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
title: T.value ? "已复制" : "复制"
|
|
2739
|
-
}, [
|
|
2740
|
-
T.value ? (x(), I("span", dt, "已复制")) : (x(), I("svg", ct, [...g[7] || (g[7] = [
|
|
2741
|
-
A("rect", {
|
|
2742
|
-
x: "9",
|
|
2743
|
-
y: "9",
|
|
2744
|
-
width: "13",
|
|
2745
|
-
height: "13",
|
|
2746
|
-
rx: "2",
|
|
2747
|
-
ry: "2"
|
|
2748
|
-
}, null, -1),
|
|
2749
|
-
A("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, null, -1)
|
|
2750
|
-
])]))
|
|
2751
|
-
], 10, ut)
|
|
2752
|
-
])
|
|
2753
|
-
]),
|
|
2754
|
-
ie(We, {
|
|
2755
|
-
modelValue: k.value,
|
|
2756
|
-
"onUpdate:modelValue": g[1] || (g[1] = (m) => k.value = m),
|
|
2757
|
-
language: u.value,
|
|
2758
|
-
theme: b.value,
|
|
2759
|
-
disabled: !i.editable || L.value,
|
|
2760
|
-
onChange: g[2] || (g[2] = (m) => S("change", m))
|
|
2761
|
-
}, null, 8, ["modelValue", "language", "theme", "disabled"])
|
|
2762
|
-
], 4)) : B("", !0),
|
|
2763
|
-
i.showEditor ? (x(), I("div", {
|
|
2764
|
-
key: 1,
|
|
2765
|
-
class: "hep-cr-resize-handle",
|
|
2766
|
-
onMousedown: te
|
|
2767
|
-
}, [...g[9] || (g[9] = [
|
|
2768
|
-
A("div", { class: "hep-cr-resize-line" }, null, -1)
|
|
2769
|
-
])], 32)) : B("", !0),
|
|
2770
|
-
A("div", {
|
|
2771
|
-
class: "hep-cr-output-panel",
|
|
2772
|
-
style: Q({ width: i.showEditor ? 100 - e.value + "%" : "100%" })
|
|
2773
|
-
}, [
|
|
2774
|
-
A("div", pt, [
|
|
2775
|
-
A("div", gt, [
|
|
2776
|
-
A("button", {
|
|
2777
|
-
class: j(["hep-cr-tab", { active: w.value === "stdout" }]),
|
|
2778
|
-
onClick: g[3] || (g[3] = (m) => w.value = "stdout")
|
|
2779
|
-
}, " 输出 ", 2),
|
|
2780
|
-
O.value ? (x(), I("button", {
|
|
2781
|
-
key: 0,
|
|
2782
|
-
class: j(["hep-cr-tab", "hep-cr-tab-error", { active: w.value === "stderr" }]),
|
|
2783
|
-
onClick: g[4] || (g[4] = (m) => w.value = "stderr")
|
|
2784
|
-
}, " 错误 ", 2)) : B("", !0)
|
|
3205
|
+
createElementVNode("div", _hoisted_15, [
|
|
3206
|
+
_cache[8] || (_cache[8] = createElementVNode("span", { class: "hep-cr-panel-title" }, "编辑器", -1)),
|
|
3207
|
+
createElementVNode("div", _hoisted_16, [
|
|
3208
|
+
createElementVNode("span", _hoisted_17, toDisplayString(languageName.value), 1),
|
|
3209
|
+
createElementVNode("button", {
|
|
3210
|
+
class: normalizeClass(["hep-cr-btn-icon", { "hep-cr-btn-copied": copiedEditor.value }]),
|
|
3211
|
+
disabled: copiedEditor.value,
|
|
3212
|
+
onClick: copyCode,
|
|
3213
|
+
title: copiedEditor.value ? "已复制" : "复制"
|
|
3214
|
+
}, [
|
|
3215
|
+
!copiedEditor.value ? (openBlock(), createElementBlock("svg", _hoisted_19, [..._cache[7] || (_cache[7] = [
|
|
3216
|
+
createElementVNode("rect", {
|
|
3217
|
+
x: "9",
|
|
3218
|
+
y: "9",
|
|
3219
|
+
width: "13",
|
|
3220
|
+
height: "13",
|
|
3221
|
+
rx: "2",
|
|
3222
|
+
ry: "2"
|
|
3223
|
+
}, null, -1),
|
|
3224
|
+
createElementVNode("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, null, -1)
|
|
3225
|
+
])])) : (openBlock(), createElementBlock("span", _hoisted_20, "已复制"))
|
|
3226
|
+
], 10, _hoisted_18)
|
|
3227
|
+
])
|
|
2785
3228
|
]),
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
3229
|
+
createVNode(CodeEditor, {
|
|
3230
|
+
modelValue: code.value,
|
|
3231
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => code.value = $event),
|
|
3232
|
+
language: languageName.value,
|
|
3233
|
+
theme: currentTheme.value,
|
|
3234
|
+
disabled: !__props.editable || isRunning.value,
|
|
3235
|
+
onChange: _cache[2] || (_cache[2] = (val) => emit("change", val))
|
|
3236
|
+
}, null, 8, ["modelValue", "language", "theme", "disabled"])
|
|
3237
|
+
], 4)) : createCommentVNode("", true),
|
|
3238
|
+
__props.showEditor ? (openBlock(), createElementBlock("div", {
|
|
3239
|
+
key: 1,
|
|
3240
|
+
class: "hep-cr-resize-handle",
|
|
3241
|
+
onMousedown: startDrag
|
|
3242
|
+
}, [..._cache[9] || (_cache[9] = [
|
|
3243
|
+
createElementVNode("div", { class: "hep-cr-resize-line" }, null, -1)
|
|
3244
|
+
])], 32)) : createCommentVNode("", true),
|
|
3245
|
+
createElementVNode("div", {
|
|
3246
|
+
class: "hep-cr-output-panel",
|
|
3247
|
+
style: normalizeStyle({ width: __props.showEditor ? 100 - editorWidth.value + "%" : "100%" })
|
|
3248
|
+
}, [
|
|
3249
|
+
createElementVNode("div", _hoisted_21, [
|
|
3250
|
+
createElementVNode("div", _hoisted_22, [
|
|
3251
|
+
createElementVNode("button", {
|
|
3252
|
+
class: normalizeClass(["hep-cr-tab", { active: activeTab.value === "stdout" }]),
|
|
3253
|
+
onClick: _cache[3] || (_cache[3] = ($event) => activeTab.value = "stdout")
|
|
3254
|
+
}, " 输出 ", 2),
|
|
3255
|
+
stderr.value ? (openBlock(), createElementBlock("button", {
|
|
3256
|
+
key: 0,
|
|
3257
|
+
class: normalizeClass(["hep-cr-tab", "hep-cr-tab-error", { active: activeTab.value === "stderr" }]),
|
|
3258
|
+
onClick: _cache[4] || (_cache[4] = ($event) => activeTab.value = "stderr")
|
|
3259
|
+
}, " 错误 ", 2)) : createCommentVNode("", true)
|
|
3260
|
+
]),
|
|
3261
|
+
createElementVNode("div", _hoisted_23, [
|
|
3262
|
+
executionTime.value !== null ? (openBlock(), createElementBlock("span", _hoisted_24, toDisplayString(executionTime.value) + "ms ", 1)) : createCommentVNode("", true),
|
|
3263
|
+
createElementVNode("button", {
|
|
3264
|
+
class: normalizeClass(["hep-cr-btn-icon", { "hep-cr-btn-copied": copiedOutput.value }]),
|
|
3265
|
+
disabled: copiedOutput.value,
|
|
3266
|
+
onClick: copyOutput,
|
|
3267
|
+
title: copiedOutput.value ? "已复制" : "复制"
|
|
3268
|
+
}, [
|
|
3269
|
+
!copiedOutput.value ? (openBlock(), createElementBlock("svg", _hoisted_26, [..._cache[10] || (_cache[10] = [
|
|
3270
|
+
createElementVNode("rect", {
|
|
3271
|
+
x: "9",
|
|
3272
|
+
y: "9",
|
|
3273
|
+
width: "13",
|
|
3274
|
+
height: "13",
|
|
3275
|
+
rx: "2",
|
|
3276
|
+
ry: "2"
|
|
3277
|
+
}, null, -1),
|
|
3278
|
+
createElementVNode("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, null, -1)
|
|
3279
|
+
])])) : (openBlock(), createElementBlock("span", _hoisted_27, "已复制"))
|
|
3280
|
+
], 10, _hoisted_25)
|
|
3281
|
+
])
|
|
3282
|
+
]),
|
|
3283
|
+
createElementVNode("div", _hoisted_28, [
|
|
3284
|
+
activeTab.value === "stdout" ? (openBlock(), createElementBlock("pre", _hoisted_29, toDisplayString(isRunning.value ? "代码执行中..." : output.value || '点击"运行"执行代码'), 1)) : (openBlock(), createElementBlock("pre", _hoisted_30, toDisplayString(stderr.value), 1))
|
|
2806
3285
|
])
|
|
2807
|
-
])
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
], 4)
|
|
2812
|
-
])
|
|
2813
|
-
], 6));
|
|
3286
|
+
], 4)
|
|
3287
|
+
])
|
|
3288
|
+
], 6);
|
|
3289
|
+
};
|
|
2814
3290
|
}
|
|
2815
|
-
})
|
|
3291
|
+
});
|
|
3292
|
+
const CodeRunner = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-41977f3b"]]);
|
|
3293
|
+
const _hoisted_1 = { class: "hep-cr-dialog-header" };
|
|
3294
|
+
const _hoisted_2 = { class: "hep-cr-dialog-title" };
|
|
3295
|
+
const _hoisted_3 = { class: "hep-cr-dialog-body" };
|
|
3296
|
+
const _hoisted_4 = {
|
|
2816
3297
|
key: 0,
|
|
2817
3298
|
class: "hep-cr-dialog-footer"
|
|
2818
|
-
}
|
|
3299
|
+
};
|
|
3300
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
2819
3301
|
__name: "CodeRunnerDialog",
|
|
2820
3302
|
props: {
|
|
2821
|
-
modelValue: { type: Boolean, default:
|
|
3303
|
+
modelValue: { type: Boolean, default: false },
|
|
2822
3304
|
title: { default: "代码执行器" },
|
|
2823
3305
|
width: { default: 800 },
|
|
2824
3306
|
pistonUrl: { default: "/api/piston" },
|
|
2825
3307
|
language: { default: "javascript" },
|
|
2826
3308
|
theme: { default: "light" },
|
|
2827
3309
|
themeColor: { default: "" },
|
|
2828
|
-
showLanguageSelector: { type: Boolean, default:
|
|
2829
|
-
showEditor: { type: Boolean, default:
|
|
2830
|
-
editable: { type: Boolean, default:
|
|
3310
|
+
showLanguageSelector: { type: Boolean, default: true },
|
|
3311
|
+
showEditor: { type: Boolean, default: true },
|
|
3312
|
+
editable: { type: Boolean, default: true },
|
|
2831
3313
|
defaultCode: {},
|
|
2832
3314
|
executorLabel: { default: "运行" }
|
|
2833
3315
|
},
|
|
2834
3316
|
emits: ["update:modelValue", "close", "change"],
|
|
2835
|
-
setup(
|
|
2836
|
-
const
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
3317
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
3318
|
+
const props = __props;
|
|
3319
|
+
const emit = __emit;
|
|
3320
|
+
const localVisible = ref(props.modelValue);
|
|
3321
|
+
const isVisible = computed(() => {
|
|
3322
|
+
if (props.modelValue !== void 0) {
|
|
3323
|
+
return props.modelValue;
|
|
3324
|
+
}
|
|
3325
|
+
return localVisible.value;
|
|
3326
|
+
});
|
|
3327
|
+
watch(
|
|
3328
|
+
() => props.modelValue,
|
|
3329
|
+
(val) => {
|
|
3330
|
+
if (val !== void 0) {
|
|
3331
|
+
localVisible.value = val;
|
|
3332
|
+
}
|
|
2841
3333
|
}
|
|
2842
3334
|
);
|
|
2843
|
-
function
|
|
2844
|
-
|
|
3335
|
+
function close() {
|
|
3336
|
+
localVisible.value = false;
|
|
3337
|
+
emit("update:modelValue", false);
|
|
3338
|
+
emit("close");
|
|
2845
3339
|
}
|
|
2846
|
-
function
|
|
2847
|
-
|
|
3340
|
+
function handleOverlayClick(e) {
|
|
3341
|
+
if (e.target === e.currentTarget) {
|
|
3342
|
+
close();
|
|
3343
|
+
}
|
|
2848
3344
|
}
|
|
2849
|
-
|
|
2850
|
-
close
|
|
2851
|
-
})
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
class: "hep-cr-dialog-container",
|
|
2861
|
-
style: Q({ width: typeof i.width == "number" ? i.width + "px" : i.width })
|
|
3345
|
+
__expose({
|
|
3346
|
+
close
|
|
3347
|
+
});
|
|
3348
|
+
return (_ctx, _cache) => {
|
|
3349
|
+
return openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3350
|
+
createVNode(Transition, { name: "hep-cr-dialog-fade" }, {
|
|
3351
|
+
default: withCtx(() => [
|
|
3352
|
+
isVisible.value ? (openBlock(), createElementBlock("div", {
|
|
3353
|
+
key: 0,
|
|
3354
|
+
class: "hep-cr-dialog-overlay",
|
|
3355
|
+
onClick: handleOverlayClick
|
|
2862
3356
|
}, [
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
3357
|
+
createElementVNode("div", {
|
|
3358
|
+
class: "hep-cr-dialog-container",
|
|
3359
|
+
style: normalizeStyle({ width: typeof __props.width === "number" ? __props.width + "px" : __props.width })
|
|
3360
|
+
}, [
|
|
3361
|
+
createElementVNode("div", _hoisted_1, [
|
|
3362
|
+
createElementVNode("h3", _hoisted_2, toDisplayString(__props.title), 1),
|
|
3363
|
+
createElementVNode("button", {
|
|
3364
|
+
class: "hep-cr-dialog-close",
|
|
3365
|
+
onClick: close
|
|
3366
|
+
}, [..._cache[0] || (_cache[0] = [
|
|
3367
|
+
createElementVNode("svg", {
|
|
3368
|
+
width: "16",
|
|
3369
|
+
height: "16",
|
|
3370
|
+
viewBox: "0 0 24 24",
|
|
3371
|
+
fill: "none",
|
|
3372
|
+
stroke: "currentColor",
|
|
3373
|
+
"stroke-width": "2"
|
|
3374
|
+
}, [
|
|
3375
|
+
createElementVNode("line", {
|
|
3376
|
+
x1: "18",
|
|
3377
|
+
y1: "6",
|
|
3378
|
+
x2: "6",
|
|
3379
|
+
y2: "18"
|
|
3380
|
+
}),
|
|
3381
|
+
createElementVNode("line", {
|
|
3382
|
+
x1: "6",
|
|
3383
|
+
y1: "6",
|
|
3384
|
+
x2: "18",
|
|
3385
|
+
y2: "18"
|
|
3386
|
+
})
|
|
3387
|
+
], -1)
|
|
3388
|
+
])])
|
|
3389
|
+
]),
|
|
3390
|
+
createElementVNode("div", _hoisted_3, [
|
|
3391
|
+
createVNode(CodeRunner, mergeProps(_ctx.$attrs, toHandlers(_ctx.$attrs)), null, 16)
|
|
3392
|
+
]),
|
|
3393
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
3394
|
+
renderSlot(_ctx.$slots, "footer", { close })
|
|
3395
|
+
])) : createCommentVNode("", true)
|
|
3396
|
+
], 4)
|
|
3397
|
+
])) : createCommentVNode("", true)
|
|
3398
|
+
]),
|
|
3399
|
+
_: 3
|
|
3400
|
+
})
|
|
3401
|
+
]);
|
|
3402
|
+
};
|
|
2904
3403
|
}
|
|
2905
3404
|
});
|
|
2906
|
-
|
|
2907
|
-
|
|
3405
|
+
CodeRunner.install = (app) => {
|
|
3406
|
+
app.component("CodeRunner", CodeRunner);
|
|
2908
3407
|
};
|
|
2909
|
-
const
|
|
2910
|
-
install(
|
|
2911
|
-
|
|
3408
|
+
const index = {
|
|
3409
|
+
install(app) {
|
|
3410
|
+
app.component("CodeRunner", CodeRunner);
|
|
2912
3411
|
}
|
|
2913
3412
|
};
|
|
2914
3413
|
export {
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
3414
|
+
CodeRunner,
|
|
3415
|
+
_sfc_main as CodeRunnerDialog,
|
|
3416
|
+
index as default
|
|
2918
3417
|
};
|