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