@hep-code-runner/react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +319 -0
- package/dist/index.mjs +3372 -0
- package/dist/style.css +1 -0
- package/package.json +41 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3372 @@
|
|
|
1
|
+
import qe, { useRef as Fe, useMemo as ve, useEffect as Oe, useState as Q, useCallback as ue } from "react";
|
|
2
|
+
var Ve = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
3
|
+
function St(f) {
|
|
4
|
+
return f && f.__esModule && Object.prototype.hasOwnProperty.call(f, "default") ? f.default : f;
|
|
5
|
+
}
|
|
6
|
+
var Ie = { exports: {} }, be = {};
|
|
7
|
+
/**
|
|
8
|
+
* @license React
|
|
9
|
+
* react-jsx-runtime.production.min.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
var Xe;
|
|
17
|
+
function At() {
|
|
18
|
+
if (Xe) return be;
|
|
19
|
+
Xe = 1;
|
|
20
|
+
var f = qe, g = Symbol.for("react.element"), n = Symbol.for("react.fragment"), c = Object.prototype.hasOwnProperty, h = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, _ = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
21
|
+
function x(l, m, S) {
|
|
22
|
+
var F, L = {}, j = null, C = null;
|
|
23
|
+
S !== void 0 && (j = "" + S), m.key !== void 0 && (j = "" + m.key), m.ref !== void 0 && (C = m.ref);
|
|
24
|
+
for (F in m) c.call(m, F) && !_.hasOwnProperty(F) && (L[F] = m[F]);
|
|
25
|
+
if (l && l.defaultProps) for (F in m = l.defaultProps, m) L[F] === void 0 && (L[F] = m[F]);
|
|
26
|
+
return { $$typeof: g, type: l, key: j, ref: C, props: L, _owner: h.current };
|
|
27
|
+
}
|
|
28
|
+
return be.Fragment = n, be.jsx = x, be.jsxs = x, be;
|
|
29
|
+
}
|
|
30
|
+
var Ee = {};
|
|
31
|
+
/**
|
|
32
|
+
* @license React
|
|
33
|
+
* react-jsx-runtime.development.js
|
|
34
|
+
*
|
|
35
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
36
|
+
*
|
|
37
|
+
* This source code is licensed under the MIT license found in the
|
|
38
|
+
* LICENSE file in the root directory of this source tree.
|
|
39
|
+
*/
|
|
40
|
+
var Ke;
|
|
41
|
+
function wt() {
|
|
42
|
+
return Ke || (Ke = 1, process.env.NODE_ENV !== "production" && function() {
|
|
43
|
+
var f = qe, g = Symbol.for("react.element"), n = Symbol.for("react.portal"), c = Symbol.for("react.fragment"), h = Symbol.for("react.strict_mode"), _ = Symbol.for("react.profiler"), x = Symbol.for("react.provider"), l = Symbol.for("react.context"), m = Symbol.for("react.forward_ref"), S = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), L = Symbol.for("react.memo"), j = Symbol.for("react.lazy"), C = Symbol.for("react.offscreen"), Y = Symbol.iterator, O = "@@iterator";
|
|
44
|
+
function R(e) {
|
|
45
|
+
if (e === null || typeof e != "object")
|
|
46
|
+
return null;
|
|
47
|
+
var a = Y && e[Y] || e[O];
|
|
48
|
+
return typeof a == "function" ? a : null;
|
|
49
|
+
}
|
|
50
|
+
var T = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
51
|
+
function t(e) {
|
|
52
|
+
{
|
|
53
|
+
for (var a = arguments.length, u = new Array(a > 1 ? a - 1 : 0), b = 1; b < a; b++)
|
|
54
|
+
u[b - 1] = arguments[b];
|
|
55
|
+
r("error", e, u);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function r(e, a, u) {
|
|
59
|
+
{
|
|
60
|
+
var b = T.ReactDebugCurrentFrame, k = b.getStackAddendum();
|
|
61
|
+
k !== "" && (a += "%s", u = u.concat([k]));
|
|
62
|
+
var N = u.map(function(w) {
|
|
63
|
+
return String(w);
|
|
64
|
+
});
|
|
65
|
+
N.unshift("Warning: " + a), Function.prototype.apply.call(console[e], console, N);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
var i = !1, s = !1, o = !1, d = !1, v = !1, p;
|
|
69
|
+
p = Symbol.for("react.module.reference");
|
|
70
|
+
function I(e) {
|
|
71
|
+
return !!(typeof e == "string" || typeof e == "function" || e === c || e === _ || v || e === h || e === S || e === F || d || e === C || i || s || o || typeof e == "object" && e !== null && (e.$$typeof === j || e.$$typeof === L || e.$$typeof === x || e.$$typeof === l || e.$$typeof === m || // This needs to include all possible module reference object
|
|
72
|
+
// types supported by any Flight configuration anywhere since
|
|
73
|
+
// we don't know which Flight build this will end up being used
|
|
74
|
+
// with.
|
|
75
|
+
e.$$typeof === p || e.getModuleId !== void 0));
|
|
76
|
+
}
|
|
77
|
+
function P(e, a, u) {
|
|
78
|
+
var b = e.displayName;
|
|
79
|
+
if (b)
|
|
80
|
+
return b;
|
|
81
|
+
var k = a.displayName || a.name || "";
|
|
82
|
+
return k !== "" ? u + "(" + k + ")" : u;
|
|
83
|
+
}
|
|
84
|
+
function B(e) {
|
|
85
|
+
return e.displayName || "Context";
|
|
86
|
+
}
|
|
87
|
+
function V(e) {
|
|
88
|
+
if (e == null)
|
|
89
|
+
return null;
|
|
90
|
+
if (typeof e.tag == "number" && t("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
91
|
+
return e.displayName || e.name || null;
|
|
92
|
+
if (typeof e == "string")
|
|
93
|
+
return e;
|
|
94
|
+
switch (e) {
|
|
95
|
+
case c:
|
|
96
|
+
return "Fragment";
|
|
97
|
+
case n:
|
|
98
|
+
return "Portal";
|
|
99
|
+
case _:
|
|
100
|
+
return "Profiler";
|
|
101
|
+
case h:
|
|
102
|
+
return "StrictMode";
|
|
103
|
+
case S:
|
|
104
|
+
return "Suspense";
|
|
105
|
+
case F:
|
|
106
|
+
return "SuspenseList";
|
|
107
|
+
}
|
|
108
|
+
if (typeof e == "object")
|
|
109
|
+
switch (e.$$typeof) {
|
|
110
|
+
case l:
|
|
111
|
+
var a = e;
|
|
112
|
+
return B(a) + ".Consumer";
|
|
113
|
+
case x:
|
|
114
|
+
var u = e;
|
|
115
|
+
return B(u._context) + ".Provider";
|
|
116
|
+
case m:
|
|
117
|
+
return P(e, e.render, "ForwardRef");
|
|
118
|
+
case L:
|
|
119
|
+
var b = e.displayName || null;
|
|
120
|
+
return b !== null ? b : V(e.type) || "Memo";
|
|
121
|
+
case j: {
|
|
122
|
+
var k = e, N = k._payload, w = k._init;
|
|
123
|
+
try {
|
|
124
|
+
return V(w(N));
|
|
125
|
+
} catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
var z = Object.assign, ne = 0, ce, le, D, H, ee, X, G;
|
|
133
|
+
function pe() {
|
|
134
|
+
}
|
|
135
|
+
pe.__reactDisabledLog = !0;
|
|
136
|
+
function Z() {
|
|
137
|
+
{
|
|
138
|
+
if (ne === 0) {
|
|
139
|
+
ce = console.log, le = console.info, D = console.warn, H = console.error, ee = console.group, X = console.groupCollapsed, G = console.groupEnd;
|
|
140
|
+
var e = {
|
|
141
|
+
configurable: !0,
|
|
142
|
+
enumerable: !0,
|
|
143
|
+
value: pe,
|
|
144
|
+
writable: !0
|
|
145
|
+
};
|
|
146
|
+
Object.defineProperties(console, {
|
|
147
|
+
info: e,
|
|
148
|
+
log: e,
|
|
149
|
+
warn: e,
|
|
150
|
+
error: e,
|
|
151
|
+
group: e,
|
|
152
|
+
groupCollapsed: e,
|
|
153
|
+
groupEnd: e
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
ne++;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function oe() {
|
|
160
|
+
{
|
|
161
|
+
if (ne--, ne === 0) {
|
|
162
|
+
var e = {
|
|
163
|
+
configurable: !0,
|
|
164
|
+
enumerable: !0,
|
|
165
|
+
writable: !0
|
|
166
|
+
};
|
|
167
|
+
Object.defineProperties(console, {
|
|
168
|
+
log: z({}, e, {
|
|
169
|
+
value: ce
|
|
170
|
+
}),
|
|
171
|
+
info: z({}, e, {
|
|
172
|
+
value: le
|
|
173
|
+
}),
|
|
174
|
+
warn: z({}, e, {
|
|
175
|
+
value: D
|
|
176
|
+
}),
|
|
177
|
+
error: z({}, e, {
|
|
178
|
+
value: H
|
|
179
|
+
}),
|
|
180
|
+
group: z({}, e, {
|
|
181
|
+
value: ee
|
|
182
|
+
}),
|
|
183
|
+
groupCollapsed: z({}, e, {
|
|
184
|
+
value: X
|
|
185
|
+
}),
|
|
186
|
+
groupEnd: z({}, e, {
|
|
187
|
+
value: G
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
ne < 0 && t("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
var ae = T.ReactCurrentDispatcher, q;
|
|
195
|
+
function ie(e, a, u) {
|
|
196
|
+
{
|
|
197
|
+
if (q === void 0)
|
|
198
|
+
try {
|
|
199
|
+
throw Error();
|
|
200
|
+
} catch (k) {
|
|
201
|
+
var b = k.stack.trim().match(/\n( *(at )?)/);
|
|
202
|
+
q = b && b[1] || "";
|
|
203
|
+
}
|
|
204
|
+
return `
|
|
205
|
+
` + q + e;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
var se = !1, te;
|
|
209
|
+
{
|
|
210
|
+
var A = typeof WeakMap == "function" ? WeakMap : Map;
|
|
211
|
+
te = new A();
|
|
212
|
+
}
|
|
213
|
+
function M(e, a) {
|
|
214
|
+
if (!e || se)
|
|
215
|
+
return "";
|
|
216
|
+
{
|
|
217
|
+
var u = te.get(e);
|
|
218
|
+
if (u !== void 0)
|
|
219
|
+
return u;
|
|
220
|
+
}
|
|
221
|
+
var b;
|
|
222
|
+
se = !0;
|
|
223
|
+
var k = Error.prepareStackTrace;
|
|
224
|
+
Error.prepareStackTrace = void 0;
|
|
225
|
+
var N;
|
|
226
|
+
N = ae.current, ae.current = null, Z();
|
|
227
|
+
try {
|
|
228
|
+
if (a) {
|
|
229
|
+
var w = function() {
|
|
230
|
+
throw Error();
|
|
231
|
+
};
|
|
232
|
+
if (Object.defineProperty(w.prototype, "props", {
|
|
233
|
+
set: function() {
|
|
234
|
+
throw Error();
|
|
235
|
+
}
|
|
236
|
+
}), typeof Reflect == "object" && Reflect.construct) {
|
|
237
|
+
try {
|
|
238
|
+
Reflect.construct(w, []);
|
|
239
|
+
} catch (K) {
|
|
240
|
+
b = K;
|
|
241
|
+
}
|
|
242
|
+
Reflect.construct(e, [], w);
|
|
243
|
+
} else {
|
|
244
|
+
try {
|
|
245
|
+
w.call();
|
|
246
|
+
} catch (K) {
|
|
247
|
+
b = K;
|
|
248
|
+
}
|
|
249
|
+
e.call(w.prototype);
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
try {
|
|
253
|
+
throw Error();
|
|
254
|
+
} catch (K) {
|
|
255
|
+
b = K;
|
|
256
|
+
}
|
|
257
|
+
e();
|
|
258
|
+
}
|
|
259
|
+
} catch (K) {
|
|
260
|
+
if (K && b && typeof K.stack == "string") {
|
|
261
|
+
for (var y = K.stack.split(`
|
|
262
|
+
`), W = b.stack.split(`
|
|
263
|
+
`), $ = y.length - 1, U = W.length - 1; $ >= 1 && U >= 0 && y[$] !== W[U]; )
|
|
264
|
+
U--;
|
|
265
|
+
for (; $ >= 1 && U >= 0; $--, U--)
|
|
266
|
+
if (y[$] !== W[U]) {
|
|
267
|
+
if ($ !== 1 || U !== 1)
|
|
268
|
+
do
|
|
269
|
+
if ($--, U--, U < 0 || y[$] !== W[U]) {
|
|
270
|
+
var J = `
|
|
271
|
+
` + y[$].replace(" at new ", " at ");
|
|
272
|
+
return e.displayName && J.includes("<anonymous>") && (J = J.replace("<anonymous>", e.displayName)), typeof e == "function" && te.set(e, J), J;
|
|
273
|
+
}
|
|
274
|
+
while ($ >= 1 && U >= 0);
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} finally {
|
|
279
|
+
se = !1, ae.current = N, oe(), Error.prepareStackTrace = k;
|
|
280
|
+
}
|
|
281
|
+
var he = e ? e.displayName || e.name : "", de = he ? ie(he) : "";
|
|
282
|
+
return typeof e == "function" && te.set(e, de), de;
|
|
283
|
+
}
|
|
284
|
+
function re(e, a, u) {
|
|
285
|
+
return M(e, !1);
|
|
286
|
+
}
|
|
287
|
+
function fe(e) {
|
|
288
|
+
var a = e.prototype;
|
|
289
|
+
return !!(a && a.isReactComponent);
|
|
290
|
+
}
|
|
291
|
+
function ye(e, a, u) {
|
|
292
|
+
if (e == null)
|
|
293
|
+
return "";
|
|
294
|
+
if (typeof e == "function")
|
|
295
|
+
return M(e, fe(e));
|
|
296
|
+
if (typeof e == "string")
|
|
297
|
+
return ie(e);
|
|
298
|
+
switch (e) {
|
|
299
|
+
case S:
|
|
300
|
+
return ie("Suspense");
|
|
301
|
+
case F:
|
|
302
|
+
return ie("SuspenseList");
|
|
303
|
+
}
|
|
304
|
+
if (typeof e == "object")
|
|
305
|
+
switch (e.$$typeof) {
|
|
306
|
+
case m:
|
|
307
|
+
return re(e.render);
|
|
308
|
+
case L:
|
|
309
|
+
return ye(e.type, a, u);
|
|
310
|
+
case j: {
|
|
311
|
+
var b = e, k = b._payload, N = b._init;
|
|
312
|
+
try {
|
|
313
|
+
return ye(N(k), a, u);
|
|
314
|
+
} catch {
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return "";
|
|
319
|
+
}
|
|
320
|
+
var me = Object.prototype.hasOwnProperty, Ce = {}, Le = T.ReactDebugCurrentFrame;
|
|
321
|
+
function Se(e) {
|
|
322
|
+
if (e) {
|
|
323
|
+
var a = e._owner, u = ye(e.type, e._source, a ? a.type : null);
|
|
324
|
+
Le.setExtraStackFrame(u);
|
|
325
|
+
} else
|
|
326
|
+
Le.setExtraStackFrame(null);
|
|
327
|
+
}
|
|
328
|
+
function Qe(e, a, u, b, k) {
|
|
329
|
+
{
|
|
330
|
+
var N = Function.call.bind(me);
|
|
331
|
+
for (var w in e)
|
|
332
|
+
if (N(e, w)) {
|
|
333
|
+
var y = void 0;
|
|
334
|
+
try {
|
|
335
|
+
if (typeof e[w] != "function") {
|
|
336
|
+
var W = Error((b || "React class") + ": " + u + " type `" + w + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[w] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
337
|
+
throw W.name = "Invariant Violation", W;
|
|
338
|
+
}
|
|
339
|
+
y = e[w](a, w, b, u, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
340
|
+
} catch ($) {
|
|
341
|
+
y = $;
|
|
342
|
+
}
|
|
343
|
+
y && !(y instanceof Error) && (Se(k), t("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", b || "React class", u, w, typeof y), Se(null)), y instanceof Error && !(y.message in Ce) && (Ce[y.message] = !0, Se(k), t("Failed %s type: %s", u, y.message), Se(null));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
var et = Array.isArray;
|
|
348
|
+
function Ae(e) {
|
|
349
|
+
return et(e);
|
|
350
|
+
}
|
|
351
|
+
function tt(e) {
|
|
352
|
+
{
|
|
353
|
+
var a = typeof Symbol == "function" && Symbol.toStringTag, u = a && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
354
|
+
return u;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function rt(e) {
|
|
358
|
+
try {
|
|
359
|
+
return Pe(e), !1;
|
|
360
|
+
} catch {
|
|
361
|
+
return !0;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function Pe(e) {
|
|
365
|
+
return "" + e;
|
|
366
|
+
}
|
|
367
|
+
function De(e) {
|
|
368
|
+
if (rt(e))
|
|
369
|
+
return t("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", tt(e)), Pe(e);
|
|
370
|
+
}
|
|
371
|
+
var $e = T.ReactCurrentOwner, nt = {
|
|
372
|
+
key: !0,
|
|
373
|
+
ref: !0,
|
|
374
|
+
__self: !0,
|
|
375
|
+
__source: !0
|
|
376
|
+
}, je, Me;
|
|
377
|
+
function at(e) {
|
|
378
|
+
if (me.call(e, "ref")) {
|
|
379
|
+
var a = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
380
|
+
if (a && a.isReactWarning)
|
|
381
|
+
return !1;
|
|
382
|
+
}
|
|
383
|
+
return e.ref !== void 0;
|
|
384
|
+
}
|
|
385
|
+
function it(e) {
|
|
386
|
+
if (me.call(e, "key")) {
|
|
387
|
+
var a = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
388
|
+
if (a && a.isReactWarning)
|
|
389
|
+
return !1;
|
|
390
|
+
}
|
|
391
|
+
return e.key !== void 0;
|
|
392
|
+
}
|
|
393
|
+
function st(e, a) {
|
|
394
|
+
typeof e.ref == "string" && $e.current;
|
|
395
|
+
}
|
|
396
|
+
function ot(e, a) {
|
|
397
|
+
{
|
|
398
|
+
var u = function() {
|
|
399
|
+
je || (je = !0, t("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
|
|
400
|
+
};
|
|
401
|
+
u.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
402
|
+
get: u,
|
|
403
|
+
configurable: !0
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function lt(e, a) {
|
|
408
|
+
{
|
|
409
|
+
var u = function() {
|
|
410
|
+
Me || (Me = !0, t("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
|
|
411
|
+
};
|
|
412
|
+
u.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
413
|
+
get: u,
|
|
414
|
+
configurable: !0
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
var ut = function(e, a, u, b, k, N, w) {
|
|
419
|
+
var y = {
|
|
420
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
421
|
+
$$typeof: g,
|
|
422
|
+
// Built-in properties that belong on the element
|
|
423
|
+
type: e,
|
|
424
|
+
key: a,
|
|
425
|
+
ref: u,
|
|
426
|
+
props: w,
|
|
427
|
+
// Record the component responsible for creating this element.
|
|
428
|
+
_owner: N
|
|
429
|
+
};
|
|
430
|
+
return y._store = {}, Object.defineProperty(y._store, "validated", {
|
|
431
|
+
configurable: !1,
|
|
432
|
+
enumerable: !1,
|
|
433
|
+
writable: !0,
|
|
434
|
+
value: !1
|
|
435
|
+
}), Object.defineProperty(y, "_self", {
|
|
436
|
+
configurable: !1,
|
|
437
|
+
enumerable: !1,
|
|
438
|
+
writable: !1,
|
|
439
|
+
value: b
|
|
440
|
+
}), Object.defineProperty(y, "_source", {
|
|
441
|
+
configurable: !1,
|
|
442
|
+
enumerable: !1,
|
|
443
|
+
writable: !1,
|
|
444
|
+
value: k
|
|
445
|
+
}), Object.freeze && (Object.freeze(y.props), Object.freeze(y)), y;
|
|
446
|
+
};
|
|
447
|
+
function ct(e, a, u, b, k) {
|
|
448
|
+
{
|
|
449
|
+
var N, w = {}, y = null, W = null;
|
|
450
|
+
u !== void 0 && (De(u), y = "" + u), it(a) && (De(a.key), y = "" + a.key), at(a) && (W = a.ref, st(a, k));
|
|
451
|
+
for (N in a)
|
|
452
|
+
me.call(a, N) && !nt.hasOwnProperty(N) && (w[N] = a[N]);
|
|
453
|
+
if (e && e.defaultProps) {
|
|
454
|
+
var $ = e.defaultProps;
|
|
455
|
+
for (N in $)
|
|
456
|
+
w[N] === void 0 && (w[N] = $[N]);
|
|
457
|
+
}
|
|
458
|
+
if (y || W) {
|
|
459
|
+
var U = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
460
|
+
y && ot(w, U), W && lt(w, U);
|
|
461
|
+
}
|
|
462
|
+
return ut(e, y, W, k, b, $e.current, w);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
var we = T.ReactCurrentOwner, Ue = T.ReactDebugCurrentFrame;
|
|
466
|
+
function ge(e) {
|
|
467
|
+
if (e) {
|
|
468
|
+
var a = e._owner, u = ye(e.type, e._source, a ? a.type : null);
|
|
469
|
+
Ue.setExtraStackFrame(u);
|
|
470
|
+
} else
|
|
471
|
+
Ue.setExtraStackFrame(null);
|
|
472
|
+
}
|
|
473
|
+
var Te;
|
|
474
|
+
Te = !1;
|
|
475
|
+
function xe(e) {
|
|
476
|
+
return typeof e == "object" && e !== null && e.$$typeof === g;
|
|
477
|
+
}
|
|
478
|
+
function He() {
|
|
479
|
+
{
|
|
480
|
+
if (we.current) {
|
|
481
|
+
var e = V(we.current.type);
|
|
482
|
+
if (e)
|
|
483
|
+
return `
|
|
484
|
+
|
|
485
|
+
Check the render method of \`` + e + "`.";
|
|
486
|
+
}
|
|
487
|
+
return "";
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function dt(e) {
|
|
491
|
+
return "";
|
|
492
|
+
}
|
|
493
|
+
var Be = {};
|
|
494
|
+
function pt(e) {
|
|
495
|
+
{
|
|
496
|
+
var a = He();
|
|
497
|
+
if (!a) {
|
|
498
|
+
var u = typeof e == "string" ? e : e.displayName || e.name;
|
|
499
|
+
u && (a = `
|
|
500
|
+
|
|
501
|
+
Check the top-level render call using <` + u + ">.");
|
|
502
|
+
}
|
|
503
|
+
return a;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function ze(e, a) {
|
|
507
|
+
{
|
|
508
|
+
if (!e._store || e._store.validated || e.key != null)
|
|
509
|
+
return;
|
|
510
|
+
e._store.validated = !0;
|
|
511
|
+
var u = pt(a);
|
|
512
|
+
if (Be[u])
|
|
513
|
+
return;
|
|
514
|
+
Be[u] = !0;
|
|
515
|
+
var b = "";
|
|
516
|
+
e && e._owner && e._owner !== we.current && (b = " It was passed a child from " + V(e._owner.type) + "."), ge(e), t('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', u, b), ge(null);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function Ge(e, a) {
|
|
520
|
+
{
|
|
521
|
+
if (typeof e != "object")
|
|
522
|
+
return;
|
|
523
|
+
if (Ae(e))
|
|
524
|
+
for (var u = 0; u < e.length; u++) {
|
|
525
|
+
var b = e[u];
|
|
526
|
+
xe(b) && ze(b, a);
|
|
527
|
+
}
|
|
528
|
+
else if (xe(e))
|
|
529
|
+
e._store && (e._store.validated = !0);
|
|
530
|
+
else if (e) {
|
|
531
|
+
var k = R(e);
|
|
532
|
+
if (typeof k == "function" && k !== e.entries)
|
|
533
|
+
for (var N = k.call(e), w; !(w = N.next()).done; )
|
|
534
|
+
xe(w.value) && ze(w.value, a);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function ft(e) {
|
|
539
|
+
{
|
|
540
|
+
var a = e.type;
|
|
541
|
+
if (a == null || typeof a == "string")
|
|
542
|
+
return;
|
|
543
|
+
var u;
|
|
544
|
+
if (typeof a == "function")
|
|
545
|
+
u = a.propTypes;
|
|
546
|
+
else if (typeof a == "object" && (a.$$typeof === m || // Note: Memo only checks outer props here.
|
|
547
|
+
// Inner props are checked in the reconciler.
|
|
548
|
+
a.$$typeof === L))
|
|
549
|
+
u = a.propTypes;
|
|
550
|
+
else
|
|
551
|
+
return;
|
|
552
|
+
if (u) {
|
|
553
|
+
var b = V(a);
|
|
554
|
+
Qe(u, e.props, "prop", b, e);
|
|
555
|
+
} else if (a.PropTypes !== void 0 && !Te) {
|
|
556
|
+
Te = !0;
|
|
557
|
+
var k = V(a);
|
|
558
|
+
t("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", k || "Unknown");
|
|
559
|
+
}
|
|
560
|
+
typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && t("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function gt(e) {
|
|
564
|
+
{
|
|
565
|
+
for (var a = Object.keys(e.props), u = 0; u < a.length; u++) {
|
|
566
|
+
var b = a[u];
|
|
567
|
+
if (b !== "children" && b !== "key") {
|
|
568
|
+
ge(e), t("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", b), ge(null);
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
e.ref !== null && (ge(e), t("Invalid attribute `ref` supplied to `React.Fragment`."), ge(null));
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
var We = {};
|
|
576
|
+
function Ye(e, a, u, b, k, N) {
|
|
577
|
+
{
|
|
578
|
+
var w = I(e);
|
|
579
|
+
if (!w) {
|
|
580
|
+
var y = "";
|
|
581
|
+
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (y += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
582
|
+
var W = dt();
|
|
583
|
+
W ? y += W : y += He();
|
|
584
|
+
var $;
|
|
585
|
+
e === null ? $ = "null" : Ae(e) ? $ = "array" : e !== void 0 && e.$$typeof === g ? ($ = "<" + (V(e.type) || "Unknown") + " />", y = " Did you accidentally export a JSX literal instead of a component?") : $ = typeof e, t("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", $, y);
|
|
586
|
+
}
|
|
587
|
+
var U = ct(e, a, u, k, N);
|
|
588
|
+
if (U == null)
|
|
589
|
+
return U;
|
|
590
|
+
if (w) {
|
|
591
|
+
var J = a.children;
|
|
592
|
+
if (J !== void 0)
|
|
593
|
+
if (b)
|
|
594
|
+
if (Ae(J)) {
|
|
595
|
+
for (var he = 0; he < J.length; he++)
|
|
596
|
+
Ge(J[he], e);
|
|
597
|
+
Object.freeze && Object.freeze(J);
|
|
598
|
+
} else
|
|
599
|
+
t("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
600
|
+
else
|
|
601
|
+
Ge(J, e);
|
|
602
|
+
}
|
|
603
|
+
if (me.call(a, "key")) {
|
|
604
|
+
var de = V(e), K = Object.keys(a).filter(function(yt) {
|
|
605
|
+
return yt !== "key";
|
|
606
|
+
}), Re = K.length > 0 ? "{key: someKey, " + K.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
607
|
+
if (!We[de + Re]) {
|
|
608
|
+
var vt = K.length > 0 ? "{" + K.join(": ..., ") + ": ...}" : "{}";
|
|
609
|
+
t(`A props object containing a "key" prop is being spread into JSX:
|
|
610
|
+
let props = %s;
|
|
611
|
+
<%s {...props} />
|
|
612
|
+
React keys must be passed directly to JSX without using spread:
|
|
613
|
+
let props = %s;
|
|
614
|
+
<%s key={someKey} {...props} />`, Re, de, vt, de), We[de + Re] = !0;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return e === c ? gt(U) : ft(U), U;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
function ht(e, a, u) {
|
|
621
|
+
return Ye(e, a, u, !0);
|
|
622
|
+
}
|
|
623
|
+
function mt(e, a, u) {
|
|
624
|
+
return Ye(e, a, u, !1);
|
|
625
|
+
}
|
|
626
|
+
var bt = mt, Et = ht;
|
|
627
|
+
Ee.Fragment = c, Ee.jsx = bt, Ee.jsxs = Et;
|
|
628
|
+
}()), Ee;
|
|
629
|
+
}
|
|
630
|
+
process.env.NODE_ENV === "production" ? Ie.exports = At() : Ie.exports = wt();
|
|
631
|
+
var E = Ie.exports, Je = { exports: {} };
|
|
632
|
+
(function(f) {
|
|
633
|
+
var g = typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {};
|
|
634
|
+
/**
|
|
635
|
+
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
636
|
+
*
|
|
637
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
638
|
+
* @author Lea Verou <https://lea.verou.me>
|
|
639
|
+
* @namespace
|
|
640
|
+
* @public
|
|
641
|
+
*/
|
|
642
|
+
var n = function(c) {
|
|
643
|
+
var h = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, _ = 0, x = {}, l = {
|
|
644
|
+
/**
|
|
645
|
+
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
646
|
+
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
647
|
+
* additional languages or plugins yourself.
|
|
648
|
+
*
|
|
649
|
+
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
650
|
+
*
|
|
651
|
+
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
652
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
653
|
+
*
|
|
654
|
+
* ```js
|
|
655
|
+
* window.Prism = window.Prism || {};
|
|
656
|
+
* Prism.manual = true;
|
|
657
|
+
* // add a new <script> to load Prism's script
|
|
658
|
+
* ```
|
|
659
|
+
*
|
|
660
|
+
* @default false
|
|
661
|
+
* @type {boolean}
|
|
662
|
+
* @memberof Prism
|
|
663
|
+
* @public
|
|
664
|
+
*/
|
|
665
|
+
manual: c.Prism && c.Prism.manual,
|
|
666
|
+
/**
|
|
667
|
+
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
668
|
+
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
669
|
+
* own worker, you don't want it to do this.
|
|
670
|
+
*
|
|
671
|
+
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
|
672
|
+
*
|
|
673
|
+
* You obviously have to change this value before Prism executes. To do this, you can add an
|
|
674
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
675
|
+
*
|
|
676
|
+
* ```js
|
|
677
|
+
* window.Prism = window.Prism || {};
|
|
678
|
+
* Prism.disableWorkerMessageHandler = true;
|
|
679
|
+
* // Load Prism's script
|
|
680
|
+
* ```
|
|
681
|
+
*
|
|
682
|
+
* @default false
|
|
683
|
+
* @type {boolean}
|
|
684
|
+
* @memberof Prism
|
|
685
|
+
* @public
|
|
686
|
+
*/
|
|
687
|
+
disableWorkerMessageHandler: c.Prism && c.Prism.disableWorkerMessageHandler,
|
|
688
|
+
/**
|
|
689
|
+
* A namespace for utility methods.
|
|
690
|
+
*
|
|
691
|
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
692
|
+
* change or disappear at any time.
|
|
693
|
+
*
|
|
694
|
+
* @namespace
|
|
695
|
+
* @memberof Prism
|
|
696
|
+
*/
|
|
697
|
+
util: {
|
|
698
|
+
encode: function t(r) {
|
|
699
|
+
return r instanceof m ? new m(r.type, t(r.content), r.alias) : Array.isArray(r) ? r.map(t) : r.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
700
|
+
},
|
|
701
|
+
/**
|
|
702
|
+
* Returns the name of the type of the given value.
|
|
703
|
+
*
|
|
704
|
+
* @param {any} o
|
|
705
|
+
* @returns {string}
|
|
706
|
+
* @example
|
|
707
|
+
* type(null) === 'Null'
|
|
708
|
+
* type(undefined) === 'Undefined'
|
|
709
|
+
* type(123) === 'Number'
|
|
710
|
+
* type('foo') === 'String'
|
|
711
|
+
* type(true) === 'Boolean'
|
|
712
|
+
* type([1, 2]) === 'Array'
|
|
713
|
+
* type({}) === 'Object'
|
|
714
|
+
* type(String) === 'Function'
|
|
715
|
+
* type(/abc+/) === 'RegExp'
|
|
716
|
+
*/
|
|
717
|
+
type: function(t) {
|
|
718
|
+
return Object.prototype.toString.call(t).slice(8, -1);
|
|
719
|
+
},
|
|
720
|
+
/**
|
|
721
|
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
722
|
+
*
|
|
723
|
+
* @param {Object} obj
|
|
724
|
+
* @returns {number}
|
|
725
|
+
*/
|
|
726
|
+
objId: function(t) {
|
|
727
|
+
return t.__id || Object.defineProperty(t, "__id", { value: ++_ }), t.__id;
|
|
728
|
+
},
|
|
729
|
+
/**
|
|
730
|
+
* Creates a deep clone of the given object.
|
|
731
|
+
*
|
|
732
|
+
* The main intended use of this function is to clone language definitions.
|
|
733
|
+
*
|
|
734
|
+
* @param {T} o
|
|
735
|
+
* @param {Record<number, any>} [visited]
|
|
736
|
+
* @returns {T}
|
|
737
|
+
* @template T
|
|
738
|
+
*/
|
|
739
|
+
clone: function t(r, i) {
|
|
740
|
+
i = i || {};
|
|
741
|
+
var s, o;
|
|
742
|
+
switch (l.util.type(r)) {
|
|
743
|
+
case "Object":
|
|
744
|
+
if (o = l.util.objId(r), i[o])
|
|
745
|
+
return i[o];
|
|
746
|
+
s = /** @type {Record<string, any>} */
|
|
747
|
+
{}, i[o] = s;
|
|
748
|
+
for (var d in r)
|
|
749
|
+
r.hasOwnProperty(d) && (s[d] = t(r[d], i));
|
|
750
|
+
return (
|
|
751
|
+
/** @type {any} */
|
|
752
|
+
s
|
|
753
|
+
);
|
|
754
|
+
case "Array":
|
|
755
|
+
return o = l.util.objId(r), i[o] ? i[o] : (s = [], i[o] = s, /** @type {Array} */
|
|
756
|
+
/** @type {any} */
|
|
757
|
+
r.forEach(function(v, p) {
|
|
758
|
+
s[p] = t(v, i);
|
|
759
|
+
}), /** @type {any} */
|
|
760
|
+
s);
|
|
761
|
+
default:
|
|
762
|
+
return r;
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
/**
|
|
766
|
+
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
767
|
+
*
|
|
768
|
+
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
769
|
+
*
|
|
770
|
+
* @param {Element} element
|
|
771
|
+
* @returns {string}
|
|
772
|
+
*/
|
|
773
|
+
getLanguage: function(t) {
|
|
774
|
+
for (; t; ) {
|
|
775
|
+
var r = h.exec(t.className);
|
|
776
|
+
if (r)
|
|
777
|
+
return r[1].toLowerCase();
|
|
778
|
+
t = t.parentElement;
|
|
779
|
+
}
|
|
780
|
+
return "none";
|
|
781
|
+
},
|
|
782
|
+
/**
|
|
783
|
+
* Sets the Prism `language-xxxx` class of the given element.
|
|
784
|
+
*
|
|
785
|
+
* @param {Element} element
|
|
786
|
+
* @param {string} language
|
|
787
|
+
* @returns {void}
|
|
788
|
+
*/
|
|
789
|
+
setLanguage: function(t, r) {
|
|
790
|
+
t.className = t.className.replace(RegExp(h, "gi"), ""), t.classList.add("language-" + r);
|
|
791
|
+
},
|
|
792
|
+
/**
|
|
793
|
+
* Returns the script element that is currently executing.
|
|
794
|
+
*
|
|
795
|
+
* This does __not__ work for line script element.
|
|
796
|
+
*
|
|
797
|
+
* @returns {HTMLScriptElement | null}
|
|
798
|
+
*/
|
|
799
|
+
currentScript: function() {
|
|
800
|
+
if (typeof document > "u")
|
|
801
|
+
return null;
|
|
802
|
+
if (document.currentScript && document.currentScript.tagName === "SCRIPT")
|
|
803
|
+
return (
|
|
804
|
+
/** @type {any} */
|
|
805
|
+
document.currentScript
|
|
806
|
+
);
|
|
807
|
+
try {
|
|
808
|
+
throw new Error();
|
|
809
|
+
} catch (s) {
|
|
810
|
+
var t = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(s.stack) || [])[1];
|
|
811
|
+
if (t) {
|
|
812
|
+
var r = document.getElementsByTagName("script");
|
|
813
|
+
for (var i in r)
|
|
814
|
+
if (r[i].src == t)
|
|
815
|
+
return r[i];
|
|
816
|
+
}
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
/**
|
|
821
|
+
* Returns whether a given class is active for `element`.
|
|
822
|
+
*
|
|
823
|
+
* The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
|
|
824
|
+
* if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
|
|
825
|
+
* given class is just the given class with a `no-` prefix.
|
|
826
|
+
*
|
|
827
|
+
* Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
|
|
828
|
+
* closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
|
|
829
|
+
* ancestors have the given class or the negated version of it, then the default activation will be returned.
|
|
830
|
+
*
|
|
831
|
+
* In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
|
|
832
|
+
* version of it, the class is considered active.
|
|
833
|
+
*
|
|
834
|
+
* @param {Element} element
|
|
835
|
+
* @param {string} className
|
|
836
|
+
* @param {boolean} [defaultActivation=false]
|
|
837
|
+
* @returns {boolean}
|
|
838
|
+
*/
|
|
839
|
+
isActive: function(t, r, i) {
|
|
840
|
+
for (var s = "no-" + r; t; ) {
|
|
841
|
+
var o = t.classList;
|
|
842
|
+
if (o.contains(r))
|
|
843
|
+
return !0;
|
|
844
|
+
if (o.contains(s))
|
|
845
|
+
return !1;
|
|
846
|
+
t = t.parentElement;
|
|
847
|
+
}
|
|
848
|
+
return !!i;
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
/**
|
|
852
|
+
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
853
|
+
*
|
|
854
|
+
* @namespace
|
|
855
|
+
* @memberof Prism
|
|
856
|
+
* @public
|
|
857
|
+
*/
|
|
858
|
+
languages: {
|
|
859
|
+
/**
|
|
860
|
+
* The grammar for plain, unformatted text.
|
|
861
|
+
*/
|
|
862
|
+
plain: x,
|
|
863
|
+
plaintext: x,
|
|
864
|
+
text: x,
|
|
865
|
+
txt: x,
|
|
866
|
+
/**
|
|
867
|
+
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
868
|
+
*
|
|
869
|
+
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
870
|
+
* will be overwritten at its original position.
|
|
871
|
+
*
|
|
872
|
+
* ## Best practices
|
|
873
|
+
*
|
|
874
|
+
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
875
|
+
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
876
|
+
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
877
|
+
*
|
|
878
|
+
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
879
|
+
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
880
|
+
*
|
|
881
|
+
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
882
|
+
* @param {Grammar} redef The new tokens to append.
|
|
883
|
+
* @returns {Grammar} The new language created.
|
|
884
|
+
* @public
|
|
885
|
+
* @example
|
|
886
|
+
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
887
|
+
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
888
|
+
* // at its original position
|
|
889
|
+
* 'comment': { ... },
|
|
890
|
+
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
891
|
+
* 'color': /\b(?:red|green|blue)\b/
|
|
892
|
+
* });
|
|
893
|
+
*/
|
|
894
|
+
extend: function(t, r) {
|
|
895
|
+
var i = l.util.clone(l.languages[t]);
|
|
896
|
+
for (var s in r)
|
|
897
|
+
i[s] = r[s];
|
|
898
|
+
return i;
|
|
899
|
+
},
|
|
900
|
+
/**
|
|
901
|
+
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
902
|
+
*
|
|
903
|
+
* ## Usage
|
|
904
|
+
*
|
|
905
|
+
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
906
|
+
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
907
|
+
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
908
|
+
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
909
|
+
* this:
|
|
910
|
+
*
|
|
911
|
+
* ```js
|
|
912
|
+
* Prism.languages.markup.style = {
|
|
913
|
+
* // token
|
|
914
|
+
* };
|
|
915
|
+
* ```
|
|
916
|
+
*
|
|
917
|
+
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
918
|
+
* before existing tokens. For the CSS example above, you would use it like this:
|
|
919
|
+
*
|
|
920
|
+
* ```js
|
|
921
|
+
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
922
|
+
* 'style': {
|
|
923
|
+
* // token
|
|
924
|
+
* }
|
|
925
|
+
* });
|
|
926
|
+
* ```
|
|
927
|
+
*
|
|
928
|
+
* ## Special cases
|
|
929
|
+
*
|
|
930
|
+
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
931
|
+
* will be ignored.
|
|
932
|
+
*
|
|
933
|
+
* This behavior can be used to insert tokens after `before`:
|
|
934
|
+
*
|
|
935
|
+
* ```js
|
|
936
|
+
* Prism.languages.insertBefore('markup', 'comment', {
|
|
937
|
+
* 'comment': Prism.languages.markup.comment,
|
|
938
|
+
* // tokens after 'comment'
|
|
939
|
+
* });
|
|
940
|
+
* ```
|
|
941
|
+
*
|
|
942
|
+
* ## Limitations
|
|
943
|
+
*
|
|
944
|
+
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
945
|
+
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
946
|
+
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
947
|
+
* deleting properties which is necessary to insert at arbitrary positions.
|
|
948
|
+
*
|
|
949
|
+
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
950
|
+
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
951
|
+
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
952
|
+
*
|
|
953
|
+
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
954
|
+
* you hold the target object in a variable, then the value of the variable will not change.
|
|
955
|
+
*
|
|
956
|
+
* ```js
|
|
957
|
+
* var oldMarkup = Prism.languages.markup;
|
|
958
|
+
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
959
|
+
*
|
|
960
|
+
* assert(oldMarkup !== Prism.languages.markup);
|
|
961
|
+
* assert(newMarkup === Prism.languages.markup);
|
|
962
|
+
* ```
|
|
963
|
+
*
|
|
964
|
+
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
965
|
+
* object to be modified.
|
|
966
|
+
* @param {string} before The key to insert before.
|
|
967
|
+
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
968
|
+
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
969
|
+
* object to be modified.
|
|
970
|
+
*
|
|
971
|
+
* Defaults to `Prism.languages`.
|
|
972
|
+
* @returns {Grammar} The new grammar object.
|
|
973
|
+
* @public
|
|
974
|
+
*/
|
|
975
|
+
insertBefore: function(t, r, i, s) {
|
|
976
|
+
s = s || /** @type {any} */
|
|
977
|
+
l.languages;
|
|
978
|
+
var o = s[t], d = {};
|
|
979
|
+
for (var v in o)
|
|
980
|
+
if (o.hasOwnProperty(v)) {
|
|
981
|
+
if (v == r)
|
|
982
|
+
for (var p in i)
|
|
983
|
+
i.hasOwnProperty(p) && (d[p] = i[p]);
|
|
984
|
+
i.hasOwnProperty(v) || (d[v] = o[v]);
|
|
985
|
+
}
|
|
986
|
+
var I = s[t];
|
|
987
|
+
return s[t] = d, l.languages.DFS(l.languages, function(P, B) {
|
|
988
|
+
B === I && P != t && (this[P] = d);
|
|
989
|
+
}), d;
|
|
990
|
+
},
|
|
991
|
+
// Traverse a language definition with Depth First Search
|
|
992
|
+
DFS: function t(r, i, s, o) {
|
|
993
|
+
o = o || {};
|
|
994
|
+
var d = l.util.objId;
|
|
995
|
+
for (var v in r)
|
|
996
|
+
if (r.hasOwnProperty(v)) {
|
|
997
|
+
i.call(r, v, r[v], s || v);
|
|
998
|
+
var p = r[v], I = l.util.type(p);
|
|
999
|
+
I === "Object" && !o[d(p)] ? (o[d(p)] = !0, t(p, i, null, o)) : I === "Array" && !o[d(p)] && (o[d(p)] = !0, t(p, i, v, o));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
plugins: {},
|
|
1004
|
+
/**
|
|
1005
|
+
* This is the most high-level function in Prism’s API.
|
|
1006
|
+
* It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
|
|
1007
|
+
* each one of them.
|
|
1008
|
+
*
|
|
1009
|
+
* This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
|
|
1010
|
+
*
|
|
1011
|
+
* @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
|
|
1012
|
+
* @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
|
|
1013
|
+
* @memberof Prism
|
|
1014
|
+
* @public
|
|
1015
|
+
*/
|
|
1016
|
+
highlightAll: function(t, r) {
|
|
1017
|
+
l.highlightAllUnder(document, t, r);
|
|
1018
|
+
},
|
|
1019
|
+
/**
|
|
1020
|
+
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
1021
|
+
* {@link Prism.highlightElement} on each one of them.
|
|
1022
|
+
*
|
|
1023
|
+
* The following hooks will be run:
|
|
1024
|
+
* 1. `before-highlightall`
|
|
1025
|
+
* 2. `before-all-elements-highlight`
|
|
1026
|
+
* 3. All hooks of {@link Prism.highlightElement} for each element.
|
|
1027
|
+
*
|
|
1028
|
+
* @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
|
|
1029
|
+
* @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
|
|
1030
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
|
|
1031
|
+
* @memberof Prism
|
|
1032
|
+
* @public
|
|
1033
|
+
*/
|
|
1034
|
+
highlightAllUnder: function(t, r, i) {
|
|
1035
|
+
var s = {
|
|
1036
|
+
callback: i,
|
|
1037
|
+
container: t,
|
|
1038
|
+
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
1039
|
+
};
|
|
1040
|
+
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);
|
|
1041
|
+
for (var o = 0, d; d = s.elements[o++]; )
|
|
1042
|
+
l.highlightElement(d, r === !0, s.callback);
|
|
1043
|
+
},
|
|
1044
|
+
/**
|
|
1045
|
+
* Highlights the code inside a single element.
|
|
1046
|
+
*
|
|
1047
|
+
* The following hooks will be run:
|
|
1048
|
+
* 1. `before-sanity-check`
|
|
1049
|
+
* 2. `before-highlight`
|
|
1050
|
+
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
|
|
1051
|
+
* 4. `before-insert`
|
|
1052
|
+
* 5. `after-highlight`
|
|
1053
|
+
* 6. `complete`
|
|
1054
|
+
*
|
|
1055
|
+
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
|
|
1056
|
+
* the element's language.
|
|
1057
|
+
*
|
|
1058
|
+
* @param {Element} element The element containing the code.
|
|
1059
|
+
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
|
|
1060
|
+
* @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
|
|
1061
|
+
* to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
|
|
1062
|
+
* [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
|
|
1063
|
+
*
|
|
1064
|
+
* Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
|
|
1065
|
+
* asynchronous highlighting to work. You can build your own bundle on the
|
|
1066
|
+
* [Download page](https://prismjs.com/download.html).
|
|
1067
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
|
|
1068
|
+
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
|
|
1069
|
+
* @memberof Prism
|
|
1070
|
+
* @public
|
|
1071
|
+
*/
|
|
1072
|
+
highlightElement: function(t, r, i) {
|
|
1073
|
+
var s = l.util.getLanguage(t), o = l.languages[s];
|
|
1074
|
+
l.util.setLanguage(t, s);
|
|
1075
|
+
var d = t.parentElement;
|
|
1076
|
+
d && d.nodeName.toLowerCase() === "pre" && l.util.setLanguage(d, s);
|
|
1077
|
+
var v = t.textContent, p = {
|
|
1078
|
+
element: t,
|
|
1079
|
+
language: s,
|
|
1080
|
+
grammar: o,
|
|
1081
|
+
code: v
|
|
1082
|
+
};
|
|
1083
|
+
function I(B) {
|
|
1084
|
+
p.highlightedCode = B, l.hooks.run("before-insert", p), p.element.innerHTML = p.highlightedCode, l.hooks.run("after-highlight", p), l.hooks.run("complete", p), i && i.call(p.element);
|
|
1085
|
+
}
|
|
1086
|
+
if (l.hooks.run("before-sanity-check", p), d = p.element.parentElement, d && d.nodeName.toLowerCase() === "pre" && !d.hasAttribute("tabindex") && d.setAttribute("tabindex", "0"), !p.code) {
|
|
1087
|
+
l.hooks.run("complete", p), i && i.call(p.element);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (l.hooks.run("before-highlight", p), !p.grammar) {
|
|
1091
|
+
I(l.util.encode(p.code));
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
if (r && c.Worker) {
|
|
1095
|
+
var P = new Worker(l.filename);
|
|
1096
|
+
P.onmessage = function(B) {
|
|
1097
|
+
I(B.data);
|
|
1098
|
+
}, P.postMessage(JSON.stringify({
|
|
1099
|
+
language: p.language,
|
|
1100
|
+
code: p.code,
|
|
1101
|
+
immediateClose: !0
|
|
1102
|
+
}));
|
|
1103
|
+
} else
|
|
1104
|
+
I(l.highlight(p.code, p.grammar, p.language));
|
|
1105
|
+
},
|
|
1106
|
+
/**
|
|
1107
|
+
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
1108
|
+
* and the language definitions to use, and returns a string with the HTML produced.
|
|
1109
|
+
*
|
|
1110
|
+
* The following hooks will be run:
|
|
1111
|
+
* 1. `before-tokenize`
|
|
1112
|
+
* 2. `after-tokenize`
|
|
1113
|
+
* 3. `wrap`: On each {@link Token}.
|
|
1114
|
+
*
|
|
1115
|
+
* @param {string} text A string with the code to be highlighted.
|
|
1116
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1117
|
+
*
|
|
1118
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
1119
|
+
* @param {string} language The name of the language definition passed to `grammar`.
|
|
1120
|
+
* @returns {string} The highlighted HTML.
|
|
1121
|
+
* @memberof Prism
|
|
1122
|
+
* @public
|
|
1123
|
+
* @example
|
|
1124
|
+
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
1125
|
+
*/
|
|
1126
|
+
highlight: function(t, r, i) {
|
|
1127
|
+
var s = {
|
|
1128
|
+
code: t,
|
|
1129
|
+
grammar: r,
|
|
1130
|
+
language: i
|
|
1131
|
+
};
|
|
1132
|
+
if (l.hooks.run("before-tokenize", s), !s.grammar)
|
|
1133
|
+
throw new Error('The language "' + s.language + '" has no grammar.');
|
|
1134
|
+
return s.tokens = l.tokenize(s.code, s.grammar), l.hooks.run("after-tokenize", s), m.stringify(l.util.encode(s.tokens), s.language);
|
|
1135
|
+
},
|
|
1136
|
+
/**
|
|
1137
|
+
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
1138
|
+
* and the language definitions to use, and returns an array with the tokenized code.
|
|
1139
|
+
*
|
|
1140
|
+
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
1141
|
+
*
|
|
1142
|
+
* This method could be useful in other contexts as well, as a very crude parser.
|
|
1143
|
+
*
|
|
1144
|
+
* @param {string} text A string with the code to be highlighted.
|
|
1145
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1146
|
+
*
|
|
1147
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
1148
|
+
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
1149
|
+
* @memberof Prism
|
|
1150
|
+
* @public
|
|
1151
|
+
* @example
|
|
1152
|
+
* let code = `var foo = 0;`;
|
|
1153
|
+
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
1154
|
+
* tokens.forEach(token => {
|
|
1155
|
+
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
1156
|
+
* console.log(`Found numeric literal: ${token.content}`);
|
|
1157
|
+
* }
|
|
1158
|
+
* });
|
|
1159
|
+
*/
|
|
1160
|
+
tokenize: function(t, r) {
|
|
1161
|
+
var i = r.rest;
|
|
1162
|
+
if (i) {
|
|
1163
|
+
for (var s in i)
|
|
1164
|
+
r[s] = i[s];
|
|
1165
|
+
delete r.rest;
|
|
1166
|
+
}
|
|
1167
|
+
var o = new L();
|
|
1168
|
+
return j(o, o.head, t), F(t, o, r, o.head, 0), Y(o);
|
|
1169
|
+
},
|
|
1170
|
+
/**
|
|
1171
|
+
* @namespace
|
|
1172
|
+
* @memberof Prism
|
|
1173
|
+
* @public
|
|
1174
|
+
*/
|
|
1175
|
+
hooks: {
|
|
1176
|
+
all: {},
|
|
1177
|
+
/**
|
|
1178
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
1179
|
+
*
|
|
1180
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
1181
|
+
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
1182
|
+
*
|
|
1183
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
1184
|
+
*
|
|
1185
|
+
* @param {string} name The name of the hook.
|
|
1186
|
+
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
1187
|
+
* @public
|
|
1188
|
+
*/
|
|
1189
|
+
add: function(t, r) {
|
|
1190
|
+
var i = l.hooks.all;
|
|
1191
|
+
i[t] = i[t] || [], i[t].push(r);
|
|
1192
|
+
},
|
|
1193
|
+
/**
|
|
1194
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
1195
|
+
*
|
|
1196
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
1197
|
+
*
|
|
1198
|
+
* @param {string} name The name of the hook.
|
|
1199
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
1200
|
+
* @public
|
|
1201
|
+
*/
|
|
1202
|
+
run: function(t, r) {
|
|
1203
|
+
var i = l.hooks.all[t];
|
|
1204
|
+
if (!(!i || !i.length))
|
|
1205
|
+
for (var s = 0, o; o = i[s++]; )
|
|
1206
|
+
o(r);
|
|
1207
|
+
}
|
|
1208
|
+
},
|
|
1209
|
+
Token: m
|
|
1210
|
+
};
|
|
1211
|
+
c.Prism = l;
|
|
1212
|
+
function m(t, r, i, s) {
|
|
1213
|
+
this.type = t, this.content = r, this.alias = i, this.length = (s || "").length | 0;
|
|
1214
|
+
}
|
|
1215
|
+
m.stringify = function t(r, i) {
|
|
1216
|
+
if (typeof r == "string")
|
|
1217
|
+
return r;
|
|
1218
|
+
if (Array.isArray(r)) {
|
|
1219
|
+
var s = "";
|
|
1220
|
+
return r.forEach(function(I) {
|
|
1221
|
+
s += t(I, i);
|
|
1222
|
+
}), s;
|
|
1223
|
+
}
|
|
1224
|
+
var o = {
|
|
1225
|
+
type: r.type,
|
|
1226
|
+
content: t(r.content, i),
|
|
1227
|
+
tag: "span",
|
|
1228
|
+
classes: ["token", r.type],
|
|
1229
|
+
attributes: {},
|
|
1230
|
+
language: i
|
|
1231
|
+
}, d = r.alias;
|
|
1232
|
+
d && (Array.isArray(d) ? Array.prototype.push.apply(o.classes, d) : o.classes.push(d)), l.hooks.run("wrap", o);
|
|
1233
|
+
var v = "";
|
|
1234
|
+
for (var p in o.attributes)
|
|
1235
|
+
v += " " + p + '="' + (o.attributes[p] || "").replace(/"/g, """) + '"';
|
|
1236
|
+
return "<" + o.tag + ' class="' + o.classes.join(" ") + '"' + v + ">" + o.content + "</" + o.tag + ">";
|
|
1237
|
+
};
|
|
1238
|
+
function S(t, r, i, s) {
|
|
1239
|
+
t.lastIndex = r;
|
|
1240
|
+
var o = t.exec(i);
|
|
1241
|
+
if (o && s && o[1]) {
|
|
1242
|
+
var d = o[1].length;
|
|
1243
|
+
o.index += d, o[0] = o[0].slice(d);
|
|
1244
|
+
}
|
|
1245
|
+
return o;
|
|
1246
|
+
}
|
|
1247
|
+
function F(t, r, i, s, o, d) {
|
|
1248
|
+
for (var v in i)
|
|
1249
|
+
if (!(!i.hasOwnProperty(v) || !i[v])) {
|
|
1250
|
+
var p = i[v];
|
|
1251
|
+
p = Array.isArray(p) ? p : [p];
|
|
1252
|
+
for (var I = 0; I < p.length; ++I) {
|
|
1253
|
+
if (d && d.cause == v + "," + I)
|
|
1254
|
+
return;
|
|
1255
|
+
var P = p[I], B = P.inside, V = !!P.lookbehind, z = !!P.greedy, ne = P.alias;
|
|
1256
|
+
if (z && !P.pattern.global) {
|
|
1257
|
+
var ce = P.pattern.toString().match(/[imsuy]*$/)[0];
|
|
1258
|
+
P.pattern = RegExp(P.pattern.source, ce + "g");
|
|
1259
|
+
}
|
|
1260
|
+
for (var le = P.pattern || P, D = s.next, H = o; D !== r.tail && !(d && H >= d.reach); H += D.value.length, D = D.next) {
|
|
1261
|
+
var ee = D.value;
|
|
1262
|
+
if (r.length > t.length)
|
|
1263
|
+
return;
|
|
1264
|
+
if (!(ee instanceof m)) {
|
|
1265
|
+
var X = 1, G;
|
|
1266
|
+
if (z) {
|
|
1267
|
+
if (G = S(le, H, t, V), !G || G.index >= t.length)
|
|
1268
|
+
break;
|
|
1269
|
+
var ae = G.index, pe = G.index + G[0].length, Z = H;
|
|
1270
|
+
for (Z += D.value.length; ae >= Z; )
|
|
1271
|
+
D = D.next, Z += D.value.length;
|
|
1272
|
+
if (Z -= D.value.length, H = Z, D.value instanceof m)
|
|
1273
|
+
continue;
|
|
1274
|
+
for (var oe = D; oe !== r.tail && (Z < pe || typeof oe.value == "string"); oe = oe.next)
|
|
1275
|
+
X++, Z += oe.value.length;
|
|
1276
|
+
X--, ee = t.slice(H, Z), G.index -= H;
|
|
1277
|
+
} else if (G = S(le, 0, ee, V), !G)
|
|
1278
|
+
continue;
|
|
1279
|
+
var ae = G.index, q = G[0], ie = ee.slice(0, ae), se = ee.slice(ae + q.length), te = H + ee.length;
|
|
1280
|
+
d && te > d.reach && (d.reach = te);
|
|
1281
|
+
var A = D.prev;
|
|
1282
|
+
ie && (A = j(r, A, ie), H += ie.length), C(r, A, X);
|
|
1283
|
+
var M = new m(v, B ? l.tokenize(q, B) : q, ne, q);
|
|
1284
|
+
if (D = j(r, A, M), se && j(r, D, se), X > 1) {
|
|
1285
|
+
var re = {
|
|
1286
|
+
cause: v + "," + I,
|
|
1287
|
+
reach: te
|
|
1288
|
+
};
|
|
1289
|
+
F(t, r, i, D.prev, H, re), d && re.reach > d.reach && (d.reach = re.reach);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
function L() {
|
|
1297
|
+
var t = { value: null, prev: null, next: null }, r = { value: null, prev: t, next: null };
|
|
1298
|
+
t.next = r, this.head = t, this.tail = r, this.length = 0;
|
|
1299
|
+
}
|
|
1300
|
+
function j(t, r, i) {
|
|
1301
|
+
var s = r.next, o = { value: i, prev: r, next: s };
|
|
1302
|
+
return r.next = o, s.prev = o, t.length++, o;
|
|
1303
|
+
}
|
|
1304
|
+
function C(t, r, i) {
|
|
1305
|
+
for (var s = r.next, o = 0; o < i && s !== t.tail; o++)
|
|
1306
|
+
s = s.next;
|
|
1307
|
+
r.next = s, s.prev = r, t.length -= o;
|
|
1308
|
+
}
|
|
1309
|
+
function Y(t) {
|
|
1310
|
+
for (var r = [], i = t.head.next; i !== t.tail; )
|
|
1311
|
+
r.push(i.value), i = i.next;
|
|
1312
|
+
return r;
|
|
1313
|
+
}
|
|
1314
|
+
if (!c.document)
|
|
1315
|
+
return c.addEventListener && (l.disableWorkerMessageHandler || c.addEventListener("message", function(t) {
|
|
1316
|
+
var r = JSON.parse(t.data), i = r.language, s = r.code, o = r.immediateClose;
|
|
1317
|
+
c.postMessage(l.highlight(s, l.languages[i], i)), o && c.close();
|
|
1318
|
+
}, !1)), l;
|
|
1319
|
+
var O = l.util.currentScript();
|
|
1320
|
+
O && (l.filename = O.src, O.hasAttribute("data-manual") && (l.manual = !0));
|
|
1321
|
+
function R() {
|
|
1322
|
+
l.manual || l.highlightAll();
|
|
1323
|
+
}
|
|
1324
|
+
if (!l.manual) {
|
|
1325
|
+
var T = document.readyState;
|
|
1326
|
+
T === "loading" || T === "interactive" && O && O.defer ? document.addEventListener("DOMContentLoaded", R) : window.requestAnimationFrame ? window.requestAnimationFrame(R) : window.setTimeout(R, 16);
|
|
1327
|
+
}
|
|
1328
|
+
return l;
|
|
1329
|
+
}(g);
|
|
1330
|
+
f.exports && (f.exports = n), typeof Ve < "u" && (Ve.Prism = n), n.languages.markup = {
|
|
1331
|
+
comment: {
|
|
1332
|
+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
1333
|
+
greedy: !0
|
|
1334
|
+
},
|
|
1335
|
+
prolog: {
|
|
1336
|
+
pattern: /<\?[\s\S]+?\?>/,
|
|
1337
|
+
greedy: !0
|
|
1338
|
+
},
|
|
1339
|
+
doctype: {
|
|
1340
|
+
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
1341
|
+
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
1342
|
+
greedy: !0,
|
|
1343
|
+
inside: {
|
|
1344
|
+
"internal-subset": {
|
|
1345
|
+
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
1346
|
+
lookbehind: !0,
|
|
1347
|
+
greedy: !0,
|
|
1348
|
+
inside: null
|
|
1349
|
+
// see below
|
|
1350
|
+
},
|
|
1351
|
+
string: {
|
|
1352
|
+
pattern: /"[^"]*"|'[^']*'/,
|
|
1353
|
+
greedy: !0
|
|
1354
|
+
},
|
|
1355
|
+
punctuation: /^<!|>$|[[\]]/,
|
|
1356
|
+
"doctype-tag": /^DOCTYPE/i,
|
|
1357
|
+
name: /[^\s<>'"]+/
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
cdata: {
|
|
1361
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1362
|
+
greedy: !0
|
|
1363
|
+
},
|
|
1364
|
+
tag: {
|
|
1365
|
+
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
1366
|
+
greedy: !0,
|
|
1367
|
+
inside: {
|
|
1368
|
+
tag: {
|
|
1369
|
+
pattern: /^<\/?[^\s>\/]+/,
|
|
1370
|
+
inside: {
|
|
1371
|
+
punctuation: /^<\/?/,
|
|
1372
|
+
namespace: /^[^\s>\/:]+:/
|
|
1373
|
+
}
|
|
1374
|
+
},
|
|
1375
|
+
"special-attr": [],
|
|
1376
|
+
"attr-value": {
|
|
1377
|
+
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
1378
|
+
inside: {
|
|
1379
|
+
punctuation: [
|
|
1380
|
+
{
|
|
1381
|
+
pattern: /^=/,
|
|
1382
|
+
alias: "attr-equals"
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
pattern: /^(\s*)["']|["']$/,
|
|
1386
|
+
lookbehind: !0
|
|
1387
|
+
}
|
|
1388
|
+
]
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
punctuation: /\/?>/,
|
|
1392
|
+
"attr-name": {
|
|
1393
|
+
pattern: /[^\s>\/]+/,
|
|
1394
|
+
inside: {
|
|
1395
|
+
namespace: /^[^\s>\/:]+:/
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
entity: [
|
|
1401
|
+
{
|
|
1402
|
+
pattern: /&[\da-z]{1,8};/i,
|
|
1403
|
+
alias: "named-entity"
|
|
1404
|
+
},
|
|
1405
|
+
/&#x?[\da-f]{1,8};/i
|
|
1406
|
+
]
|
|
1407
|
+
}, n.languages.markup.tag.inside["attr-value"].inside.entity = n.languages.markup.entity, n.languages.markup.doctype.inside["internal-subset"].inside = n.languages.markup, n.hooks.add("wrap", function(c) {
|
|
1408
|
+
c.type === "entity" && (c.attributes.title = c.content.replace(/&/, "&"));
|
|
1409
|
+
}), Object.defineProperty(n.languages.markup.tag, "addInlined", {
|
|
1410
|
+
/**
|
|
1411
|
+
* Adds an inlined language to markup.
|
|
1412
|
+
*
|
|
1413
|
+
* An example of an inlined language is CSS with `<style>` tags.
|
|
1414
|
+
*
|
|
1415
|
+
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
|
1416
|
+
* case insensitive.
|
|
1417
|
+
* @param {string} lang The language key.
|
|
1418
|
+
* @example
|
|
1419
|
+
* addInlined('style', 'css');
|
|
1420
|
+
*/
|
|
1421
|
+
value: function(h, _) {
|
|
1422
|
+
var x = {};
|
|
1423
|
+
x["language-" + _] = {
|
|
1424
|
+
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1425
|
+
lookbehind: !0,
|
|
1426
|
+
inside: n.languages[_]
|
|
1427
|
+
}, x.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
1428
|
+
var l = {
|
|
1429
|
+
"included-cdata": {
|
|
1430
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1431
|
+
inside: x
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
l["language-" + _] = {
|
|
1435
|
+
pattern: /[\s\S]+/,
|
|
1436
|
+
inside: n.languages[_]
|
|
1437
|
+
};
|
|
1438
|
+
var m = {};
|
|
1439
|
+
m[h] = {
|
|
1440
|
+
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1441
|
+
return h;
|
|
1442
|
+
}), "i"),
|
|
1443
|
+
lookbehind: !0,
|
|
1444
|
+
greedy: !0,
|
|
1445
|
+
inside: l
|
|
1446
|
+
}, n.languages.insertBefore("markup", "cdata", m);
|
|
1447
|
+
}
|
|
1448
|
+
}), Object.defineProperty(n.languages.markup.tag, "addAttribute", {
|
|
1449
|
+
/**
|
|
1450
|
+
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
1451
|
+
*
|
|
1452
|
+
* An example of an inlined language is CSS with `style` attributes.
|
|
1453
|
+
*
|
|
1454
|
+
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
|
1455
|
+
* case insensitive.
|
|
1456
|
+
* @param {string} lang The language key.
|
|
1457
|
+
* @example
|
|
1458
|
+
* addAttribute('style', 'css');
|
|
1459
|
+
*/
|
|
1460
|
+
value: function(c, h) {
|
|
1461
|
+
n.languages.markup.tag.inside["special-attr"].push({
|
|
1462
|
+
pattern: RegExp(
|
|
1463
|
+
/(^|["'\s])/.source + "(?:" + c + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1464
|
+
"i"
|
|
1465
|
+
),
|
|
1466
|
+
lookbehind: !0,
|
|
1467
|
+
inside: {
|
|
1468
|
+
"attr-name": /^[^\s=]+/,
|
|
1469
|
+
"attr-value": {
|
|
1470
|
+
pattern: /=[\s\S]+/,
|
|
1471
|
+
inside: {
|
|
1472
|
+
value: {
|
|
1473
|
+
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1474
|
+
lookbehind: !0,
|
|
1475
|
+
alias: [h, "language-" + h],
|
|
1476
|
+
inside: n.languages[h]
|
|
1477
|
+
},
|
|
1478
|
+
punctuation: [
|
|
1479
|
+
{
|
|
1480
|
+
pattern: /^=/,
|
|
1481
|
+
alias: "attr-equals"
|
|
1482
|
+
},
|
|
1483
|
+
/"|'/
|
|
1484
|
+
]
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
}), n.languages.html = n.languages.markup, n.languages.mathml = n.languages.markup, n.languages.svg = n.languages.markup, n.languages.xml = n.languages.extend("markup", {}), n.languages.ssml = n.languages.xml, n.languages.atom = n.languages.xml, n.languages.rss = n.languages.xml, function(c) {
|
|
1491
|
+
var h = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1492
|
+
c.languages.css = {
|
|
1493
|
+
comment: /\/\*[\s\S]*?\*\//,
|
|
1494
|
+
atrule: {
|
|
1495
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + h.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1496
|
+
inside: {
|
|
1497
|
+
rule: /^@[\w-]+/,
|
|
1498
|
+
"selector-function-argument": {
|
|
1499
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
1500
|
+
lookbehind: !0,
|
|
1501
|
+
alias: "selector"
|
|
1502
|
+
},
|
|
1503
|
+
keyword: {
|
|
1504
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
1505
|
+
lookbehind: !0
|
|
1506
|
+
}
|
|
1507
|
+
// See rest below
|
|
1508
|
+
}
|
|
1509
|
+
},
|
|
1510
|
+
url: {
|
|
1511
|
+
// https://drafts.csswg.org/css-values-3/#urls
|
|
1512
|
+
pattern: RegExp("\\burl\\((?:" + h.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1513
|
+
greedy: !0,
|
|
1514
|
+
inside: {
|
|
1515
|
+
function: /^url/i,
|
|
1516
|
+
punctuation: /^\(|\)$/,
|
|
1517
|
+
string: {
|
|
1518
|
+
pattern: RegExp("^" + h.source + "$"),
|
|
1519
|
+
alias: "url"
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
selector: {
|
|
1524
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + h.source + ")*(?=\\s*\\{)"),
|
|
1525
|
+
lookbehind: !0
|
|
1526
|
+
},
|
|
1527
|
+
string: {
|
|
1528
|
+
pattern: h,
|
|
1529
|
+
greedy: !0
|
|
1530
|
+
},
|
|
1531
|
+
property: {
|
|
1532
|
+
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
1533
|
+
lookbehind: !0
|
|
1534
|
+
},
|
|
1535
|
+
important: /!important\b/i,
|
|
1536
|
+
function: {
|
|
1537
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
1538
|
+
lookbehind: !0
|
|
1539
|
+
},
|
|
1540
|
+
punctuation: /[(){};:,]/
|
|
1541
|
+
}, c.languages.css.atrule.inside.rest = c.languages.css;
|
|
1542
|
+
var _ = c.languages.markup;
|
|
1543
|
+
_ && (_.tag.addInlined("style", "css"), _.tag.addAttribute("style", "css"));
|
|
1544
|
+
}(n), n.languages.clike = {
|
|
1545
|
+
comment: [
|
|
1546
|
+
{
|
|
1547
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1548
|
+
lookbehind: !0,
|
|
1549
|
+
greedy: !0
|
|
1550
|
+
},
|
|
1551
|
+
{
|
|
1552
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
1553
|
+
lookbehind: !0,
|
|
1554
|
+
greedy: !0
|
|
1555
|
+
}
|
|
1556
|
+
],
|
|
1557
|
+
string: {
|
|
1558
|
+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1559
|
+
greedy: !0
|
|
1560
|
+
},
|
|
1561
|
+
"class-name": {
|
|
1562
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1563
|
+
lookbehind: !0,
|
|
1564
|
+
inside: {
|
|
1565
|
+
punctuation: /[.\\]/
|
|
1566
|
+
}
|
|
1567
|
+
},
|
|
1568
|
+
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1569
|
+
boolean: /\b(?:false|true)\b/,
|
|
1570
|
+
function: /\b\w+(?=\()/,
|
|
1571
|
+
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1572
|
+
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1573
|
+
punctuation: /[{}[\];(),.:]/
|
|
1574
|
+
}, n.languages.javascript = n.languages.extend("clike", {
|
|
1575
|
+
"class-name": [
|
|
1576
|
+
n.languages.clike["class-name"],
|
|
1577
|
+
{
|
|
1578
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1579
|
+
lookbehind: !0
|
|
1580
|
+
}
|
|
1581
|
+
],
|
|
1582
|
+
keyword: [
|
|
1583
|
+
{
|
|
1584
|
+
pattern: /((?:^|\})\s*)catch\b/,
|
|
1585
|
+
lookbehind: !0
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
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/,
|
|
1589
|
+
lookbehind: !0
|
|
1590
|
+
}
|
|
1591
|
+
],
|
|
1592
|
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1593
|
+
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1594
|
+
number: {
|
|
1595
|
+
pattern: RegExp(
|
|
1596
|
+
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1597
|
+
(/NaN|Infinity/.source + "|" + // binary integer
|
|
1598
|
+
/0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
|
|
1599
|
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
|
|
1600
|
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
|
|
1601
|
+
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1602
|
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1603
|
+
),
|
|
1604
|
+
lookbehind: !0
|
|
1605
|
+
},
|
|
1606
|
+
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1607
|
+
}), n.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, n.languages.insertBefore("javascript", "keyword", {
|
|
1608
|
+
regex: {
|
|
1609
|
+
pattern: RegExp(
|
|
1610
|
+
// lookbehind
|
|
1611
|
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
1612
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
|
|
1613
|
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
1614
|
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
1615
|
+
// with the only syntax, so we have to define 2 different regex patterns.
|
|
1616
|
+
/\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
|
|
1617
|
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1618
|
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1619
|
+
),
|
|
1620
|
+
lookbehind: !0,
|
|
1621
|
+
greedy: !0,
|
|
1622
|
+
inside: {
|
|
1623
|
+
"regex-source": {
|
|
1624
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1625
|
+
lookbehind: !0,
|
|
1626
|
+
alias: "language-regex",
|
|
1627
|
+
inside: n.languages.regex
|
|
1628
|
+
},
|
|
1629
|
+
"regex-delimiter": /^\/|\/$/,
|
|
1630
|
+
"regex-flags": /^[a-z]+$/
|
|
1631
|
+
}
|
|
1632
|
+
},
|
|
1633
|
+
// This must be declared before keyword because we use "function" inside the look-forward
|
|
1634
|
+
"function-variable": {
|
|
1635
|
+
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*=>))/,
|
|
1636
|
+
alias: "function"
|
|
1637
|
+
},
|
|
1638
|
+
parameter: [
|
|
1639
|
+
{
|
|
1640
|
+
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1641
|
+
lookbehind: !0,
|
|
1642
|
+
inside: n.languages.javascript
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1646
|
+
lookbehind: !0,
|
|
1647
|
+
inside: n.languages.javascript
|
|
1648
|
+
},
|
|
1649
|
+
{
|
|
1650
|
+
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1651
|
+
lookbehind: !0,
|
|
1652
|
+
inside: n.languages.javascript
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
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*\{)/,
|
|
1656
|
+
lookbehind: !0,
|
|
1657
|
+
inside: n.languages.javascript
|
|
1658
|
+
}
|
|
1659
|
+
],
|
|
1660
|
+
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1661
|
+
}), n.languages.insertBefore("javascript", "string", {
|
|
1662
|
+
hashbang: {
|
|
1663
|
+
pattern: /^#!.*/,
|
|
1664
|
+
greedy: !0,
|
|
1665
|
+
alias: "comment"
|
|
1666
|
+
},
|
|
1667
|
+
"template-string": {
|
|
1668
|
+
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1669
|
+
greedy: !0,
|
|
1670
|
+
inside: {
|
|
1671
|
+
"template-punctuation": {
|
|
1672
|
+
pattern: /^`|`$/,
|
|
1673
|
+
alias: "string"
|
|
1674
|
+
},
|
|
1675
|
+
interpolation: {
|
|
1676
|
+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1677
|
+
lookbehind: !0,
|
|
1678
|
+
inside: {
|
|
1679
|
+
"interpolation-punctuation": {
|
|
1680
|
+
pattern: /^\$\{|\}$/,
|
|
1681
|
+
alias: "punctuation"
|
|
1682
|
+
},
|
|
1683
|
+
rest: n.languages.javascript
|
|
1684
|
+
}
|
|
1685
|
+
},
|
|
1686
|
+
string: /[\s\S]+/
|
|
1687
|
+
}
|
|
1688
|
+
},
|
|
1689
|
+
"string-property": {
|
|
1690
|
+
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1691
|
+
lookbehind: !0,
|
|
1692
|
+
greedy: !0,
|
|
1693
|
+
alias: "property"
|
|
1694
|
+
}
|
|
1695
|
+
}), n.languages.insertBefore("javascript", "operator", {
|
|
1696
|
+
"literal-property": {
|
|
1697
|
+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1698
|
+
lookbehind: !0,
|
|
1699
|
+
alias: "property"
|
|
1700
|
+
}
|
|
1701
|
+
}), n.languages.markup && (n.languages.markup.tag.addInlined("script", "javascript"), n.languages.markup.tag.addAttribute(
|
|
1702
|
+
/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,
|
|
1703
|
+
"javascript"
|
|
1704
|
+
)), n.languages.js = n.languages.javascript, function() {
|
|
1705
|
+
if (typeof n > "u" || typeof document > "u")
|
|
1706
|
+
return;
|
|
1707
|
+
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1708
|
+
var c = "Loading…", h = function(O, R) {
|
|
1709
|
+
return "✖ Error " + O + " while fetching file: " + R;
|
|
1710
|
+
}, _ = "✖ Error: File does not exist or is empty", x = {
|
|
1711
|
+
js: "javascript",
|
|
1712
|
+
py: "python",
|
|
1713
|
+
rb: "ruby",
|
|
1714
|
+
ps1: "powershell",
|
|
1715
|
+
psm1: "powershell",
|
|
1716
|
+
sh: "bash",
|
|
1717
|
+
bat: "batch",
|
|
1718
|
+
h: "c",
|
|
1719
|
+
tex: "latex"
|
|
1720
|
+
}, l = "data-src-status", m = "loading", S = "loaded", F = "failed", L = "pre[data-src]:not([" + l + '="' + S + '"]):not([' + l + '="' + m + '"])';
|
|
1721
|
+
function j(O, R, T) {
|
|
1722
|
+
var t = new XMLHttpRequest();
|
|
1723
|
+
t.open("GET", O, !0), t.onreadystatechange = function() {
|
|
1724
|
+
t.readyState == 4 && (t.status < 400 && t.responseText ? R(t.responseText) : t.status >= 400 ? T(h(t.status, t.statusText)) : T(_));
|
|
1725
|
+
}, t.send(null);
|
|
1726
|
+
}
|
|
1727
|
+
function C(O) {
|
|
1728
|
+
var R = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(O || "");
|
|
1729
|
+
if (R) {
|
|
1730
|
+
var T = Number(R[1]), t = R[2], r = R[3];
|
|
1731
|
+
return t ? r ? [T, Number(r)] : [T, void 0] : [T, T];
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
n.hooks.add("before-highlightall", function(O) {
|
|
1735
|
+
O.selector += ", " + L;
|
|
1736
|
+
}), n.hooks.add("before-sanity-check", function(O) {
|
|
1737
|
+
var R = (
|
|
1738
|
+
/** @type {HTMLPreElement} */
|
|
1739
|
+
O.element
|
|
1740
|
+
);
|
|
1741
|
+
if (R.matches(L)) {
|
|
1742
|
+
O.code = "", R.setAttribute(l, m);
|
|
1743
|
+
var T = R.appendChild(document.createElement("CODE"));
|
|
1744
|
+
T.textContent = c;
|
|
1745
|
+
var t = R.getAttribute("data-src"), r = O.language;
|
|
1746
|
+
if (r === "none") {
|
|
1747
|
+
var i = (/\.(\w+)$/.exec(t) || [, "none"])[1];
|
|
1748
|
+
r = x[i] || i;
|
|
1749
|
+
}
|
|
1750
|
+
n.util.setLanguage(T, r), n.util.setLanguage(R, r);
|
|
1751
|
+
var s = n.plugins.autoloader;
|
|
1752
|
+
s && s.loadLanguages(r), j(
|
|
1753
|
+
t,
|
|
1754
|
+
function(o) {
|
|
1755
|
+
R.setAttribute(l, S);
|
|
1756
|
+
var d = C(R.getAttribute("data-range"));
|
|
1757
|
+
if (d) {
|
|
1758
|
+
var v = o.split(/\r\n?|\n/g), p = d[0], I = d[1] == null ? v.length : d[1];
|
|
1759
|
+
p < 0 && (p += v.length), p = Math.max(0, Math.min(p - 1, v.length)), I < 0 && (I += v.length), I = Math.max(0, Math.min(I, v.length)), o = v.slice(p, I).join(`
|
|
1760
|
+
`), R.hasAttribute("data-start") || R.setAttribute("data-start", String(p + 1));
|
|
1761
|
+
}
|
|
1762
|
+
T.textContent = o, n.highlightElement(T);
|
|
1763
|
+
},
|
|
1764
|
+
function(o) {
|
|
1765
|
+
R.setAttribute(l, F), T.textContent = o;
|
|
1766
|
+
}
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
}), n.plugins.fileHighlight = {
|
|
1770
|
+
/**
|
|
1771
|
+
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
1772
|
+
*
|
|
1773
|
+
* Note: Elements which are already loaded or currently loading will not be touched by this method.
|
|
1774
|
+
*
|
|
1775
|
+
* @param {ParentNode} [container=document]
|
|
1776
|
+
*/
|
|
1777
|
+
highlight: function(R) {
|
|
1778
|
+
for (var T = (R || document).querySelectorAll(L), t = 0, r; r = T[t++]; )
|
|
1779
|
+
n.highlightElement(r);
|
|
1780
|
+
}
|
|
1781
|
+
};
|
|
1782
|
+
var Y = !1;
|
|
1783
|
+
n.fileHighlight = function() {
|
|
1784
|
+
Y || (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), Y = !0), n.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1785
|
+
};
|
|
1786
|
+
}();
|
|
1787
|
+
})(Je);
|
|
1788
|
+
var Tt = Je.exports;
|
|
1789
|
+
const Ne = /* @__PURE__ */ St(Tt);
|
|
1790
|
+
Prism.languages.clike = {
|
|
1791
|
+
comment: [
|
|
1792
|
+
{
|
|
1793
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1794
|
+
lookbehind: !0,
|
|
1795
|
+
greedy: !0
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
1799
|
+
lookbehind: !0,
|
|
1800
|
+
greedy: !0
|
|
1801
|
+
}
|
|
1802
|
+
],
|
|
1803
|
+
string: {
|
|
1804
|
+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1805
|
+
greedy: !0
|
|
1806
|
+
},
|
|
1807
|
+
"class-name": {
|
|
1808
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1809
|
+
lookbehind: !0,
|
|
1810
|
+
inside: {
|
|
1811
|
+
punctuation: /[.\\]/
|
|
1812
|
+
}
|
|
1813
|
+
},
|
|
1814
|
+
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1815
|
+
boolean: /\b(?:false|true)\b/,
|
|
1816
|
+
function: /\b\w+(?=\()/,
|
|
1817
|
+
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1818
|
+
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1819
|
+
punctuation: /[{}[\];(),.:]/
|
|
1820
|
+
};
|
|
1821
|
+
Prism.languages.javascript = Prism.languages.extend("clike", {
|
|
1822
|
+
"class-name": [
|
|
1823
|
+
Prism.languages.clike["class-name"],
|
|
1824
|
+
{
|
|
1825
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1826
|
+
lookbehind: !0
|
|
1827
|
+
}
|
|
1828
|
+
],
|
|
1829
|
+
keyword: [
|
|
1830
|
+
{
|
|
1831
|
+
pattern: /((?:^|\})\s*)catch\b/,
|
|
1832
|
+
lookbehind: !0
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
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/,
|
|
1836
|
+
lookbehind: !0
|
|
1837
|
+
}
|
|
1838
|
+
],
|
|
1839
|
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1840
|
+
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1841
|
+
number: {
|
|
1842
|
+
pattern: RegExp(
|
|
1843
|
+
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1844
|
+
(/NaN|Infinity/.source + "|" + // binary integer
|
|
1845
|
+
/0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
|
|
1846
|
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
|
|
1847
|
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
|
|
1848
|
+
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1849
|
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1850
|
+
),
|
|
1851
|
+
lookbehind: !0
|
|
1852
|
+
},
|
|
1853
|
+
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1854
|
+
});
|
|
1855
|
+
Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
1856
|
+
Prism.languages.insertBefore("javascript", "keyword", {
|
|
1857
|
+
regex: {
|
|
1858
|
+
pattern: RegExp(
|
|
1859
|
+
// lookbehind
|
|
1860
|
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
1861
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
|
|
1862
|
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
1863
|
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
1864
|
+
// with the only syntax, so we have to define 2 different regex patterns.
|
|
1865
|
+
/\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
|
|
1866
|
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1867
|
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1868
|
+
),
|
|
1869
|
+
lookbehind: !0,
|
|
1870
|
+
greedy: !0,
|
|
1871
|
+
inside: {
|
|
1872
|
+
"regex-source": {
|
|
1873
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1874
|
+
lookbehind: !0,
|
|
1875
|
+
alias: "language-regex",
|
|
1876
|
+
inside: Prism.languages.regex
|
|
1877
|
+
},
|
|
1878
|
+
"regex-delimiter": /^\/|\/$/,
|
|
1879
|
+
"regex-flags": /^[a-z]+$/
|
|
1880
|
+
}
|
|
1881
|
+
},
|
|
1882
|
+
// This must be declared before keyword because we use "function" inside the look-forward
|
|
1883
|
+
"function-variable": {
|
|
1884
|
+
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*=>))/,
|
|
1885
|
+
alias: "function"
|
|
1886
|
+
},
|
|
1887
|
+
parameter: [
|
|
1888
|
+
{
|
|
1889
|
+
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1890
|
+
lookbehind: !0,
|
|
1891
|
+
inside: Prism.languages.javascript
|
|
1892
|
+
},
|
|
1893
|
+
{
|
|
1894
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1895
|
+
lookbehind: !0,
|
|
1896
|
+
inside: Prism.languages.javascript
|
|
1897
|
+
},
|
|
1898
|
+
{
|
|
1899
|
+
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1900
|
+
lookbehind: !0,
|
|
1901
|
+
inside: Prism.languages.javascript
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
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*\{)/,
|
|
1905
|
+
lookbehind: !0,
|
|
1906
|
+
inside: Prism.languages.javascript
|
|
1907
|
+
}
|
|
1908
|
+
],
|
|
1909
|
+
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1910
|
+
});
|
|
1911
|
+
Prism.languages.insertBefore("javascript", "string", {
|
|
1912
|
+
hashbang: {
|
|
1913
|
+
pattern: /^#!.*/,
|
|
1914
|
+
greedy: !0,
|
|
1915
|
+
alias: "comment"
|
|
1916
|
+
},
|
|
1917
|
+
"template-string": {
|
|
1918
|
+
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1919
|
+
greedy: !0,
|
|
1920
|
+
inside: {
|
|
1921
|
+
"template-punctuation": {
|
|
1922
|
+
pattern: /^`|`$/,
|
|
1923
|
+
alias: "string"
|
|
1924
|
+
},
|
|
1925
|
+
interpolation: {
|
|
1926
|
+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1927
|
+
lookbehind: !0,
|
|
1928
|
+
inside: {
|
|
1929
|
+
"interpolation-punctuation": {
|
|
1930
|
+
pattern: /^\$\{|\}$/,
|
|
1931
|
+
alias: "punctuation"
|
|
1932
|
+
},
|
|
1933
|
+
rest: Prism.languages.javascript
|
|
1934
|
+
}
|
|
1935
|
+
},
|
|
1936
|
+
string: /[\s\S]+/
|
|
1937
|
+
}
|
|
1938
|
+
},
|
|
1939
|
+
"string-property": {
|
|
1940
|
+
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1941
|
+
lookbehind: !0,
|
|
1942
|
+
greedy: !0,
|
|
1943
|
+
alias: "property"
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
Prism.languages.insertBefore("javascript", "operator", {
|
|
1947
|
+
"literal-property": {
|
|
1948
|
+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1949
|
+
lookbehind: !0,
|
|
1950
|
+
alias: "property"
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
Prism.languages.markup && (Prism.languages.markup.tag.addInlined("script", "javascript"), Prism.languages.markup.tag.addAttribute(
|
|
1954
|
+
/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,
|
|
1955
|
+
"javascript"
|
|
1956
|
+
));
|
|
1957
|
+
Prism.languages.js = Prism.languages.javascript;
|
|
1958
|
+
Prism.languages.python = {
|
|
1959
|
+
comment: {
|
|
1960
|
+
pattern: /(^|[^\\])#.*/,
|
|
1961
|
+
lookbehind: !0,
|
|
1962
|
+
greedy: !0
|
|
1963
|
+
},
|
|
1964
|
+
"string-interpolation": {
|
|
1965
|
+
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
1966
|
+
greedy: !0,
|
|
1967
|
+
inside: {
|
|
1968
|
+
interpolation: {
|
|
1969
|
+
// "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
|
1970
|
+
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
1971
|
+
lookbehind: !0,
|
|
1972
|
+
inside: {
|
|
1973
|
+
"format-spec": {
|
|
1974
|
+
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
1975
|
+
lookbehind: !0
|
|
1976
|
+
},
|
|
1977
|
+
"conversion-option": {
|
|
1978
|
+
pattern: //,
|
|
1979
|
+
alias: "punctuation"
|
|
1980
|
+
},
|
|
1981
|
+
rest: null
|
|
1982
|
+
}
|
|
1983
|
+
},
|
|
1984
|
+
string: /[\s\S]+/
|
|
1985
|
+
}
|
|
1986
|
+
},
|
|
1987
|
+
"triple-quoted-string": {
|
|
1988
|
+
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
1989
|
+
greedy: !0,
|
|
1990
|
+
alias: "string"
|
|
1991
|
+
},
|
|
1992
|
+
string: {
|
|
1993
|
+
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
1994
|
+
greedy: !0
|
|
1995
|
+
},
|
|
1996
|
+
function: {
|
|
1997
|
+
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
1998
|
+
lookbehind: !0
|
|
1999
|
+
},
|
|
2000
|
+
"class-name": {
|
|
2001
|
+
pattern: /(\bclass\s+)\w+/i,
|
|
2002
|
+
lookbehind: !0
|
|
2003
|
+
},
|
|
2004
|
+
decorator: {
|
|
2005
|
+
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
2006
|
+
lookbehind: !0,
|
|
2007
|
+
alias: ["annotation", "punctuation"],
|
|
2008
|
+
inside: {
|
|
2009
|
+
punctuation: /\./
|
|
2010
|
+
}
|
|
2011
|
+
},
|
|
2012
|
+
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/,
|
|
2013
|
+
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/,
|
|
2014
|
+
boolean: /\b(?:False|None|True)\b/,
|
|
2015
|
+
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,
|
|
2016
|
+
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
2017
|
+
punctuation: /[{}[\];(),.:]/
|
|
2018
|
+
};
|
|
2019
|
+
Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python;
|
|
2020
|
+
Prism.languages.py = Prism.languages.python;
|
|
2021
|
+
Prism.languages.go = Prism.languages.extend("clike", {
|
|
2022
|
+
string: {
|
|
2023
|
+
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
|
|
2024
|
+
lookbehind: !0,
|
|
2025
|
+
greedy: !0
|
|
2026
|
+
},
|
|
2027
|
+
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/,
|
|
2028
|
+
boolean: /\b(?:_|false|iota|nil|true)\b/,
|
|
2029
|
+
number: [
|
|
2030
|
+
// binary and octal integers
|
|
2031
|
+
/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
|
|
2032
|
+
// hexadecimal integers and floats
|
|
2033
|
+
/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
|
|
2034
|
+
// decimal integers and floats
|
|
2035
|
+
/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
|
|
2036
|
+
],
|
|
2037
|
+
operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
2038
|
+
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/
|
|
2039
|
+
});
|
|
2040
|
+
Prism.languages.insertBefore("go", "string", {
|
|
2041
|
+
char: {
|
|
2042
|
+
pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
|
|
2043
|
+
greedy: !0
|
|
2044
|
+
}
|
|
2045
|
+
});
|
|
2046
|
+
delete Prism.languages.go["class-name"];
|
|
2047
|
+
(function(f) {
|
|
2048
|
+
var g = /\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/, n = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source, c = {
|
|
2049
|
+
pattern: RegExp(/(^|[^\w.])/.source + n + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
|
|
2050
|
+
lookbehind: !0,
|
|
2051
|
+
inside: {
|
|
2052
|
+
namespace: {
|
|
2053
|
+
pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
|
|
2054
|
+
inside: {
|
|
2055
|
+
punctuation: /\./
|
|
2056
|
+
}
|
|
2057
|
+
},
|
|
2058
|
+
punctuation: /\./
|
|
2059
|
+
}
|
|
2060
|
+
};
|
|
2061
|
+
f.languages.java = f.languages.extend("clike", {
|
|
2062
|
+
string: {
|
|
2063
|
+
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
|
|
2064
|
+
lookbehind: !0,
|
|
2065
|
+
greedy: !0
|
|
2066
|
+
},
|
|
2067
|
+
"class-name": [
|
|
2068
|
+
c,
|
|
2069
|
+
{
|
|
2070
|
+
// variables, parameters, and constructor references
|
|
2071
|
+
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
2072
|
+
pattern: RegExp(/(^|[^\w.])/.source + n + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
|
|
2073
|
+
lookbehind: !0,
|
|
2074
|
+
inside: c.inside
|
|
2075
|
+
},
|
|
2076
|
+
{
|
|
2077
|
+
// class names based on keyword
|
|
2078
|
+
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
2079
|
+
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + n + /[A-Z]\w*\b/.source),
|
|
2080
|
+
lookbehind: !0,
|
|
2081
|
+
inside: c.inside
|
|
2082
|
+
}
|
|
2083
|
+
],
|
|
2084
|
+
keyword: g,
|
|
2085
|
+
function: [
|
|
2086
|
+
f.languages.clike.function,
|
|
2087
|
+
{
|
|
2088
|
+
pattern: /(::\s*)[a-z_]\w*/,
|
|
2089
|
+
lookbehind: !0
|
|
2090
|
+
}
|
|
2091
|
+
],
|
|
2092
|
+
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,
|
|
2093
|
+
operator: {
|
|
2094
|
+
pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
|
2095
|
+
lookbehind: !0
|
|
2096
|
+
},
|
|
2097
|
+
constant: /\b[A-Z][A-Z_\d]+\b/
|
|
2098
|
+
}), f.languages.insertBefore("java", "string", {
|
|
2099
|
+
"triple-quoted-string": {
|
|
2100
|
+
// http://openjdk.java.net/jeps/355#Description
|
|
2101
|
+
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
2102
|
+
greedy: !0,
|
|
2103
|
+
alias: "string"
|
|
2104
|
+
},
|
|
2105
|
+
char: {
|
|
2106
|
+
pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
|
|
2107
|
+
greedy: !0
|
|
2108
|
+
}
|
|
2109
|
+
}), f.languages.insertBefore("java", "class-name", {
|
|
2110
|
+
annotation: {
|
|
2111
|
+
pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
|
|
2112
|
+
lookbehind: !0,
|
|
2113
|
+
alias: "punctuation"
|
|
2114
|
+
},
|
|
2115
|
+
generics: {
|
|
2116
|
+
pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
|
|
2117
|
+
inside: {
|
|
2118
|
+
"class-name": c,
|
|
2119
|
+
keyword: g,
|
|
2120
|
+
punctuation: /[<>(),.:]/,
|
|
2121
|
+
operator: /[?&|]/
|
|
2122
|
+
}
|
|
2123
|
+
},
|
|
2124
|
+
import: [
|
|
2125
|
+
{
|
|
2126
|
+
pattern: RegExp(/(\bimport\s+)/.source + n + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
|
|
2127
|
+
lookbehind: !0,
|
|
2128
|
+
inside: {
|
|
2129
|
+
namespace: c.inside.namespace,
|
|
2130
|
+
punctuation: /\./,
|
|
2131
|
+
operator: /\*/,
|
|
2132
|
+
"class-name": /\w+/
|
|
2133
|
+
}
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
pattern: RegExp(/(\bimport\s+static\s+)/.source + n + /(?:\w+|\*)(?=\s*;)/.source),
|
|
2137
|
+
lookbehind: !0,
|
|
2138
|
+
alias: "static",
|
|
2139
|
+
inside: {
|
|
2140
|
+
namespace: c.inside.namespace,
|
|
2141
|
+
static: /\b\w+$/,
|
|
2142
|
+
punctuation: /\./,
|
|
2143
|
+
operator: /\*/,
|
|
2144
|
+
"class-name": /\w+/
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
],
|
|
2148
|
+
namespace: {
|
|
2149
|
+
pattern: RegExp(
|
|
2150
|
+
/(\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() {
|
|
2151
|
+
return g.source;
|
|
2152
|
+
})
|
|
2153
|
+
),
|
|
2154
|
+
lookbehind: !0,
|
|
2155
|
+
inside: {
|
|
2156
|
+
punctuation: /\./
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
})(Prism);
|
|
2161
|
+
Prism.languages.c = Prism.languages.extend("clike", {
|
|
2162
|
+
comment: {
|
|
2163
|
+
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2164
|
+
greedy: !0
|
|
2165
|
+
},
|
|
2166
|
+
string: {
|
|
2167
|
+
// https://en.cppreference.com/w/c/language/string_literal
|
|
2168
|
+
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
2169
|
+
greedy: !0
|
|
2170
|
+
},
|
|
2171
|
+
"class-name": {
|
|
2172
|
+
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
2173
|
+
lookbehind: !0
|
|
2174
|
+
},
|
|
2175
|
+
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/,
|
|
2176
|
+
function: /\b[a-z_]\w*(?=\s*\()/i,
|
|
2177
|
+
number: /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
2178
|
+
operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
2179
|
+
});
|
|
2180
|
+
Prism.languages.insertBefore("c", "string", {
|
|
2181
|
+
char: {
|
|
2182
|
+
// https://en.cppreference.com/w/c/language/character_constant
|
|
2183
|
+
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
2184
|
+
greedy: !0
|
|
2185
|
+
}
|
|
2186
|
+
});
|
|
2187
|
+
Prism.languages.insertBefore("c", "string", {
|
|
2188
|
+
macro: {
|
|
2189
|
+
// allow for multiline macro definitions
|
|
2190
|
+
// spaces after the # character compile fine with gcc
|
|
2191
|
+
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
2192
|
+
lookbehind: !0,
|
|
2193
|
+
greedy: !0,
|
|
2194
|
+
alias: "property",
|
|
2195
|
+
inside: {
|
|
2196
|
+
string: [
|
|
2197
|
+
{
|
|
2198
|
+
// highlight the path of the include statement as a string
|
|
2199
|
+
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
2200
|
+
lookbehind: !0
|
|
2201
|
+
},
|
|
2202
|
+
Prism.languages.c.string
|
|
2203
|
+
],
|
|
2204
|
+
char: Prism.languages.c.char,
|
|
2205
|
+
comment: Prism.languages.c.comment,
|
|
2206
|
+
"macro-name": [
|
|
2207
|
+
{
|
|
2208
|
+
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
2209
|
+
lookbehind: !0
|
|
2210
|
+
},
|
|
2211
|
+
{
|
|
2212
|
+
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
2213
|
+
lookbehind: !0,
|
|
2214
|
+
alias: "function"
|
|
2215
|
+
}
|
|
2216
|
+
],
|
|
2217
|
+
// highlight macro directives as keywords
|
|
2218
|
+
directive: {
|
|
2219
|
+
pattern: /^(#\s*)[a-z]+/,
|
|
2220
|
+
lookbehind: !0,
|
|
2221
|
+
alias: "keyword"
|
|
2222
|
+
},
|
|
2223
|
+
"directive-hash": /^#/,
|
|
2224
|
+
punctuation: /##|\\(?=[\r\n])/,
|
|
2225
|
+
expression: {
|
|
2226
|
+
pattern: /\S[\s\S]*/,
|
|
2227
|
+
inside: Prism.languages.c
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
Prism.languages.insertBefore("c", "function", {
|
|
2233
|
+
// highlight predefined macros as constants
|
|
2234
|
+
constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
2235
|
+
});
|
|
2236
|
+
delete Prism.languages.c.boolean;
|
|
2237
|
+
(function(f) {
|
|
2238
|
+
for (var g = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source, n = 0; n < 2; n++)
|
|
2239
|
+
g = g.replace(/<self>/g, function() {
|
|
2240
|
+
return g;
|
|
2241
|
+
});
|
|
2242
|
+
g = g.replace(/<self>/g, function() {
|
|
2243
|
+
return /[^\s\S]/.source;
|
|
2244
|
+
}), f.languages.rust = {
|
|
2245
|
+
comment: [
|
|
2246
|
+
{
|
|
2247
|
+
pattern: RegExp(/(^|[^\\])/.source + g),
|
|
2248
|
+
lookbehind: !0,
|
|
2249
|
+
greedy: !0
|
|
2250
|
+
},
|
|
2251
|
+
{
|
|
2252
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
2253
|
+
lookbehind: !0,
|
|
2254
|
+
greedy: !0
|
|
2255
|
+
}
|
|
2256
|
+
],
|
|
2257
|
+
string: {
|
|
2258
|
+
pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
|
|
2259
|
+
greedy: !0
|
|
2260
|
+
},
|
|
2261
|
+
char: {
|
|
2262
|
+
pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
|
|
2263
|
+
greedy: !0
|
|
2264
|
+
},
|
|
2265
|
+
attribute: {
|
|
2266
|
+
pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
|
|
2267
|
+
greedy: !0,
|
|
2268
|
+
alias: "attr-name",
|
|
2269
|
+
inside: {
|
|
2270
|
+
string: null
|
|
2271
|
+
// see below
|
|
2272
|
+
}
|
|
2273
|
+
},
|
|
2274
|
+
// Closure params should not be confused with bitwise OR |
|
|
2275
|
+
"closure-params": {
|
|
2276
|
+
pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
|
|
2277
|
+
lookbehind: !0,
|
|
2278
|
+
greedy: !0,
|
|
2279
|
+
inside: {
|
|
2280
|
+
"closure-punctuation": {
|
|
2281
|
+
pattern: /^\||\|$/,
|
|
2282
|
+
alias: "punctuation"
|
|
2283
|
+
},
|
|
2284
|
+
rest: null
|
|
2285
|
+
// see below
|
|
2286
|
+
}
|
|
2287
|
+
},
|
|
2288
|
+
"lifetime-annotation": {
|
|
2289
|
+
pattern: /'\w+/,
|
|
2290
|
+
alias: "symbol"
|
|
2291
|
+
},
|
|
2292
|
+
"fragment-specifier": {
|
|
2293
|
+
pattern: /(\$\w+:)[a-z]+/,
|
|
2294
|
+
lookbehind: !0,
|
|
2295
|
+
alias: "punctuation"
|
|
2296
|
+
},
|
|
2297
|
+
variable: /\$\w+/,
|
|
2298
|
+
"function-definition": {
|
|
2299
|
+
pattern: /(\bfn\s+)\w+/,
|
|
2300
|
+
lookbehind: !0,
|
|
2301
|
+
alias: "function"
|
|
2302
|
+
},
|
|
2303
|
+
"type-definition": {
|
|
2304
|
+
pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
|
|
2305
|
+
lookbehind: !0,
|
|
2306
|
+
alias: "class-name"
|
|
2307
|
+
},
|
|
2308
|
+
"module-declaration": [
|
|
2309
|
+
{
|
|
2310
|
+
pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
|
|
2311
|
+
lookbehind: !0,
|
|
2312
|
+
alias: "namespace"
|
|
2313
|
+
},
|
|
2314
|
+
{
|
|
2315
|
+
pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
|
|
2316
|
+
lookbehind: !0,
|
|
2317
|
+
alias: "namespace",
|
|
2318
|
+
inside: {
|
|
2319
|
+
punctuation: /::/
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
],
|
|
2323
|
+
keyword: [
|
|
2324
|
+
// https://github.com/rust-lang/reference/blob/master/src/keywords.md
|
|
2325
|
+
/\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/,
|
|
2326
|
+
// primitives and str
|
|
2327
|
+
// https://doc.rust-lang.org/stable/rust-by-example/primitives.html
|
|
2328
|
+
/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/
|
|
2329
|
+
],
|
|
2330
|
+
// functions can technically start with an upper-case letter, but this will introduce a lot of false positives
|
|
2331
|
+
// and Rust's naming conventions recommend snake_case anyway.
|
|
2332
|
+
// https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
|
|
2333
|
+
function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
2334
|
+
macro: {
|
|
2335
|
+
pattern: /\b\w+!/,
|
|
2336
|
+
alias: "property"
|
|
2337
|
+
},
|
|
2338
|
+
constant: /\b[A-Z_][A-Z_\d]+\b/,
|
|
2339
|
+
"class-name": /\b[A-Z]\w*\b/,
|
|
2340
|
+
namespace: {
|
|
2341
|
+
pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
|
|
2342
|
+
inside: {
|
|
2343
|
+
punctuation: /::/
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
// Hex, oct, bin, dec numbers with visual separators and type suffix
|
|
2347
|
+
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/,
|
|
2348
|
+
boolean: /\b(?:false|true)\b/,
|
|
2349
|
+
punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
2350
|
+
operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
2351
|
+
}, f.languages.rust["closure-params"].inside.rest = f.languages.rust, f.languages.rust.attribute.inside.string = f.languages.rust.string;
|
|
2352
|
+
})(Prism);
|
|
2353
|
+
Prism.languages.sql = {
|
|
2354
|
+
comment: {
|
|
2355
|
+
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
|
2356
|
+
lookbehind: !0
|
|
2357
|
+
},
|
|
2358
|
+
variable: [
|
|
2359
|
+
{
|
|
2360
|
+
pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
|
|
2361
|
+
greedy: !0
|
|
2362
|
+
},
|
|
2363
|
+
/@[\w.$]+/
|
|
2364
|
+
],
|
|
2365
|
+
string: {
|
|
2366
|
+
pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
|
|
2367
|
+
greedy: !0,
|
|
2368
|
+
lookbehind: !0
|
|
2369
|
+
},
|
|
2370
|
+
identifier: {
|
|
2371
|
+
pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
|
|
2372
|
+
greedy: !0,
|
|
2373
|
+
lookbehind: !0,
|
|
2374
|
+
inside: {
|
|
2375
|
+
punctuation: /^`|`$/
|
|
2376
|
+
}
|
|
2377
|
+
},
|
|
2378
|
+
function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
2379
|
+
// Should we highlight user defined functions too?
|
|
2380
|
+
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,
|
|
2381
|
+
boolean: /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
2382
|
+
number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
2383
|
+
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
2384
|
+
punctuation: /[;[\]()`,.]/
|
|
2385
|
+
};
|
|
2386
|
+
(function(f) {
|
|
2387
|
+
var g = "\\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", n = {
|
|
2388
|
+
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
2389
|
+
lookbehind: !0,
|
|
2390
|
+
alias: "punctuation",
|
|
2391
|
+
// this looks reasonably well in all themes
|
|
2392
|
+
inside: null
|
|
2393
|
+
// see below
|
|
2394
|
+
}, c = {
|
|
2395
|
+
bash: n,
|
|
2396
|
+
environment: {
|
|
2397
|
+
pattern: RegExp("\\$" + g),
|
|
2398
|
+
alias: "constant"
|
|
2399
|
+
},
|
|
2400
|
+
variable: [
|
|
2401
|
+
// [0]: Arithmetic Environment
|
|
2402
|
+
{
|
|
2403
|
+
pattern: /\$?\(\([\s\S]+?\)\)/,
|
|
2404
|
+
greedy: !0,
|
|
2405
|
+
inside: {
|
|
2406
|
+
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
|
2407
|
+
variable: [
|
|
2408
|
+
{
|
|
2409
|
+
pattern: /(^\$\(\([\s\S]+)\)\)/,
|
|
2410
|
+
lookbehind: !0
|
|
2411
|
+
},
|
|
2412
|
+
/^\$\(\(/
|
|
2413
|
+
],
|
|
2414
|
+
number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
2415
|
+
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
|
2416
|
+
operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
2417
|
+
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
|
2418
|
+
punctuation: /\(\(?|\)\)?|,|;/
|
|
2419
|
+
}
|
|
2420
|
+
},
|
|
2421
|
+
// [1]: Command Substitution
|
|
2422
|
+
{
|
|
2423
|
+
pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
|
2424
|
+
greedy: !0,
|
|
2425
|
+
inside: {
|
|
2426
|
+
variable: /^\$\(|^`|\)$|`$/
|
|
2427
|
+
}
|
|
2428
|
+
},
|
|
2429
|
+
// [2]: Brace expansion
|
|
2430
|
+
{
|
|
2431
|
+
pattern: /\$\{[^}]+\}/,
|
|
2432
|
+
greedy: !0,
|
|
2433
|
+
inside: {
|
|
2434
|
+
operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
2435
|
+
punctuation: /[\[\]]/,
|
|
2436
|
+
environment: {
|
|
2437
|
+
pattern: RegExp("(\\{)" + g),
|
|
2438
|
+
lookbehind: !0,
|
|
2439
|
+
alias: "constant"
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
},
|
|
2443
|
+
/\$(?:\w+|[#?*!@$])/
|
|
2444
|
+
],
|
|
2445
|
+
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
2446
|
+
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})/
|
|
2447
|
+
};
|
|
2448
|
+
f.languages.bash = {
|
|
2449
|
+
shebang: {
|
|
2450
|
+
pattern: /^#!\s*\/.*/,
|
|
2451
|
+
alias: "important"
|
|
2452
|
+
},
|
|
2453
|
+
comment: {
|
|
2454
|
+
pattern: /(^|[^"{\\$])#.*/,
|
|
2455
|
+
lookbehind: !0
|
|
2456
|
+
},
|
|
2457
|
+
"function-name": [
|
|
2458
|
+
// a) function foo {
|
|
2459
|
+
// b) foo() {
|
|
2460
|
+
// c) function foo() {
|
|
2461
|
+
// but not “foo {”
|
|
2462
|
+
{
|
|
2463
|
+
// a) and c)
|
|
2464
|
+
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
|
2465
|
+
lookbehind: !0,
|
|
2466
|
+
alias: "function"
|
|
2467
|
+
},
|
|
2468
|
+
{
|
|
2469
|
+
// b)
|
|
2470
|
+
pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
|
|
2471
|
+
alias: "function"
|
|
2472
|
+
}
|
|
2473
|
+
],
|
|
2474
|
+
// Highlight variable names as variables in for and select beginnings.
|
|
2475
|
+
"for-or-select": {
|
|
2476
|
+
pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
|
2477
|
+
alias: "variable",
|
|
2478
|
+
lookbehind: !0
|
|
2479
|
+
},
|
|
2480
|
+
// Highlight variable names as variables in the left-hand part
|
|
2481
|
+
// of assignments (“=” and “+=”).
|
|
2482
|
+
"assign-left": {
|
|
2483
|
+
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
2484
|
+
inside: {
|
|
2485
|
+
environment: {
|
|
2486
|
+
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + g),
|
|
2487
|
+
lookbehind: !0,
|
|
2488
|
+
alias: "constant"
|
|
2489
|
+
}
|
|
2490
|
+
},
|
|
2491
|
+
alias: "variable",
|
|
2492
|
+
lookbehind: !0
|
|
2493
|
+
},
|
|
2494
|
+
// Highlight parameter names as variables
|
|
2495
|
+
parameter: {
|
|
2496
|
+
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
|
|
2497
|
+
alias: "variable",
|
|
2498
|
+
lookbehind: !0
|
|
2499
|
+
},
|
|
2500
|
+
string: [
|
|
2501
|
+
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
|
|
2502
|
+
{
|
|
2503
|
+
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
2504
|
+
lookbehind: !0,
|
|
2505
|
+
greedy: !0,
|
|
2506
|
+
inside: c
|
|
2507
|
+
},
|
|
2508
|
+
// Here-document with quotes around the tag
|
|
2509
|
+
// → No expansion (so no “inside”).
|
|
2510
|
+
{
|
|
2511
|
+
pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
|
2512
|
+
lookbehind: !0,
|
|
2513
|
+
greedy: !0,
|
|
2514
|
+
inside: {
|
|
2515
|
+
bash: n
|
|
2516
|
+
}
|
|
2517
|
+
},
|
|
2518
|
+
// “Normal” string
|
|
2519
|
+
{
|
|
2520
|
+
// https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
|
|
2521
|
+
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
2522
|
+
lookbehind: !0,
|
|
2523
|
+
greedy: !0,
|
|
2524
|
+
inside: c
|
|
2525
|
+
},
|
|
2526
|
+
{
|
|
2527
|
+
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
2528
|
+
pattern: /(^|[^$\\])'[^']*'/,
|
|
2529
|
+
lookbehind: !0,
|
|
2530
|
+
greedy: !0
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
// https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
|
|
2534
|
+
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
2535
|
+
greedy: !0,
|
|
2536
|
+
inside: {
|
|
2537
|
+
entity: c.entity
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
],
|
|
2541
|
+
environment: {
|
|
2542
|
+
pattern: RegExp("\\$?" + g),
|
|
2543
|
+
alias: "constant"
|
|
2544
|
+
},
|
|
2545
|
+
variable: c.variable,
|
|
2546
|
+
function: {
|
|
2547
|
+
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;|&])/,
|
|
2548
|
+
lookbehind: !0
|
|
2549
|
+
},
|
|
2550
|
+
keyword: {
|
|
2551
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
|
2552
|
+
lookbehind: !0
|
|
2553
|
+
},
|
|
2554
|
+
// https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
|
2555
|
+
builtin: {
|
|
2556
|
+
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;|&])/,
|
|
2557
|
+
lookbehind: !0,
|
|
2558
|
+
// Alias added to make those easier to distinguish from strings.
|
|
2559
|
+
alias: "class-name"
|
|
2560
|
+
},
|
|
2561
|
+
boolean: {
|
|
2562
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
|
|
2563
|
+
lookbehind: !0
|
|
2564
|
+
},
|
|
2565
|
+
"file-descriptor": {
|
|
2566
|
+
pattern: /\B&\d\b/,
|
|
2567
|
+
alias: "important"
|
|
2568
|
+
},
|
|
2569
|
+
operator: {
|
|
2570
|
+
// Lots of redirections here, but not just that.
|
|
2571
|
+
pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
|
2572
|
+
inside: {
|
|
2573
|
+
"file-descriptor": {
|
|
2574
|
+
pattern: /^\d/,
|
|
2575
|
+
alias: "important"
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
},
|
|
2579
|
+
punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
2580
|
+
number: {
|
|
2581
|
+
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
2582
|
+
lookbehind: !0
|
|
2583
|
+
}
|
|
2584
|
+
}, n.inside = f.languages.bash;
|
|
2585
|
+
for (var h = [
|
|
2586
|
+
"comment",
|
|
2587
|
+
"function-name",
|
|
2588
|
+
"for-or-select",
|
|
2589
|
+
"assign-left",
|
|
2590
|
+
"parameter",
|
|
2591
|
+
"string",
|
|
2592
|
+
"environment",
|
|
2593
|
+
"function",
|
|
2594
|
+
"keyword",
|
|
2595
|
+
"builtin",
|
|
2596
|
+
"boolean",
|
|
2597
|
+
"file-descriptor",
|
|
2598
|
+
"operator",
|
|
2599
|
+
"punctuation",
|
|
2600
|
+
"number"
|
|
2601
|
+
], _ = c.variable[1].inside, x = 0; x < h.length; x++)
|
|
2602
|
+
_[h[x]] = f.languages.bash[h[x]];
|
|
2603
|
+
f.languages.sh = f.languages.bash, f.languages.shell = f.languages.bash;
|
|
2604
|
+
})(Prism);
|
|
2605
|
+
Prism.languages.json = {
|
|
2606
|
+
property: {
|
|
2607
|
+
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
2608
|
+
lookbehind: !0,
|
|
2609
|
+
greedy: !0
|
|
2610
|
+
},
|
|
2611
|
+
string: {
|
|
2612
|
+
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
|
2613
|
+
lookbehind: !0,
|
|
2614
|
+
greedy: !0
|
|
2615
|
+
},
|
|
2616
|
+
comment: {
|
|
2617
|
+
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2618
|
+
greedy: !0
|
|
2619
|
+
},
|
|
2620
|
+
number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
2621
|
+
punctuation: /[{}[\],]/,
|
|
2622
|
+
operator: /:/,
|
|
2623
|
+
boolean: /\b(?:false|true)\b/,
|
|
2624
|
+
null: {
|
|
2625
|
+
pattern: /\bnull\b/,
|
|
2626
|
+
alias: "keyword"
|
|
2627
|
+
}
|
|
2628
|
+
};
|
|
2629
|
+
Prism.languages.webmanifest = Prism.languages.json;
|
|
2630
|
+
function xt(f) {
|
|
2631
|
+
if (typeof document > "u") return;
|
|
2632
|
+
const g = f === "dark" ? "prism-okaidia" : "prism", n = document.getElementById("prism-theme-style"), c = `https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/${g}.min.css`;
|
|
2633
|
+
if (n)
|
|
2634
|
+
n.setAttribute("href", c);
|
|
2635
|
+
else {
|
|
2636
|
+
const h = document.createElement("link");
|
|
2637
|
+
h.id = "prism-theme-style", h.rel = "stylesheet", h.href = c, document.head.appendChild(h);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
window.Prism = Ne;
|
|
2641
|
+
const Rt = {
|
|
2642
|
+
javascript: "javascript",
|
|
2643
|
+
js: "javascript",
|
|
2644
|
+
typescript: "typescript",
|
|
2645
|
+
ts: "typescript",
|
|
2646
|
+
python: "python",
|
|
2647
|
+
py: "python",
|
|
2648
|
+
java: "java",
|
|
2649
|
+
c: "c",
|
|
2650
|
+
cpp: "cpp",
|
|
2651
|
+
"c++": "cpp",
|
|
2652
|
+
csharp: "csharp",
|
|
2653
|
+
"c#": "csharp",
|
|
2654
|
+
go: "go",
|
|
2655
|
+
golang: "go",
|
|
2656
|
+
rust: "rust",
|
|
2657
|
+
ruby: "ruby",
|
|
2658
|
+
rb: "ruby",
|
|
2659
|
+
php: "php",
|
|
2660
|
+
swift: "swift",
|
|
2661
|
+
kotlin: "kotlin",
|
|
2662
|
+
kt: "kotlin",
|
|
2663
|
+
sql: "sql",
|
|
2664
|
+
bash: "bash",
|
|
2665
|
+
sh: "bash",
|
|
2666
|
+
shell: "bash",
|
|
2667
|
+
json: "json",
|
|
2668
|
+
yaml: "yaml",
|
|
2669
|
+
yml: "yaml",
|
|
2670
|
+
markdown: "markdown",
|
|
2671
|
+
md: "markdown"
|
|
2672
|
+
};
|
|
2673
|
+
function kt(f) {
|
|
2674
|
+
const g = document.createElement("div");
|
|
2675
|
+
return g.textContent = f, g.innerHTML;
|
|
2676
|
+
}
|
|
2677
|
+
const _t = ({
|
|
2678
|
+
value: f,
|
|
2679
|
+
language: g,
|
|
2680
|
+
theme: n = "dark",
|
|
2681
|
+
disabled: c = !1,
|
|
2682
|
+
onChange: h
|
|
2683
|
+
}) => {
|
|
2684
|
+
const _ = Fe(null), x = Fe(null), l = ve(() => Rt[g.toLowerCase()] || "javascript", [g]), m = n === "dark" ? "#1e1e1e" : "#fafafa", S = ve(() => {
|
|
2685
|
+
try {
|
|
2686
|
+
const C = Ne.languages[l];
|
|
2687
|
+
if (C)
|
|
2688
|
+
return Ne.highlight(f || "", C, l);
|
|
2689
|
+
} catch {
|
|
2690
|
+
}
|
|
2691
|
+
return kt(f || "");
|
|
2692
|
+
}, [f, l]), F = (C) => {
|
|
2693
|
+
h == null || h(C.target.value);
|
|
2694
|
+
}, L = () => {
|
|
2695
|
+
_.current && x.current && (x.current.scrollTop = _.current.scrollTop, x.current.scrollLeft = _.current.scrollLeft);
|
|
2696
|
+
};
|
|
2697
|
+
Oe(() => {
|
|
2698
|
+
xt(n);
|
|
2699
|
+
}, [n]);
|
|
2700
|
+
const j = (C) => {
|
|
2701
|
+
if (C.key === "Tab") {
|
|
2702
|
+
C.preventDefault();
|
|
2703
|
+
const Y = C.target, O = Y.selectionStart, R = Y.selectionEnd, T = f.substring(0, O) + " " + f.substring(R);
|
|
2704
|
+
h == null || h(T), requestAnimationFrame(() => {
|
|
2705
|
+
Y.selectionStart = Y.selectionEnd = O + 2;
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
};
|
|
2709
|
+
return /* @__PURE__ */ E.jsxs("div", { className: `code-editor theme-${n}`, style: { background: m }, children: [
|
|
2710
|
+
/* @__PURE__ */ E.jsx(
|
|
2711
|
+
"pre",
|
|
2712
|
+
{
|
|
2713
|
+
ref: x,
|
|
2714
|
+
className: `code-highlight language-${l}`,
|
|
2715
|
+
"aria-hidden": "true",
|
|
2716
|
+
children: /* @__PURE__ */ E.jsx("code", { dangerouslySetInnerHTML: { __html: S } })
|
|
2717
|
+
}
|
|
2718
|
+
),
|
|
2719
|
+
/* @__PURE__ */ E.jsx(
|
|
2720
|
+
"textarea",
|
|
2721
|
+
{
|
|
2722
|
+
ref: _,
|
|
2723
|
+
className: "code-input",
|
|
2724
|
+
value: f,
|
|
2725
|
+
disabled: c,
|
|
2726
|
+
onChange: F,
|
|
2727
|
+
onScroll: L,
|
|
2728
|
+
onKeyDown: j,
|
|
2729
|
+
spellCheck: !1,
|
|
2730
|
+
placeholder: "Write your code here..."
|
|
2731
|
+
}
|
|
2732
|
+
)
|
|
2733
|
+
] });
|
|
2734
|
+
};
|
|
2735
|
+
var Ft = Object.defineProperty, Ot = (f, g, n) => g in f ? Ft(f, g, { enumerable: !0, configurable: !0, writable: !0, value: n }) : f[g] = n, Ze = (f, g, n) => Ot(f, typeof g != "symbol" ? g + "" : g, n);
|
|
2736
|
+
let ke = null;
|
|
2737
|
+
class It {
|
|
2738
|
+
constructor(g = {}) {
|
|
2739
|
+
Ze(this, "baseUrl"), Ze(this, "timeout"), this.baseUrl = g.pistonUrl || "/api/piston", this.timeout = g.timeout || 3e3;
|
|
2740
|
+
}
|
|
2741
|
+
async getRuntimes(g = !1) {
|
|
2742
|
+
if (ke && !g)
|
|
2743
|
+
return ke;
|
|
2744
|
+
try {
|
|
2745
|
+
const n = await fetch(`${this.baseUrl}/runtimes`, {
|
|
2746
|
+
method: "GET",
|
|
2747
|
+
headers: {
|
|
2748
|
+
"Content-Type": "application/json"
|
|
2749
|
+
}
|
|
2750
|
+
});
|
|
2751
|
+
if (!n.ok)
|
|
2752
|
+
throw new Error(`Failed to fetch runtimes: ${n.statusText}`);
|
|
2753
|
+
const c = await n.json();
|
|
2754
|
+
return ke = c, c;
|
|
2755
|
+
} catch (n) {
|
|
2756
|
+
throw console.error("Failed to fetch runtimes:", n), n;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
async execute(g, n, c = {}) {
|
|
2760
|
+
const h = (await this.getRuntimes()).find(
|
|
2761
|
+
(m) => {
|
|
2762
|
+
var S;
|
|
2763
|
+
return m.language.toLowerCase() === g.toLowerCase() || ((S = m.aliases) == null ? void 0 : S.some((F) => F.toLowerCase() === g.toLowerCase()));
|
|
2764
|
+
}
|
|
2765
|
+
);
|
|
2766
|
+
if (!h)
|
|
2767
|
+
throw new Error(`Language '${g}' is not supported`);
|
|
2768
|
+
const _ = this.getFileName(g), x = {
|
|
2769
|
+
language: h.language,
|
|
2770
|
+
version: c.version || h.version,
|
|
2771
|
+
files: [
|
|
2772
|
+
{
|
|
2773
|
+
name: _,
|
|
2774
|
+
content: n
|
|
2775
|
+
}
|
|
2776
|
+
],
|
|
2777
|
+
stdin: c.stdin || "",
|
|
2778
|
+
args: c.args || [],
|
|
2779
|
+
run_timeout: c.runTimeout || this.timeout,
|
|
2780
|
+
compile_timeout: this.timeout
|
|
2781
|
+
}, l = Date.now();
|
|
2782
|
+
try {
|
|
2783
|
+
const m = await fetch(`${this.baseUrl}/execute`, {
|
|
2784
|
+
method: "POST",
|
|
2785
|
+
headers: {
|
|
2786
|
+
"Content-Type": "application/json"
|
|
2787
|
+
},
|
|
2788
|
+
body: JSON.stringify(x)
|
|
2789
|
+
});
|
|
2790
|
+
if (!m.ok)
|
|
2791
|
+
throw new Error(`Execute failed: ${m.statusText}`);
|
|
2792
|
+
const S = await m.json(), F = Date.now() - l, L = S.run.stdout || "", j = S.run.stderr || "";
|
|
2793
|
+
return {
|
|
2794
|
+
success: S.run.code === 0,
|
|
2795
|
+
output: L,
|
|
2796
|
+
stderr: j,
|
|
2797
|
+
code: S.run.code,
|
|
2798
|
+
executionTime: F,
|
|
2799
|
+
compile: S.compile ? {
|
|
2800
|
+
stdout: S.compile.stdout || "",
|
|
2801
|
+
stderr: S.compile.stderr || "",
|
|
2802
|
+
code: S.compile.code
|
|
2803
|
+
} : void 0
|
|
2804
|
+
};
|
|
2805
|
+
} catch (m) {
|
|
2806
|
+
return {
|
|
2807
|
+
success: !1,
|
|
2808
|
+
output: "",
|
|
2809
|
+
stderr: m instanceof Error ? m.message : "Unknown error",
|
|
2810
|
+
code: -1,
|
|
2811
|
+
executionTime: Date.now() - l
|
|
2812
|
+
};
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
getFileName(g) {
|
|
2816
|
+
return {
|
|
2817
|
+
javascript: "main.js",
|
|
2818
|
+
typescript: "main.ts",
|
|
2819
|
+
python: "main.py",
|
|
2820
|
+
python3: "main.py",
|
|
2821
|
+
go: "main.go",
|
|
2822
|
+
rust: "main.rs",
|
|
2823
|
+
java: "Main.java",
|
|
2824
|
+
c: "main.c",
|
|
2825
|
+
cpp: "main.cpp",
|
|
2826
|
+
csharp: "Main.cs",
|
|
2827
|
+
ruby: "main.rb",
|
|
2828
|
+
php: "main.php",
|
|
2829
|
+
bash: "main.sh",
|
|
2830
|
+
shell: "main.sh",
|
|
2831
|
+
perl: "main.pl",
|
|
2832
|
+
lua: "main.lua",
|
|
2833
|
+
swift: "main.swift",
|
|
2834
|
+
kotlin: "Main.kt",
|
|
2835
|
+
scala: "Main.scala",
|
|
2836
|
+
haskell: "main.hs",
|
|
2837
|
+
dart: "main.dart",
|
|
2838
|
+
html: "index.html",
|
|
2839
|
+
css: "style.css",
|
|
2840
|
+
sql: "query.sql",
|
|
2841
|
+
markdown: "readme.md"
|
|
2842
|
+
}[g.toLowerCase()] || `main.${g}`;
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
const Nt = {
|
|
2846
|
+
javascript: 'console.log("Hello, World!");',
|
|
2847
|
+
typescript: 'console.log("Hello, World!");',
|
|
2848
|
+
python: 'print("Hello, World!")',
|
|
2849
|
+
python3: 'print("Hello, World!")',
|
|
2850
|
+
go: `package main
|
|
2851
|
+
|
|
2852
|
+
import "fmt"
|
|
2853
|
+
|
|
2854
|
+
func main() {
|
|
2855
|
+
fmt.Println("Hello, World!")
|
|
2856
|
+
}`,
|
|
2857
|
+
rust: `fn main() {
|
|
2858
|
+
println!("Hello, World!");
|
|
2859
|
+
}`,
|
|
2860
|
+
java: `public class Main {
|
|
2861
|
+
public static void main(String[] args) {
|
|
2862
|
+
System.out.println("Hello, World!");
|
|
2863
|
+
}
|
|
2864
|
+
}`,
|
|
2865
|
+
c: `#include <stdio.h>
|
|
2866
|
+
|
|
2867
|
+
int main() {
|
|
2868
|
+
printf("Hello, World!\\n");
|
|
2869
|
+
return 0;
|
|
2870
|
+
}`,
|
|
2871
|
+
cpp: `#include <iostream>
|
|
2872
|
+
|
|
2873
|
+
int main() {
|
|
2874
|
+
std::cout << "Hello, World!" << std::endl;
|
|
2875
|
+
return 0;
|
|
2876
|
+
}`,
|
|
2877
|
+
csharp: `using System;
|
|
2878
|
+
|
|
2879
|
+
class Main {
|
|
2880
|
+
static void Main() {
|
|
2881
|
+
Console.WriteLine("Hello, World!");
|
|
2882
|
+
}
|
|
2883
|
+
}`,
|
|
2884
|
+
ruby: 'puts "Hello, World!"',
|
|
2885
|
+
php: `<?php
|
|
2886
|
+
echo "Hello, World!";
|
|
2887
|
+
?>`,
|
|
2888
|
+
bash: 'echo "Hello, World!"',
|
|
2889
|
+
shell: 'echo "Hello, World!"',
|
|
2890
|
+
perl: 'print "Hello, World!\\n";',
|
|
2891
|
+
lua: 'print("Hello, World!")',
|
|
2892
|
+
r: 'print("Hello, World!")',
|
|
2893
|
+
swift: 'print("Hello, World!")',
|
|
2894
|
+
kotlin: `fun main() {
|
|
2895
|
+
println("Hello, World!")
|
|
2896
|
+
}`,
|
|
2897
|
+
scala: `object Main extends App {
|
|
2898
|
+
println("Hello, World!")
|
|
2899
|
+
}`,
|
|
2900
|
+
haskell: 'main = putStrLn "Hello, World!"',
|
|
2901
|
+
elixir: 'IO.puts "Hello, World!"',
|
|
2902
|
+
erlang: 'main() -> io:fwrite("Hello, World!~n").',
|
|
2903
|
+
clojure: '(println "Hello, World!")',
|
|
2904
|
+
fsharp: 'printfn "Hello, World!"',
|
|
2905
|
+
dart: `void main() {
|
|
2906
|
+
print("Hello, World!");
|
|
2907
|
+
}`,
|
|
2908
|
+
assembly: `section .data
|
|
2909
|
+
msg db 'Hello, World!', 0
|
|
2910
|
+
section .text
|
|
2911
|
+
global _start
|
|
2912
|
+
_start:
|
|
2913
|
+
mov rax, 1
|
|
2914
|
+
mov rdi, 1
|
|
2915
|
+
mov rsi, msg
|
|
2916
|
+
mov rdx, 13
|
|
2917
|
+
syscall
|
|
2918
|
+
mov rax, 60
|
|
2919
|
+
xor rdi, rdi
|
|
2920
|
+
syscall`,
|
|
2921
|
+
html: `<!DOCTYPE html>
|
|
2922
|
+
<html>
|
|
2923
|
+
<head>
|
|
2924
|
+
<title>Hello</title>
|
|
2925
|
+
</head>
|
|
2926
|
+
<body>
|
|
2927
|
+
<h1>Hello, World!</h1>
|
|
2928
|
+
</body>
|
|
2929
|
+
</html>`,
|
|
2930
|
+
css: `body {
|
|
2931
|
+
background-color: #f0f0f0;
|
|
2932
|
+
font-family: Arial, sans-serif;
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
h1 {
|
|
2936
|
+
color: #333;
|
|
2937
|
+
}`,
|
|
2938
|
+
sql: "SELECT 'Hello, World!' AS message;",
|
|
2939
|
+
markdown: `# Hello, World!
|
|
2940
|
+
|
|
2941
|
+
This is a sample markdown document.`
|
|
2942
|
+
};
|
|
2943
|
+
function _e(f) {
|
|
2944
|
+
const g = f.toLowerCase();
|
|
2945
|
+
return Nt[g] || `// ${f}
|
|
2946
|
+
// Write your code here`;
|
|
2947
|
+
}
|
|
2948
|
+
const Lt = ({
|
|
2949
|
+
pistonUrl: f = "/api/piston",
|
|
2950
|
+
language: g = "javascript",
|
|
2951
|
+
theme: n = "light",
|
|
2952
|
+
showLanguageSelector: c = !0,
|
|
2953
|
+
showEditor: h = !0,
|
|
2954
|
+
editable: _ = !0,
|
|
2955
|
+
defaultCode: x = "",
|
|
2956
|
+
executorLabel: l = "运行",
|
|
2957
|
+
onExecuteStart: m,
|
|
2958
|
+
onExecuteEnd: S,
|
|
2959
|
+
onLanguageChange: F
|
|
2960
|
+
}) => {
|
|
2961
|
+
const [L, j] = Q([]), [C, Y] = Q(g), [O, R] = Q(n), [T, t] = Q(x), [r, i] = Q(""), [s, o] = Q(""), [d, v] = Q(!1), [p, I] = Q(null), [P, B] = Q("stdout"), [V, z] = Q(null), [ne, ce] = Q(!0), [le, D] = Q(60), H = ve(() => new It({ pistonUrl: f }), [f]), ee = ve(() => L.map((A) => ({
|
|
2962
|
+
value: `${A.language}:${A.version}`,
|
|
2963
|
+
label: `${A.language.charAt(0).toUpperCase() + A.language.slice(1)} ${A.version}`
|
|
2964
|
+
})), [L]), X = ve(() => C.includes(":") ? C.split(":")[0] : C, [C]);
|
|
2965
|
+
Oe(() => {
|
|
2966
|
+
async function A() {
|
|
2967
|
+
ce(!0), z(null);
|
|
2968
|
+
try {
|
|
2969
|
+
const M = await H.getRuntimes();
|
|
2970
|
+
j(M);
|
|
2971
|
+
} catch (M) {
|
|
2972
|
+
z(M instanceof Error ? M.message : "Failed to load runtimes");
|
|
2973
|
+
} finally {
|
|
2974
|
+
ce(!1);
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
A();
|
|
2978
|
+
}, [H]), Oe(() => {
|
|
2979
|
+
!T && L.length > 0 && t(x || _e(X));
|
|
2980
|
+
}, [L, T, x, X]);
|
|
2981
|
+
const G = ue(
|
|
2982
|
+
(A) => {
|
|
2983
|
+
const M = A.target.value, re = M.includes(":") ? M.split(":")[0] : M;
|
|
2984
|
+
Y(M);
|
|
2985
|
+
const fe = _e(re);
|
|
2986
|
+
t(fe), F == null || F(re, fe);
|
|
2987
|
+
},
|
|
2988
|
+
[F]
|
|
2989
|
+
), pe = ue(async () => {
|
|
2990
|
+
if (!d) {
|
|
2991
|
+
v(!0), i(""), o(""), I(null), z(null), B("stdout"), m == null || m();
|
|
2992
|
+
try {
|
|
2993
|
+
const A = await H.execute(X, T);
|
|
2994
|
+
i(A.output), o(A.stderr), I(A.executionTime || null), B(A.stderr ? "stderr" : "stdout"), S == null || S(A);
|
|
2995
|
+
} catch (A) {
|
|
2996
|
+
const M = A instanceof Error ? A.message : "Execution failed";
|
|
2997
|
+
z(M), S == null || S({
|
|
2998
|
+
success: !1,
|
|
2999
|
+
output: "",
|
|
3000
|
+
stderr: M,
|
|
3001
|
+
code: -1
|
|
3002
|
+
});
|
|
3003
|
+
} finally {
|
|
3004
|
+
v(!1);
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
}, [d, C, T, H, m, S]), Z = ue(() => {
|
|
3008
|
+
i(""), o(""), I(null), z(null);
|
|
3009
|
+
}, []), oe = ue(async () => {
|
|
3010
|
+
const A = P === "stdout" ? r : s;
|
|
3011
|
+
await navigator.clipboard.writeText(A);
|
|
3012
|
+
}, [P, r, s]), ae = ue(() => {
|
|
3013
|
+
t(_e(X));
|
|
3014
|
+
}, [C]), q = Fe(!1), ie = ue((A) => {
|
|
3015
|
+
q.current = !0, document.addEventListener("mousemove", se), document.addEventListener("mouseup", te), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
3016
|
+
}, []), se = ue((A) => {
|
|
3017
|
+
if (!q.current) return;
|
|
3018
|
+
const M = document.querySelector(".code-runner-main");
|
|
3019
|
+
if (!M) return;
|
|
3020
|
+
const re = M.getBoundingClientRect(), fe = (A.clientX - re.left) / re.width * 100;
|
|
3021
|
+
D(Math.max(20, Math.min(80, fe)));
|
|
3022
|
+
}, []), te = ue(() => {
|
|
3023
|
+
q.current = !1, document.removeEventListener("mousemove", se), document.removeEventListener("mouseup", te), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
3024
|
+
}, [se]);
|
|
3025
|
+
return /* @__PURE__ */ E.jsxs("div", { className: `code-runner code-runner-${O}`, children: [
|
|
3026
|
+
/* @__PURE__ */ E.jsxs("div", { className: "code-runner-header", children: [
|
|
3027
|
+
/* @__PURE__ */ E.jsx("div", { className: "code-runner-controls", children: c && /* @__PURE__ */ E.jsxs(
|
|
3028
|
+
"select",
|
|
3029
|
+
{
|
|
3030
|
+
value: C,
|
|
3031
|
+
onChange: G,
|
|
3032
|
+
className: "language-select",
|
|
3033
|
+
disabled: d,
|
|
3034
|
+
children: [
|
|
3035
|
+
ne && /* @__PURE__ */ E.jsx("option", { value: "", children: "加载中..." }),
|
|
3036
|
+
ee.map((A) => /* @__PURE__ */ E.jsx("option", { value: A.value, children: A.label }, A.value))
|
|
3037
|
+
]
|
|
3038
|
+
}
|
|
3039
|
+
) }),
|
|
3040
|
+
/* @__PURE__ */ E.jsxs("div", { className: "code-runner-actions", children: [
|
|
3041
|
+
/* @__PURE__ */ E.jsxs(
|
|
3042
|
+
"button",
|
|
3043
|
+
{
|
|
3044
|
+
className: "btn btn-run",
|
|
3045
|
+
disabled: d || ne,
|
|
3046
|
+
onClick: pe,
|
|
3047
|
+
children: [
|
|
3048
|
+
d ? /* @__PURE__ */ E.jsx("span", { className: "spinner" }) : /* @__PURE__ */ E.jsx("span", { className: "run-icon", children: "▶" }),
|
|
3049
|
+
d ? "运行中..." : l
|
|
3050
|
+
]
|
|
3051
|
+
}
|
|
3052
|
+
),
|
|
3053
|
+
h && _ && /* @__PURE__ */ E.jsx("button", { className: "btn btn-reset", onClick: ae, children: "重置" }),
|
|
3054
|
+
/* @__PURE__ */ E.jsx(
|
|
3055
|
+
"button",
|
|
3056
|
+
{
|
|
3057
|
+
className: "btn btn-theme",
|
|
3058
|
+
onClick: () => R(O === "light" ? "dark" : "light"),
|
|
3059
|
+
title: O === "light" ? "Switch to dark mode" : "Switch to light mode",
|
|
3060
|
+
children: O === "light" ? "🌙" : "☀️"
|
|
3061
|
+
}
|
|
3062
|
+
)
|
|
3063
|
+
] })
|
|
3064
|
+
] }),
|
|
3065
|
+
V && /* @__PURE__ */ E.jsx("div", { className: "error-message", children: V }),
|
|
3066
|
+
/* @__PURE__ */ E.jsxs("div", { className: "code-runner-main", children: [
|
|
3067
|
+
h && /* @__PURE__ */ E.jsxs("div", { className: "editor-panel", style: { width: `${le}%` }, children: [
|
|
3068
|
+
/* @__PURE__ */ E.jsxs("div", { className: "panel-header", children: [
|
|
3069
|
+
/* @__PURE__ */ E.jsx("span", { className: "panel-title", children: "编辑器" }),
|
|
3070
|
+
/* @__PURE__ */ E.jsx("span", { className: "language-badge", children: X })
|
|
3071
|
+
] }),
|
|
3072
|
+
/* @__PURE__ */ E.jsx(
|
|
3073
|
+
_t,
|
|
3074
|
+
{
|
|
3075
|
+
value: T,
|
|
3076
|
+
language: X,
|
|
3077
|
+
theme: O,
|
|
3078
|
+
disabled: !_ || d,
|
|
3079
|
+
onChange: t
|
|
3080
|
+
}
|
|
3081
|
+
)
|
|
3082
|
+
] }),
|
|
3083
|
+
h && /* @__PURE__ */ E.jsx("div", { className: "resize-handle", onMouseDown: ie, children: /* @__PURE__ */ E.jsx("div", { className: "resize-line" }) }),
|
|
3084
|
+
/* @__PURE__ */ E.jsxs(
|
|
3085
|
+
"div",
|
|
3086
|
+
{
|
|
3087
|
+
className: "output-panel",
|
|
3088
|
+
style: { width: h ? `${100 - le}%` : "100%" },
|
|
3089
|
+
children: [
|
|
3090
|
+
/* @__PURE__ */ E.jsxs("div", { className: "panel-header", children: [
|
|
3091
|
+
/* @__PURE__ */ E.jsxs("div", { className: "output-tabs", children: [
|
|
3092
|
+
/* @__PURE__ */ E.jsx(
|
|
3093
|
+
"button",
|
|
3094
|
+
{
|
|
3095
|
+
className: `tab ${P === "stdout" ? "active" : ""}`,
|
|
3096
|
+
onClick: () => B("stdout"),
|
|
3097
|
+
children: "输出"
|
|
3098
|
+
}
|
|
3099
|
+
),
|
|
3100
|
+
s && /* @__PURE__ */ E.jsx(
|
|
3101
|
+
"button",
|
|
3102
|
+
{
|
|
3103
|
+
className: `tab ${P === "stderr" ? "active" : ""}`,
|
|
3104
|
+
onClick: () => B("stderr"),
|
|
3105
|
+
children: "错误"
|
|
3106
|
+
}
|
|
3107
|
+
)
|
|
3108
|
+
] }),
|
|
3109
|
+
/* @__PURE__ */ E.jsxs("div", { className: "output-actions", children: [
|
|
3110
|
+
p !== null && /* @__PURE__ */ E.jsxs("span", { className: "execution-time", children: [
|
|
3111
|
+
p,
|
|
3112
|
+
"ms"
|
|
3113
|
+
] }),
|
|
3114
|
+
/* @__PURE__ */ E.jsx("button", { className: "btn-icon", onClick: oe, title: "复制", children: /* @__PURE__ */ E.jsxs(
|
|
3115
|
+
"svg",
|
|
3116
|
+
{
|
|
3117
|
+
width: "14",
|
|
3118
|
+
height: "14",
|
|
3119
|
+
viewBox: "0 0 24 24",
|
|
3120
|
+
fill: "none",
|
|
3121
|
+
stroke: "currentColor",
|
|
3122
|
+
strokeWidth: "2",
|
|
3123
|
+
children: [
|
|
3124
|
+
/* @__PURE__ */ E.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
3125
|
+
/* @__PURE__ */ E.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
3126
|
+
]
|
|
3127
|
+
}
|
|
3128
|
+
) }),
|
|
3129
|
+
/* @__PURE__ */ E.jsx("button", { className: "btn-icon", onClick: Z, title: "清除", children: /* @__PURE__ */ E.jsxs(
|
|
3130
|
+
"svg",
|
|
3131
|
+
{
|
|
3132
|
+
width: "14",
|
|
3133
|
+
height: "14",
|
|
3134
|
+
viewBox: "0 0 24 24",
|
|
3135
|
+
fill: "none",
|
|
3136
|
+
stroke: "currentColor",
|
|
3137
|
+
strokeWidth: "2",
|
|
3138
|
+
children: [
|
|
3139
|
+
/* @__PURE__ */ E.jsx("polyline", { points: "3 6 5 6 21 6" }),
|
|
3140
|
+
/* @__PURE__ */ E.jsx("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
3141
|
+
]
|
|
3142
|
+
}
|
|
3143
|
+
) })
|
|
3144
|
+
] })
|
|
3145
|
+
] }),
|
|
3146
|
+
/* @__PURE__ */ E.jsx("div", { className: "output-content", children: /* @__PURE__ */ E.jsx("pre", { children: P === "stdout" ? r || '点击"运行"执行代码' : s }) })
|
|
3147
|
+
]
|
|
3148
|
+
}
|
|
3149
|
+
)
|
|
3150
|
+
] }),
|
|
3151
|
+
/* @__PURE__ */ E.jsx("style", { children: `
|
|
3152
|
+
.code-runner {
|
|
3153
|
+
display: flex;
|
|
3154
|
+
flex-direction: column;
|
|
3155
|
+
border: 1px solid #e0e0e0;
|
|
3156
|
+
border-radius: 12px;
|
|
3157
|
+
overflow: hidden;
|
|
3158
|
+
font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
3159
|
+
}
|
|
3160
|
+
.code-runner-dark { background: #1e1e1e; border-color: #333; }
|
|
3161
|
+
.code-runner-light { background: #ffffff; }
|
|
3162
|
+
.code-runner-header {
|
|
3163
|
+
display: flex;
|
|
3164
|
+
justify-content: space-between;
|
|
3165
|
+
align-items: center;
|
|
3166
|
+
padding: 12px 16px;
|
|
3167
|
+
background: #252526;
|
|
3168
|
+
border-bottom: 1px solid #333;
|
|
3169
|
+
}
|
|
3170
|
+
.code-runner-light .code-runner-header { background: #f3f3f3; border-color: #e0e0e0; }
|
|
3171
|
+
.code-runner-controls { display: flex; gap: 8px; }
|
|
3172
|
+
.language-select {
|
|
3173
|
+
padding: 6px 12px;
|
|
3174
|
+
border: 1px solid #444;
|
|
3175
|
+
border-radius: 6px;
|
|
3176
|
+
background: #2d2d2d;
|
|
3177
|
+
color: #d4d4d4;
|
|
3178
|
+
font-size: 13px;
|
|
3179
|
+
cursor: pointer;
|
|
3180
|
+
outline: none;
|
|
3181
|
+
}
|
|
3182
|
+
.code-runner-light .language-select { background: white; color: #333; border-color: #ccc; }
|
|
3183
|
+
.language-select:focus { border-color: #4fc3f7; }
|
|
3184
|
+
.code-runner-actions { display: flex; gap: 8px; }
|
|
3185
|
+
.btn {
|
|
3186
|
+
padding: 6px 16px;
|
|
3187
|
+
border: none;
|
|
3188
|
+
border-radius: 6px;
|
|
3189
|
+
font-size: 13px;
|
|
3190
|
+
font-weight: 500;
|
|
3191
|
+
cursor: pointer;
|
|
3192
|
+
display: flex;
|
|
3193
|
+
align-items: center;
|
|
3194
|
+
gap: 6px;
|
|
3195
|
+
transition: all 0.2s;
|
|
3196
|
+
}
|
|
3197
|
+
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
3198
|
+
.btn-run {
|
|
3199
|
+
background: linear-gradient(135deg, #4caf50 0%, #43a047 100%);
|
|
3200
|
+
color: white;
|
|
3201
|
+
}
|
|
3202
|
+
.btn-run:hover:not(:disabled) { background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%); }
|
|
3203
|
+
.btn-reset { background: #3d3d3d; color: #aaa; }
|
|
3204
|
+
.code-runner-light .btn-reset { background: #e0e0e0; color: #666; }
|
|
3205
|
+
.btn-theme { background: #3d3d3d; color: #aaa; padding: 5px 10px; font-size: 14px; line-height: 1; height: auto; min-height: 28px; }
|
|
3206
|
+
.code-runner-light .btn-theme { background: #e0e0e0; }
|
|
3207
|
+
.btn-theme:hover { background: #4d4d4d; color: #fff; }
|
|
3208
|
+
.error-message {
|
|
3209
|
+
padding: 10px 16px;
|
|
3210
|
+
background: #c62828;
|
|
3211
|
+
color: white;
|
|
3212
|
+
font-size: 13px;
|
|
3213
|
+
}
|
|
3214
|
+
.code-runner-main { display: flex; height: 400px; overflow: hidden; }
|
|
3215
|
+
.editor-panel {
|
|
3216
|
+
display: flex;
|
|
3217
|
+
flex-direction: column;
|
|
3218
|
+
min-width: 20%;
|
|
3219
|
+
max-width: 80%;
|
|
3220
|
+
}
|
|
3221
|
+
.panel-header {
|
|
3222
|
+
display: flex;
|
|
3223
|
+
justify-content: space-between;
|
|
3224
|
+
align-items: center;
|
|
3225
|
+
padding: 8px 12px;
|
|
3226
|
+
background: #2d2d2d;
|
|
3227
|
+
border-bottom: 1px solid #333;
|
|
3228
|
+
}
|
|
3229
|
+
.code-runner-light .panel-header { background: #f0f0f0; border-color: #e0e0e0; }
|
|
3230
|
+
.panel-title {
|
|
3231
|
+
font-size: 12px;
|
|
3232
|
+
font-weight: 600;
|
|
3233
|
+
color: #888;
|
|
3234
|
+
text-transform: uppercase;
|
|
3235
|
+
letter-spacing: 0.5px;
|
|
3236
|
+
}
|
|
3237
|
+
.language-badge {
|
|
3238
|
+
font-size: 11px;
|
|
3239
|
+
padding: 2px 8px;
|
|
3240
|
+
background: #4fc3f7;
|
|
3241
|
+
color: #000;
|
|
3242
|
+
border-radius: 10px;
|
|
3243
|
+
font-weight: 500;
|
|
3244
|
+
}
|
|
3245
|
+
.code-editor {
|
|
3246
|
+
flex: 1;
|
|
3247
|
+
width: 100%;
|
|
3248
|
+
background: #1e1e1e;
|
|
3249
|
+
position: relative;
|
|
3250
|
+
overflow: hidden;
|
|
3251
|
+
}
|
|
3252
|
+
.code-editor .code-highlight,
|
|
3253
|
+
.code-editor .code-input {
|
|
3254
|
+
position: absolute;
|
|
3255
|
+
top: 0;
|
|
3256
|
+
left: 0;
|
|
3257
|
+
width: 100%;
|
|
3258
|
+
height: 100%;
|
|
3259
|
+
padding: 12px 16px;
|
|
3260
|
+
margin: 0;
|
|
3261
|
+
border: none;
|
|
3262
|
+
font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
3263
|
+
font-size: 14px;
|
|
3264
|
+
line-height: 1.6;
|
|
3265
|
+
white-space: pre;
|
|
3266
|
+
overflow: auto;
|
|
3267
|
+
}
|
|
3268
|
+
.code-editor .code-highlight {
|
|
3269
|
+
background: transparent !important;
|
|
3270
|
+
pointer-events: none;
|
|
3271
|
+
z-index: 1;
|
|
3272
|
+
}
|
|
3273
|
+
.code-editor .code-highlight code {
|
|
3274
|
+
display: block;
|
|
3275
|
+
font-family: inherit;
|
|
3276
|
+
}
|
|
3277
|
+
.code-editor .code-input {
|
|
3278
|
+
background: transparent !important;
|
|
3279
|
+
color: transparent !important;
|
|
3280
|
+
caret-color: #d4d4d4;
|
|
3281
|
+
resize: none;
|
|
3282
|
+
outline: none;
|
|
3283
|
+
z-index: 2;
|
|
3284
|
+
}
|
|
3285
|
+
.code-editor .code-input:disabled { opacity: 0.7; }
|
|
3286
|
+
.code-runner-light .code-editor .code-highlight code {
|
|
3287
|
+
color: #333333;
|
|
3288
|
+
}
|
|
3289
|
+
.code-runner-light .code-editor .code-input {
|
|
3290
|
+
caret-color: #333333;
|
|
3291
|
+
}
|
|
3292
|
+
.resize-handle {
|
|
3293
|
+
width: 6px;
|
|
3294
|
+
background: #252526;
|
|
3295
|
+
cursor: col-resize;
|
|
3296
|
+
display: flex;
|
|
3297
|
+
align-items: center;
|
|
3298
|
+
justify-content: center;
|
|
3299
|
+
}
|
|
3300
|
+
.resize-handle:hover { background: #4fc3f7; }
|
|
3301
|
+
.resize-line { width: 2px; height: 40px; background: #444; border-radius: 1px; }
|
|
3302
|
+
.resize-handle:hover .resize-line { background: #fff; }
|
|
3303
|
+
.output-panel {
|
|
3304
|
+
display: flex;
|
|
3305
|
+
flex-direction: column;
|
|
3306
|
+
min-width: 20%;
|
|
3307
|
+
border-left: 1px solid #333;
|
|
3308
|
+
}
|
|
3309
|
+
.code-runner-light .output-panel { border-color: #e0e0e0; }
|
|
3310
|
+
.output-tabs { display: flex; gap: 4px; }
|
|
3311
|
+
.tab {
|
|
3312
|
+
padding: 4px 12px;
|
|
3313
|
+
border: none;
|
|
3314
|
+
background: transparent;
|
|
3315
|
+
cursor: pointer;
|
|
3316
|
+
font-size: 12px;
|
|
3317
|
+
border-radius: 4px;
|
|
3318
|
+
color: #888;
|
|
3319
|
+
transition: all 0.2s;
|
|
3320
|
+
}
|
|
3321
|
+
.tab:hover { color: #d4d4d4; background: #3d3d3d; }
|
|
3322
|
+
.code-runner-light .tab:hover { color: #333; background: #e0e0e0; }
|
|
3323
|
+
.tab.active { background: #4fc3f7; color: #000; font-weight: 500; }
|
|
3324
|
+
.output-actions { display: flex; align-items: center; gap: 12px; }
|
|
3325
|
+
.execution-time { font-size: 12px; color: #4caf50; font-weight: 500; }
|
|
3326
|
+
.btn-icon {
|
|
3327
|
+
background: transparent;
|
|
3328
|
+
border: none;
|
|
3329
|
+
cursor: pointer;
|
|
3330
|
+
padding: 4px;
|
|
3331
|
+
border-radius: 4px;
|
|
3332
|
+
color: #888;
|
|
3333
|
+
display: flex;
|
|
3334
|
+
align-items: center;
|
|
3335
|
+
justify-content: center;
|
|
3336
|
+
transition: all 0.2s;
|
|
3337
|
+
}
|
|
3338
|
+
.btn-icon:hover { color: #fff; background: #3d3d3d; }
|
|
3339
|
+
.code-runner-light .btn-icon:hover { color: #333; background: #e0e0e0; }
|
|
3340
|
+
.output-content {
|
|
3341
|
+
flex: 1;
|
|
3342
|
+
padding: 12px 16px;
|
|
3343
|
+
overflow: auto;
|
|
3344
|
+
background: #1e1e1e;
|
|
3345
|
+
}
|
|
3346
|
+
.code-runner-light .output-content { background: #fff; }
|
|
3347
|
+
.output-content pre {
|
|
3348
|
+
margin: 0;
|
|
3349
|
+
font-size: 13px;
|
|
3350
|
+
line-height: 1.6;
|
|
3351
|
+
white-space: pre-wrap;
|
|
3352
|
+
word-break: break-all;
|
|
3353
|
+
color: #d4d4d4;
|
|
3354
|
+
}
|
|
3355
|
+
.code-runner-light .output-content pre { color: #333; }
|
|
3356
|
+
.output-content .stderr { color: #f44336; }
|
|
3357
|
+
.spinner {
|
|
3358
|
+
width: 12px;
|
|
3359
|
+
height: 12px;
|
|
3360
|
+
border: 2px solid rgba(255,255,255,0.3);
|
|
3361
|
+
border-top-color: white;
|
|
3362
|
+
border-radius: 50%;
|
|
3363
|
+
animation: spin 0.8s linear infinite;
|
|
3364
|
+
}
|
|
3365
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
3366
|
+
` })
|
|
3367
|
+
] });
|
|
3368
|
+
};
|
|
3369
|
+
export {
|
|
3370
|
+
Lt as CodeRunner,
|
|
3371
|
+
Lt as default
|
|
3372
|
+
};
|