@splunk/react-ui 5.4.0 → 5.6.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/AnchorMenu.d.ts +2 -0
- package/AnchorMenu.js +286 -0
- package/Badge.d.ts +2 -0
- package/Badge.js +154 -0
- package/CHANGELOG.md +42 -0
- package/Code.js +1097 -500
- package/Color.js +142 -141
- package/ComboBox.js +6 -5
- package/Link.js +74 -44
- package/MIGRATION.md +32 -1
- package/Menu.js +41 -43
- package/Multiselect.js +615 -2156
- package/Number.js +3 -3
- package/PhoneNumber.d.ts +2 -0
- package/PhoneNumber.js +769 -0
- package/Popover.js +73 -75
- package/RadioList.js +166 -151
- package/ResultsMenu.js +27 -29
- package/Select.js +179 -1768
- package/SelectBase.d.ts +2 -0
- package/SelectBase.js +1714 -0
- package/Slider.js +358 -302
- package/SlidingPanels.js +55 -62
- package/Switch.js +42 -27
- package/TabBar.js +295 -294
- package/TabLayout.js +14 -14
- package/Table.js +1087 -1040
- package/TransitionOpen.js +65 -58
- package/cypress/support/commands.ts +40 -0
- package/cypress/support/component.ts +1 -1
- package/cypress/support/index.d.ts +22 -0
- package/docker-compose.yml +99 -52
- package/package.json +9 -5
- package/stubs-splunkui.d.ts +0 -86
- package/test-runner-jest.config.js +1 -0
- package/types/src/AnchorMenu/AnchorMenu.d.ts +36 -0
- package/types/src/AnchorMenu/AnchorMenuContext.d.ts +6 -0
- package/types/src/AnchorMenu/Item.d.ts +35 -0
- package/types/src/AnchorMenu/docs/examples/Basic.d.ts +6 -0
- package/types/src/AnchorMenu/index.d.ts +3 -0
- package/types/src/Badge/Badge.d.ts +29 -0
- package/types/src/Badge/docs/examples/Basic.d.ts +5 -0
- package/types/src/Badge/docs/examples/Count.d.ts +6 -0
- package/types/src/Badge/docs/examples/CustomColors.d.ts +8 -0
- package/types/src/Badge/docs/examples/Icon.d.ts +6 -0
- package/types/src/Badge/index.d.ts +2 -0
- package/types/src/Code/Code.d.ts +4 -3
- package/types/src/Code/index.d.ts +1 -0
- package/types/src/Link/Link.d.ts +4 -0
- package/types/src/Link/LinkContext.d.ts +14 -0
- package/types/src/Link/docs/examples/Visited.d.ts +7 -0
- package/types/src/Link/index.d.ts +1 -0
- package/types/src/Menu/Item.d.ts +1 -1
- package/types/src/Multiselect/Compact.d.ts +8 -1
- package/types/src/Multiselect/Multiselect.d.ts +8 -1
- package/types/src/PhoneNumber/PhoneNumber.d.ts +139 -0
- package/types/src/PhoneNumber/docs/examples/Controlled.d.ts +7 -0
- package/types/src/PhoneNumber/docs/examples/DefaultCountry.d.ts +7 -0
- package/types/src/PhoneNumber/docs/examples/Disabled.d.ts +6 -0
- package/types/src/PhoneNumber/docs/examples/Error.d.ts +6 -0
- package/types/src/PhoneNumber/docs/examples/Inline.d.ts +7 -0
- package/types/src/PhoneNumber/docs/examples/Uncontrolled.d.ts +7 -0
- package/types/src/PhoneNumber/index.d.ts +2 -0
- package/types/src/PhoneNumber/utils.d.ts +47 -0
- package/types/src/RadioList/Option.d.ts +6 -1
- package/types/src/RadioList/docs/examples/Description.d.ts +6 -0
- package/types/src/Select/Option.d.ts +8 -3
- package/types/src/Select/Select.d.ts +1 -1
- package/types/src/{Select → SelectBase}/OptionBase.d.ts +8 -2
- package/types/src/{Select → SelectBase}/SelectBase.d.ts +11 -2
- package/types/src/SelectBase/index.d.ts +2 -0
- package/types/src/Slider/Slider.d.ts +7 -1
- package/types/src/Switch/Switch.d.ts +4 -1
- package/types/src/Table/Body.d.ts +6 -1
- package/types/src/Table/Cell.d.ts +5 -1
- package/types/src/Table/Head.d.ts +6 -2
- package/types/src/Table/HeadCell.d.ts +5 -1
- package/types/src/Table/Row.d.ts +5 -1
- package/types/src/Table/Table.d.ts +20 -1
- package/types/src/Table/TableContext.d.ts +1 -0
- package/types/src/Table/docs/examples/HorizontalOverflowScroll.d.ts +8 -0
- package/types/src/Table/docs/examples/PinActionColumn.d.ts +7 -0
- package/types/src/TransitionOpen/TransitionOpen.d.ts +3 -1
- package/types/src/useResizeObserver/useResizeObserver.d.ts +2 -0
- package/types/src/useRovingFocus/useRovingFocus.d.ts +8 -1
- package/usePrevious.d.ts +2 -0
- package/useResizeObserver.js +59 -92
- package/useRovingFocus.js +96 -41
- /package/types/src/{Select → SelectBase}/SelectAllOption.d.ts +0 -0
package/Code.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
var t = undefined;
|
|
8
8
|
var n = undefined;
|
|
9
9
|
/// <reference lib="WebWorker"/>
|
|
10
|
-
var
|
|
10
|
+
var r = typeof t !== "undefined" ? t : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
|
|
11
11
|
/**
|
|
12
12
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
13
13
|
*
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
* @author Lea Verou <https://lea.verou.me>
|
|
16
16
|
* @namespace
|
|
17
17
|
* @public
|
|
18
|
-
*/ var
|
|
18
|
+
*/ var a = function(e) {
|
|
19
19
|
// Private helper vars
|
|
20
20
|
var n = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
|
|
21
|
-
var
|
|
21
|
+
var r = 0;
|
|
22
22
|
// The grammar object for plaintext
|
|
23
|
-
var
|
|
24
|
-
var
|
|
23
|
+
var a = {};
|
|
24
|
+
var s = {
|
|
25
25
|
/**
|
|
26
26
|
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
27
27
|
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
*/
|
|
78
78
|
util: {
|
|
79
79
|
encode: function e(t) {
|
|
80
|
-
if (t instanceof
|
|
81
|
-
return new
|
|
80
|
+
if (t instanceof i) {
|
|
81
|
+
return new i(t.type, e(t.content), t.alias);
|
|
82
82
|
} else if (Array.isArray(t)) {
|
|
83
83
|
return t.map(e);
|
|
84
84
|
} else {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
objId: function(e) {
|
|
114
114
|
if (!e["__id"]) {
|
|
115
115
|
Object.defineProperty(e, "__id", {
|
|
116
|
-
value: ++
|
|
116
|
+
value: ++r
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
return e["__id"];
|
|
@@ -130,36 +130,36 @@
|
|
|
130
130
|
*/
|
|
131
131
|
clone: function e(t, n) {
|
|
132
132
|
n = n || {};
|
|
133
|
-
var a;
|
|
134
133
|
var r;
|
|
135
|
-
|
|
134
|
+
var a;
|
|
135
|
+
switch (s.util.type(t)) {
|
|
136
136
|
case "Object":
|
|
137
|
-
|
|
138
|
-
if (n[
|
|
139
|
-
return n[
|
|
137
|
+
a = s.util.objId(t);
|
|
138
|
+
if (n[a]) {
|
|
139
|
+
return n[a];
|
|
140
140
|
}
|
|
141
|
-
|
|
142
|
-
n[
|
|
143
|
-
for (var
|
|
144
|
-
if (t.hasOwnProperty(
|
|
145
|
-
|
|
141
|
+
r = /** @type {Record<string, any>} */ {};
|
|
142
|
+
n[a] = r;
|
|
143
|
+
for (var i in t) {
|
|
144
|
+
if (t.hasOwnProperty(i)) {
|
|
145
|
+
r[i] = e(t[i], n);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
/** @type {any} */
|
|
149
|
-
return
|
|
149
|
+
return r;
|
|
150
150
|
|
|
151
151
|
case "Array":
|
|
152
|
-
|
|
153
|
-
if (n[
|
|
154
|
-
return n[
|
|
152
|
+
a = s.util.objId(t);
|
|
153
|
+
if (n[a]) {
|
|
154
|
+
return n[a];
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
n[
|
|
158
|
-
/** @type {Array} */ /** @type {any} */ t.forEach((function(t,
|
|
159
|
-
a
|
|
156
|
+
r = [];
|
|
157
|
+
n[a] = r;
|
|
158
|
+
/** @type {Array} */ /** @type {any} */ t.forEach((function(t, a) {
|
|
159
|
+
r[a] = e(t, n);
|
|
160
160
|
}));
|
|
161
161
|
/** @type {any} */
|
|
162
|
-
return
|
|
162
|
+
return r;
|
|
163
163
|
|
|
164
164
|
default:
|
|
165
165
|
return t;
|
|
@@ -218,13 +218,13 @@
|
|
|
218
218
|
// this will not work for inline scripts
|
|
219
219
|
try {
|
|
220
220
|
throw new Error;
|
|
221
|
-
} catch (
|
|
221
|
+
} catch (r) {
|
|
222
222
|
// Get file src url from stack. Specifically works with the format of stack traces in IE.
|
|
223
223
|
// A stack will look like this:
|
|
224
224
|
// Error
|
|
225
225
|
// at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
|
|
226
226
|
// at Global code (http://localhost/components/prism-core.js:606:1)
|
|
227
|
-
var e = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(
|
|
227
|
+
var e = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack) || [])[1];
|
|
228
228
|
if (e) {
|
|
229
229
|
var t = document.getElementsByTagName("script");
|
|
230
230
|
for (var n in t) {
|
|
@@ -256,13 +256,13 @@
|
|
|
256
256
|
* @returns {boolean}
|
|
257
257
|
*/
|
|
258
258
|
isActive: function(e, t, n) {
|
|
259
|
-
var
|
|
259
|
+
var r = "no-" + t;
|
|
260
260
|
while (e) {
|
|
261
|
-
var
|
|
262
|
-
if (
|
|
261
|
+
var a = e.classList;
|
|
262
|
+
if (a.contains(t)) {
|
|
263
263
|
return true;
|
|
264
264
|
}
|
|
265
|
-
if (
|
|
265
|
+
if (a.contains(r)) {
|
|
266
266
|
return false;
|
|
267
267
|
}
|
|
268
268
|
e = e.parentElement;
|
|
@@ -281,10 +281,10 @@
|
|
|
281
281
|
/**
|
|
282
282
|
* The grammar for plain, unformatted text.
|
|
283
283
|
*/
|
|
284
|
-
plain:
|
|
285
|
-
plaintext:
|
|
286
|
-
text:
|
|
287
|
-
txt:
|
|
284
|
+
plain: a,
|
|
285
|
+
plaintext: a,
|
|
286
|
+
text: a,
|
|
287
|
+
txt: a,
|
|
288
288
|
/**
|
|
289
289
|
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
290
290
|
*
|
|
@@ -314,9 +314,9 @@
|
|
|
314
314
|
* });
|
|
315
315
|
*/
|
|
316
316
|
extend: function(e, t) {
|
|
317
|
-
var n =
|
|
318
|
-
for (var
|
|
319
|
-
n[
|
|
317
|
+
var n = s.util.clone(s.languages[e]);
|
|
318
|
+
for (var r in t) {
|
|
319
|
+
n[r] = t[r];
|
|
320
320
|
}
|
|
321
321
|
return n;
|
|
322
322
|
},
|
|
@@ -395,50 +395,50 @@
|
|
|
395
395
|
* @returns {Grammar} The new grammar object.
|
|
396
396
|
* @public
|
|
397
397
|
*/
|
|
398
|
-
insertBefore: function(e, t, n,
|
|
399
|
-
|
|
400
|
-
var
|
|
401
|
-
/** @type {Grammar} */ var
|
|
402
|
-
for (var o in
|
|
403
|
-
if (
|
|
398
|
+
insertBefore: function(e, t, n, r) {
|
|
399
|
+
r = r || /** @type {any} */ s.languages;
|
|
400
|
+
var a = r[e];
|
|
401
|
+
/** @type {Grammar} */ var i = {};
|
|
402
|
+
for (var o in a) {
|
|
403
|
+
if (a.hasOwnProperty(o)) {
|
|
404
404
|
if (o == t) {
|
|
405
405
|
for (var l in n) {
|
|
406
406
|
if (n.hasOwnProperty(l)) {
|
|
407
|
-
|
|
407
|
+
i[l] = n[l];
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
// Do not insert token which also occur in insert. See #1525
|
|
412
412
|
if (!n.hasOwnProperty(o)) {
|
|
413
|
-
|
|
413
|
+
i[o] = a[o];
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
var u =
|
|
418
|
-
|
|
417
|
+
var u = r[e];
|
|
418
|
+
r[e] = i;
|
|
419
419
|
// Update references in other language definitions
|
|
420
|
-
|
|
420
|
+
s.languages.DFS(s.languages, (function(t, n) {
|
|
421
421
|
if (n === u && t != e) {
|
|
422
|
-
this[t] =
|
|
422
|
+
this[t] = i;
|
|
423
423
|
}
|
|
424
424
|
}));
|
|
425
|
-
return
|
|
425
|
+
return i;
|
|
426
426
|
},
|
|
427
427
|
// Traverse a language definition with Depth First Search
|
|
428
|
-
DFS: function e(t, n,
|
|
429
|
-
|
|
430
|
-
var
|
|
428
|
+
DFS: function e(t, n, r, a) {
|
|
429
|
+
a = a || {};
|
|
430
|
+
var i = s.util.objId;
|
|
431
431
|
for (var o in t) {
|
|
432
432
|
if (t.hasOwnProperty(o)) {
|
|
433
|
-
n.call(t, o, t[o],
|
|
433
|
+
n.call(t, o, t[o], r || o);
|
|
434
434
|
var l = t[o];
|
|
435
|
-
var u =
|
|
436
|
-
if (u === "Object" && !
|
|
437
|
-
|
|
438
|
-
e(l, n, null,
|
|
439
|
-
} else if (u === "Array" && !
|
|
440
|
-
|
|
441
|
-
e(l, n, o,
|
|
435
|
+
var u = s.util.type(l);
|
|
436
|
+
if (u === "Object" && !a[i(l)]) {
|
|
437
|
+
a[i(l)] = true;
|
|
438
|
+
e(l, n, null, a);
|
|
439
|
+
} else if (u === "Array" && !a[i(l)]) {
|
|
440
|
+
a[i(l)] = true;
|
|
441
|
+
e(l, n, o, a);
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
}
|
|
@@ -458,7 +458,7 @@
|
|
|
458
458
|
* @public
|
|
459
459
|
*/
|
|
460
460
|
highlightAll: function(e, t) {
|
|
461
|
-
|
|
461
|
+
s.highlightAllUnder(document, e, t);
|
|
462
462
|
},
|
|
463
463
|
/**
|
|
464
464
|
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
@@ -476,16 +476,16 @@
|
|
|
476
476
|
* @public
|
|
477
477
|
*/
|
|
478
478
|
highlightAllUnder: function(e, t, n) {
|
|
479
|
-
var
|
|
479
|
+
var r = {
|
|
480
480
|
callback: n,
|
|
481
481
|
container: e,
|
|
482
482
|
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
483
483
|
};
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
for (var
|
|
488
|
-
|
|
484
|
+
s.hooks.run("before-highlightall", r);
|
|
485
|
+
r.elements = Array.prototype.slice.apply(r.container.querySelectorAll(r.selector));
|
|
486
|
+
s.hooks.run("before-all-elements-highlight", r);
|
|
487
|
+
for (var a = 0, i; i = r.elements[a++]; ) {
|
|
488
|
+
s.highlightElement(i, t === true, r.callback);
|
|
489
489
|
}
|
|
490
490
|
},
|
|
491
491
|
/**
|
|
@@ -516,50 +516,50 @@
|
|
|
516
516
|
* @memberof Prism
|
|
517
517
|
* @public
|
|
518
518
|
*/
|
|
519
|
-
highlightElement: function(t, n,
|
|
519
|
+
highlightElement: function(t, n, r) {
|
|
520
520
|
// Find language
|
|
521
|
-
var
|
|
522
|
-
var
|
|
521
|
+
var a = s.util.getLanguage(t);
|
|
522
|
+
var i = s.languages[a];
|
|
523
523
|
// Set language on the element, if not present
|
|
524
|
-
|
|
524
|
+
s.util.setLanguage(t, a);
|
|
525
525
|
// Set language on the parent, for styling
|
|
526
526
|
var o = t.parentElement;
|
|
527
527
|
if (o && o.nodeName.toLowerCase() === "pre") {
|
|
528
|
-
|
|
528
|
+
s.util.setLanguage(o, a);
|
|
529
529
|
}
|
|
530
530
|
var l = t.textContent;
|
|
531
531
|
var u = {
|
|
532
532
|
element: t,
|
|
533
|
-
language:
|
|
534
|
-
grammar:
|
|
533
|
+
language: a,
|
|
534
|
+
grammar: i,
|
|
535
535
|
code: l
|
|
536
536
|
};
|
|
537
537
|
function c(e) {
|
|
538
538
|
u.highlightedCode = e;
|
|
539
|
-
|
|
539
|
+
s.hooks.run("before-insert", u);
|
|
540
540
|
u.element.innerHTML = u.highlightedCode;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
541
|
+
s.hooks.run("after-highlight", u);
|
|
542
|
+
s.hooks.run("complete", u);
|
|
543
|
+
r && r.call(u.element);
|
|
544
544
|
}
|
|
545
|
-
|
|
545
|
+
s.hooks.run("before-sanity-check", u);
|
|
546
546
|
// plugins may change/add the parent/element
|
|
547
547
|
o = u.element.parentElement;
|
|
548
548
|
if (o && o.nodeName.toLowerCase() === "pre" && !o.hasAttribute("tabindex")) {
|
|
549
549
|
o.setAttribute("tabindex", "0");
|
|
550
550
|
}
|
|
551
551
|
if (!u.code) {
|
|
552
|
-
|
|
553
|
-
|
|
552
|
+
s.hooks.run("complete", u);
|
|
553
|
+
r && r.call(u.element);
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
|
-
|
|
556
|
+
s.hooks.run("before-highlight", u);
|
|
557
557
|
if (!u.grammar) {
|
|
558
|
-
c(
|
|
558
|
+
c(s.util.encode(u.code));
|
|
559
559
|
return;
|
|
560
560
|
}
|
|
561
561
|
if (n && e.Worker) {
|
|
562
|
-
var p = new Worker(
|
|
562
|
+
var p = new Worker(s.filename);
|
|
563
563
|
p.onmessage = function(e) {
|
|
564
564
|
c(e.data);
|
|
565
565
|
};
|
|
@@ -569,7 +569,7 @@
|
|
|
569
569
|
immediateClose: true
|
|
570
570
|
}));
|
|
571
571
|
} else {
|
|
572
|
-
c(
|
|
572
|
+
c(s.highlight(u.code, u.grammar, u.language));
|
|
573
573
|
}
|
|
574
574
|
},
|
|
575
575
|
/**
|
|
@@ -593,18 +593,18 @@
|
|
|
593
593
|
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
594
594
|
*/
|
|
595
595
|
highlight: function(e, t, n) {
|
|
596
|
-
var
|
|
596
|
+
var r = {
|
|
597
597
|
code: e,
|
|
598
598
|
grammar: t,
|
|
599
599
|
language: n
|
|
600
600
|
};
|
|
601
|
-
|
|
602
|
-
if (!
|
|
603
|
-
throw new Error('The language "' +
|
|
601
|
+
s.hooks.run("before-tokenize", r);
|
|
602
|
+
if (!r.grammar) {
|
|
603
|
+
throw new Error('The language "' + r.language + '" has no grammar.');
|
|
604
604
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
return
|
|
605
|
+
r.tokens = s.tokenize(r.code, r.grammar);
|
|
606
|
+
s.hooks.run("after-tokenize", r);
|
|
607
|
+
return i.stringify(s.util.encode(r.tokens), r.language);
|
|
608
608
|
},
|
|
609
609
|
/**
|
|
610
610
|
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
@@ -633,15 +633,15 @@
|
|
|
633
633
|
tokenize: function(e, t) {
|
|
634
634
|
var n = t.rest;
|
|
635
635
|
if (n) {
|
|
636
|
-
for (var
|
|
637
|
-
t[
|
|
636
|
+
for (var r in n) {
|
|
637
|
+
t[r] = n[r];
|
|
638
638
|
}
|
|
639
639
|
delete t.rest;
|
|
640
640
|
}
|
|
641
|
-
var
|
|
642
|
-
c(
|
|
643
|
-
l(e,
|
|
644
|
-
return d(
|
|
641
|
+
var a = new u;
|
|
642
|
+
c(a, a.head, e);
|
|
643
|
+
l(e, a, t, a.head, 0);
|
|
644
|
+
return d(a);
|
|
645
645
|
},
|
|
646
646
|
/**
|
|
647
647
|
* @namespace
|
|
@@ -663,7 +663,7 @@
|
|
|
663
663
|
* @public
|
|
664
664
|
*/
|
|
665
665
|
add: function(e, t) {
|
|
666
|
-
var n =
|
|
666
|
+
var n = s.hooks.all;
|
|
667
667
|
n[e] = n[e] || [];
|
|
668
668
|
n[e].push(t);
|
|
669
669
|
},
|
|
@@ -677,18 +677,18 @@
|
|
|
677
677
|
* @public
|
|
678
678
|
*/
|
|
679
679
|
run: function(e, t) {
|
|
680
|
-
var n =
|
|
680
|
+
var n = s.hooks.all[e];
|
|
681
681
|
if (!n || !n.length) {
|
|
682
682
|
return;
|
|
683
683
|
}
|
|
684
|
-
for (var
|
|
685
|
-
|
|
684
|
+
for (var r = 0, a; a = n[r++]; ) {
|
|
685
|
+
a(t);
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
},
|
|
689
|
-
Token:
|
|
689
|
+
Token: i
|
|
690
690
|
};
|
|
691
|
-
e.Prism =
|
|
691
|
+
e.Prism = s;
|
|
692
692
|
// Typescript note:
|
|
693
693
|
// The following can be used to import the Token type in JSDoc:
|
|
694
694
|
|
|
@@ -703,7 +703,7 @@
|
|
|
703
703
|
* @class
|
|
704
704
|
* @global
|
|
705
705
|
* @public
|
|
706
|
-
*/ function
|
|
706
|
+
*/ function i(e, t, n, r) {
|
|
707
707
|
/**
|
|
708
708
|
* The type of the token.
|
|
709
709
|
*
|
|
@@ -730,7 +730,7 @@
|
|
|
730
730
|
* @public
|
|
731
731
|
*/ this.alias = n;
|
|
732
732
|
// Copy of the full string this token was created from
|
|
733
|
-
this.length = (
|
|
733
|
+
this.length = (r || "").length | 0;
|
|
734
734
|
}
|
|
735
735
|
/**
|
|
736
736
|
* A token stream is an array of strings and {@link Token Token} objects.
|
|
@@ -758,18 +758,18 @@
|
|
|
758
758
|
* @returns {string} The HTML representation of the token or token stream.
|
|
759
759
|
* @memberof Token
|
|
760
760
|
* @static
|
|
761
|
-
*/
|
|
761
|
+
*/ i.stringify = function e(t, n) {
|
|
762
762
|
if (typeof t == "string") {
|
|
763
763
|
return t;
|
|
764
764
|
}
|
|
765
765
|
if (Array.isArray(t)) {
|
|
766
|
-
var
|
|
766
|
+
var r = "";
|
|
767
767
|
t.forEach((function(t) {
|
|
768
|
-
|
|
768
|
+
r += e(t, n);
|
|
769
769
|
}));
|
|
770
|
-
return
|
|
770
|
+
return r;
|
|
771
771
|
}
|
|
772
|
-
var
|
|
772
|
+
var a = {
|
|
773
773
|
type: t.type,
|
|
774
774
|
content: e(t.content, n),
|
|
775
775
|
tag: "span",
|
|
@@ -777,20 +777,20 @@
|
|
|
777
777
|
attributes: {},
|
|
778
778
|
language: n
|
|
779
779
|
};
|
|
780
|
-
var
|
|
781
|
-
if (
|
|
782
|
-
if (Array.isArray(
|
|
783
|
-
Array.prototype.push.apply(
|
|
780
|
+
var i = t.alias;
|
|
781
|
+
if (i) {
|
|
782
|
+
if (Array.isArray(i)) {
|
|
783
|
+
Array.prototype.push.apply(a.classes, i);
|
|
784
784
|
} else {
|
|
785
|
-
|
|
785
|
+
a.classes.push(i);
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
|
-
|
|
788
|
+
s.hooks.run("wrap", a);
|
|
789
789
|
var o = "";
|
|
790
|
-
for (var l in
|
|
791
|
-
o += " " + l + '="' + (
|
|
790
|
+
for (var l in a.attributes) {
|
|
791
|
+
o += " " + l + '="' + (a.attributes[l] || "").replace(/"/g, """) + '"';
|
|
792
792
|
}
|
|
793
|
-
return "<" +
|
|
793
|
+
return "<" + a.tag + ' class="' + a.classes.join(" ") + '"' + o + ">" + a.content + "</" + a.tag + ">";
|
|
794
794
|
};
|
|
795
795
|
/**
|
|
796
796
|
* @param {RegExp} pattern
|
|
@@ -798,16 +798,16 @@
|
|
|
798
798
|
* @param {string} text
|
|
799
799
|
* @param {boolean} lookbehind
|
|
800
800
|
* @returns {RegExpExecArray | null}
|
|
801
|
-
*/ function o(e, t, n,
|
|
801
|
+
*/ function o(e, t, n, r) {
|
|
802
802
|
e.lastIndex = t;
|
|
803
|
-
var
|
|
804
|
-
if (
|
|
803
|
+
var a = e.exec(n);
|
|
804
|
+
if (a && r && a[1]) {
|
|
805
805
|
// change the match to remove the text matched by the Prism lookbehind group
|
|
806
|
-
var
|
|
807
|
-
|
|
808
|
-
|
|
806
|
+
var s = a[1].length;
|
|
807
|
+
a.index += s;
|
|
808
|
+
a[0] = a[0].slice(s);
|
|
809
809
|
}
|
|
810
|
-
return
|
|
810
|
+
return a;
|
|
811
811
|
}
|
|
812
812
|
/**
|
|
813
813
|
* @param {string} text
|
|
@@ -822,7 +822,7 @@
|
|
|
822
822
|
* @typedef RematchOptions
|
|
823
823
|
* @property {string} cause
|
|
824
824
|
* @property {number} reach
|
|
825
|
-
*/ function l(e, t, n,
|
|
825
|
+
*/ function l(e, t, n, r, a, u) {
|
|
826
826
|
for (var d in n) {
|
|
827
827
|
if (!n.hasOwnProperty(d) || !n[d]) {
|
|
828
828
|
continue;
|
|
@@ -834,97 +834,97 @@
|
|
|
834
834
|
return;
|
|
835
835
|
}
|
|
836
836
|
var m = g[f];
|
|
837
|
-
var
|
|
838
|
-
var
|
|
839
|
-
var
|
|
840
|
-
var
|
|
841
|
-
if (
|
|
837
|
+
var b = m.inside;
|
|
838
|
+
var h = !!m.lookbehind;
|
|
839
|
+
var v = !!m.greedy;
|
|
840
|
+
var E = m.alias;
|
|
841
|
+
if (v && !m.pattern.global) {
|
|
842
842
|
// Without the global flag, lastIndex won't work
|
|
843
843
|
var y = m.pattern.toString().match(/[imsuy]*$/)[0];
|
|
844
844
|
m.pattern = RegExp(m.pattern.source, y + "g");
|
|
845
845
|
}
|
|
846
846
|
/** @type {RegExp} */ var S = m.pattern || m;
|
|
847
847
|
for (// iterate the token list and keep track of the current token/string position
|
|
848
|
-
var A =
|
|
849
|
-
if (u &&
|
|
848
|
+
var A = r.next, k = a; A !== t.tail; k += A.value.length, A = A.next) {
|
|
849
|
+
if (u && k >= u.reach) {
|
|
850
850
|
break;
|
|
851
851
|
}
|
|
852
|
-
var
|
|
852
|
+
var x = A.value;
|
|
853
853
|
if (t.length > e.length) {
|
|
854
854
|
// Something went terribly wrong, ABORT, ABORT!
|
|
855
855
|
return;
|
|
856
856
|
}
|
|
857
|
-
if (
|
|
857
|
+
if (x instanceof i) {
|
|
858
858
|
continue;
|
|
859
859
|
}
|
|
860
|
-
var
|
|
860
|
+
var T = 1;
|
|
861
861
|
// this is the to parameter of removeBetween
|
|
862
|
-
var
|
|
863
|
-
if (
|
|
864
|
-
|
|
865
|
-
if (!
|
|
862
|
+
var I;
|
|
863
|
+
if (v) {
|
|
864
|
+
I = o(S, k, e, h);
|
|
865
|
+
if (!I || I.index >= e.length) {
|
|
866
866
|
break;
|
|
867
867
|
}
|
|
868
|
-
var
|
|
869
|
-
var
|
|
870
|
-
var
|
|
868
|
+
var R = I.index;
|
|
869
|
+
var w = I.index + I[0].length;
|
|
870
|
+
var N = k;
|
|
871
871
|
// find the node that contains the match
|
|
872
|
-
|
|
873
|
-
while (
|
|
872
|
+
N += A.value.length;
|
|
873
|
+
while (R >= N) {
|
|
874
874
|
A = A.next;
|
|
875
|
-
|
|
875
|
+
N += A.value.length;
|
|
876
876
|
}
|
|
877
877
|
// adjust pos (and p)
|
|
878
|
-
|
|
879
|
-
|
|
878
|
+
N -= A.value.length;
|
|
879
|
+
k = N;
|
|
880
880
|
// the current node is a Token, then the match starts inside another Token, which is invalid
|
|
881
|
-
if (A.value instanceof
|
|
881
|
+
if (A.value instanceof i) {
|
|
882
882
|
continue;
|
|
883
883
|
}
|
|
884
884
|
// find the last node which is affected by this match
|
|
885
|
-
for (var
|
|
886
|
-
|
|
887
|
-
|
|
885
|
+
for (var O = A; O !== t.tail && (N < w || typeof O.value === "string"); O = O.next) {
|
|
886
|
+
T++;
|
|
887
|
+
N += O.value.length;
|
|
888
888
|
}
|
|
889
|
-
|
|
889
|
+
T--;
|
|
890
890
|
// replace with the new match
|
|
891
|
-
|
|
892
|
-
|
|
891
|
+
x = e.slice(k, N);
|
|
892
|
+
I.index -= k;
|
|
893
893
|
} else {
|
|
894
|
-
|
|
895
|
-
if (!
|
|
894
|
+
I = o(S, 0, x, h);
|
|
895
|
+
if (!I) {
|
|
896
896
|
continue;
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
// eslint-disable-next-line no-redeclare
|
|
900
|
-
var
|
|
901
|
-
var
|
|
902
|
-
var
|
|
903
|
-
var
|
|
904
|
-
var
|
|
905
|
-
if (u &&
|
|
906
|
-
u.reach =
|
|
900
|
+
var R = I.index;
|
|
901
|
+
var _ = I[0];
|
|
902
|
+
var L = x.slice(0, R);
|
|
903
|
+
var F = x.slice(R + _.length);
|
|
904
|
+
var C = k + x.length;
|
|
905
|
+
if (u && C > u.reach) {
|
|
906
|
+
u.reach = C;
|
|
907
907
|
}
|
|
908
|
-
var
|
|
909
|
-
if (
|
|
910
|
-
|
|
911
|
-
|
|
908
|
+
var D = A.prev;
|
|
909
|
+
if (L) {
|
|
910
|
+
D = c(t, D, L);
|
|
911
|
+
k += L.length;
|
|
912
912
|
}
|
|
913
|
-
p(t,
|
|
914
|
-
var
|
|
915
|
-
A = c(t,
|
|
916
|
-
if (
|
|
917
|
-
c(t, A,
|
|
913
|
+
p(t, D, T);
|
|
914
|
+
var P = new i(d, b ? s.tokenize(_, b) : _, E, _);
|
|
915
|
+
A = c(t, D, P);
|
|
916
|
+
if (F) {
|
|
917
|
+
c(t, A, F);
|
|
918
918
|
}
|
|
919
|
-
if (
|
|
919
|
+
if (T > 1) {
|
|
920
920
|
// at least one Token object was removed, so we have to do some rematching
|
|
921
921
|
// this can only happen if the current pattern is greedy
|
|
922
922
|
/** @type {RematchOptions} */
|
|
923
923
|
var $ = {
|
|
924
924
|
cause: d + "," + f,
|
|
925
|
-
reach:
|
|
925
|
+
reach: C
|
|
926
926
|
};
|
|
927
|
-
l(e, t, n, A.prev,
|
|
927
|
+
l(e, t, n, A.prev, k, $);
|
|
928
928
|
// the reach might have been extended because of the rematching
|
|
929
929
|
if (u && $.reach > u.reach) {
|
|
930
930
|
u.reach = $.reach;
|
|
@@ -972,16 +972,16 @@
|
|
|
972
972
|
* @template T
|
|
973
973
|
*/ function c(e, t, n) {
|
|
974
974
|
// assumes that node != list.tail && values.length >= 0
|
|
975
|
-
var
|
|
976
|
-
var
|
|
975
|
+
var r = t.next;
|
|
976
|
+
var a = {
|
|
977
977
|
value: n,
|
|
978
978
|
prev: t,
|
|
979
|
-
next:
|
|
979
|
+
next: r
|
|
980
980
|
};
|
|
981
|
-
t.next =
|
|
982
|
-
|
|
981
|
+
t.next = a;
|
|
982
|
+
r.prev = a;
|
|
983
983
|
e.length++;
|
|
984
|
-
return
|
|
984
|
+
return a;
|
|
985
985
|
}
|
|
986
986
|
/**
|
|
987
987
|
* Removes `count` nodes after the given node. The given node will not be removed.
|
|
@@ -991,13 +991,13 @@
|
|
|
991
991
|
* @param {number} count
|
|
992
992
|
* @template T
|
|
993
993
|
*/ function p(e, t, n) {
|
|
994
|
-
var
|
|
995
|
-
for (var
|
|
996
|
-
|
|
994
|
+
var r = t.next;
|
|
995
|
+
for (var a = 0; a < n && r !== e.tail; a++) {
|
|
996
|
+
r = r.next;
|
|
997
997
|
}
|
|
998
|
-
t.next =
|
|
999
|
-
|
|
1000
|
-
e.length -=
|
|
998
|
+
t.next = r;
|
|
999
|
+
r.prev = t;
|
|
1000
|
+
e.length -= a;
|
|
1001
1001
|
}
|
|
1002
1002
|
/**
|
|
1003
1003
|
* @param {LinkedList<T>} list
|
|
@@ -1015,37 +1015,37 @@
|
|
|
1015
1015
|
if (!e.document) {
|
|
1016
1016
|
if (!e.addEventListener) {
|
|
1017
1017
|
// in Node.js
|
|
1018
|
-
return
|
|
1018
|
+
return s;
|
|
1019
1019
|
}
|
|
1020
|
-
if (!
|
|
1020
|
+
if (!s.disableWorkerMessageHandler) {
|
|
1021
1021
|
// In worker
|
|
1022
1022
|
e.addEventListener("message", (function(t) {
|
|
1023
1023
|
var n = JSON.parse(t.data);
|
|
1024
|
-
var
|
|
1025
|
-
var
|
|
1026
|
-
var
|
|
1027
|
-
e.postMessage(
|
|
1028
|
-
if (
|
|
1024
|
+
var r = n.language;
|
|
1025
|
+
var a = n.code;
|
|
1026
|
+
var i = n.immediateClose;
|
|
1027
|
+
e.postMessage(s.highlight(a, s.languages[r], r));
|
|
1028
|
+
if (i) {
|
|
1029
1029
|
e.close();
|
|
1030
1030
|
}
|
|
1031
1031
|
}), false);
|
|
1032
1032
|
}
|
|
1033
|
-
return
|
|
1033
|
+
return s;
|
|
1034
1034
|
}
|
|
1035
1035
|
// Get current script and highlight
|
|
1036
|
-
var g =
|
|
1036
|
+
var g = s.util.currentScript();
|
|
1037
1037
|
if (g) {
|
|
1038
|
-
|
|
1038
|
+
s.filename = g.src;
|
|
1039
1039
|
if (g.hasAttribute("data-manual")) {
|
|
1040
|
-
|
|
1040
|
+
s.manual = true;
|
|
1041
1041
|
}
|
|
1042
1042
|
}
|
|
1043
1043
|
function f() {
|
|
1044
|
-
if (!
|
|
1045
|
-
|
|
1044
|
+
if (!s.manual) {
|
|
1045
|
+
s.highlightAll();
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
if (!
|
|
1048
|
+
if (!s.manual) {
|
|
1049
1049
|
// If the document state is "loading", then we'll use DOMContentLoaded.
|
|
1050
1050
|
// If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
|
|
1051
1051
|
// DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
|
|
@@ -1063,14 +1063,14 @@
|
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
|
-
return
|
|
1067
|
-
}(
|
|
1066
|
+
return s;
|
|
1067
|
+
}(r);
|
|
1068
1068
|
if (true && e.exports) {
|
|
1069
|
-
e.exports =
|
|
1069
|
+
e.exports = a;
|
|
1070
1070
|
}
|
|
1071
1071
|
// hack for components to work correctly in node.js
|
|
1072
1072
|
if (typeof n !== "undefined") {
|
|
1073
|
-
n.Prism =
|
|
1073
|
+
n.Prism = a;
|
|
1074
1074
|
}
|
|
1075
1075
|
// some additional documentation/types
|
|
1076
1076
|
/**
|
|
@@ -1117,7 +1117,7 @@
|
|
|
1117
1117
|
* @public
|
|
1118
1118
|
*/
|
|
1119
1119
|
// https://www.json.org/json-en.html
|
|
1120
|
-
|
|
1120
|
+
a.languages.json = {
|
|
1121
1121
|
property: {
|
|
1122
1122
|
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
1123
1123
|
lookbehind: true,
|
|
@@ -1141,8 +1141,8 @@
|
|
|
1141
1141
|
alias: "keyword"
|
|
1142
1142
|
}
|
|
1143
1143
|
};
|
|
1144
|
-
|
|
1145
|
-
|
|
1144
|
+
a.languages.webmanifest = a.languages.json;
|
|
1145
|
+
a.languages.markup = {
|
|
1146
1146
|
comment: {
|
|
1147
1147
|
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
1148
1148
|
greedy: true
|
|
@@ -1213,15 +1213,15 @@
|
|
|
1213
1213
|
alias: "named-entity"
|
|
1214
1214
|
}, /&#x?[\da-f]{1,8};/i ]
|
|
1215
1215
|
};
|
|
1216
|
-
|
|
1217
|
-
|
|
1216
|
+
a.languages.markup["tag"].inside["attr-value"].inside["entity"] = a.languages.markup["entity"];
|
|
1217
|
+
a.languages.markup["doctype"].inside["internal-subset"].inside = a.languages.markup;
|
|
1218
1218
|
// Plugin to make entity title show the real entity, idea by Roman Komarov
|
|
1219
|
-
|
|
1219
|
+
a.hooks.add("wrap", (function(e) {
|
|
1220
1220
|
if (e.type === "entity") {
|
|
1221
1221
|
e.attributes["title"] = e.content.replace(/&/, "&");
|
|
1222
1222
|
}
|
|
1223
1223
|
}));
|
|
1224
|
-
Object.defineProperty(
|
|
1224
|
+
Object.defineProperty(a.languages.markup.tag, "addInlined", {
|
|
1225
1225
|
/**
|
|
1226
1226
|
* Adds an inlined language to markup.
|
|
1227
1227
|
*
|
|
@@ -1234,36 +1234,36 @@
|
|
|
1234
1234
|
* addInlined('style', 'css');
|
|
1235
1235
|
*/
|
|
1236
1236
|
value: function e(t, n) {
|
|
1237
|
-
var
|
|
1238
|
-
|
|
1237
|
+
var r = {};
|
|
1238
|
+
r["language-" + n] = {
|
|
1239
1239
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1240
1240
|
lookbehind: true,
|
|
1241
|
-
inside:
|
|
1241
|
+
inside: a.languages[n]
|
|
1242
1242
|
};
|
|
1243
|
-
|
|
1244
|
-
var
|
|
1243
|
+
r["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
|
|
1244
|
+
var s = {
|
|
1245
1245
|
"included-cdata": {
|
|
1246
1246
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1247
|
-
inside:
|
|
1247
|
+
inside: r
|
|
1248
1248
|
}
|
|
1249
1249
|
};
|
|
1250
|
-
|
|
1250
|
+
s["language-" + n] = {
|
|
1251
1251
|
pattern: /[\s\S]+/,
|
|
1252
|
-
inside:
|
|
1252
|
+
inside: a.languages[n]
|
|
1253
1253
|
};
|
|
1254
|
-
var
|
|
1255
|
-
|
|
1254
|
+
var i = {};
|
|
1255
|
+
i[t] = {
|
|
1256
1256
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, (function() {
|
|
1257
1257
|
return t;
|
|
1258
1258
|
})), "i"),
|
|
1259
1259
|
lookbehind: true,
|
|
1260
1260
|
greedy: true,
|
|
1261
|
-
inside:
|
|
1261
|
+
inside: s
|
|
1262
1262
|
};
|
|
1263
|
-
|
|
1263
|
+
a.languages.insertBefore("markup", "cdata", i);
|
|
1264
1264
|
}
|
|
1265
1265
|
});
|
|
1266
|
-
Object.defineProperty(
|
|
1266
|
+
Object.defineProperty(a.languages.markup.tag, "addAttribute", {
|
|
1267
1267
|
/**
|
|
1268
1268
|
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
1269
1269
|
*
|
|
@@ -1276,7 +1276,7 @@
|
|
|
1276
1276
|
* addAttribute('style', 'css');
|
|
1277
1277
|
*/
|
|
1278
1278
|
value: function(e, t) {
|
|
1279
|
-
|
|
1279
|
+
a.languages.markup.tag.inside["special-attr"].push({
|
|
1280
1280
|
pattern: RegExp(/(^|["'\s])/.source + "(?:" + e + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, "i"),
|
|
1281
1281
|
lookbehind: true,
|
|
1282
1282
|
inside: {
|
|
@@ -1288,7 +1288,7 @@
|
|
|
1288
1288
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1289
1289
|
lookbehind: true,
|
|
1290
1290
|
alias: [ t, "language-" + t ],
|
|
1291
|
-
inside:
|
|
1291
|
+
inside: a.languages[t]
|
|
1292
1292
|
},
|
|
1293
1293
|
punctuation: [ {
|
|
1294
1294
|
pattern: /^=/,
|
|
@@ -1300,14 +1300,14 @@
|
|
|
1300
1300
|
});
|
|
1301
1301
|
}
|
|
1302
1302
|
});
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1303
|
+
a.languages.html = a.languages.markup;
|
|
1304
|
+
a.languages.mathml = a.languages.markup;
|
|
1305
|
+
a.languages.svg = a.languages.markup;
|
|
1306
|
+
a.languages.xml = a.languages.extend("markup", {});
|
|
1307
|
+
a.languages.ssml = a.languages.xml;
|
|
1308
|
+
a.languages.atom = a.languages.xml;
|
|
1309
|
+
a.languages.rss = a.languages.xml;
|
|
1310
|
+
a.languages.clike = {
|
|
1311
1311
|
comment: [ {
|
|
1312
1312
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1313
1313
|
lookbehind: true,
|
|
@@ -1335,8 +1335,8 @@
|
|
|
1335
1335
|
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1336
1336
|
punctuation: /[{}[\];(),.:]/
|
|
1337
1337
|
};
|
|
1338
|
-
|
|
1339
|
-
"class-name": [
|
|
1338
|
+
a.languages.javascript = a.languages.extend("clike", {
|
|
1339
|
+
"class-name": [ a.languages.clike["class-name"], {
|
|
1340
1340
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1341
1341
|
lookbehind: true
|
|
1342
1342
|
} ],
|
|
@@ -1367,8 +1367,8 @@
|
|
|
1367
1367
|
},
|
|
1368
1368
|
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1369
1369
|
});
|
|
1370
|
-
|
|
1371
|
-
|
|
1370
|
+
a.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
1371
|
+
a.languages.insertBefore("javascript", "keyword", {
|
|
1372
1372
|
regex: {
|
|
1373
1373
|
pattern: RegExp(
|
|
1374
1374
|
// lookbehind
|
|
@@ -1390,7 +1390,7 @@
|
|
|
1390
1390
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1391
1391
|
lookbehind: true,
|
|
1392
1392
|
alias: "language-regex",
|
|
1393
|
-
inside:
|
|
1393
|
+
inside: a.languages.regex
|
|
1394
1394
|
},
|
|
1395
1395
|
"regex-delimiter": /^\/|\/$/,
|
|
1396
1396
|
"regex-flags": /^[a-z]+$/
|
|
@@ -1404,23 +1404,23 @@
|
|
|
1404
1404
|
parameter: [ {
|
|
1405
1405
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1406
1406
|
lookbehind: true,
|
|
1407
|
-
inside:
|
|
1407
|
+
inside: a.languages.javascript
|
|
1408
1408
|
}, {
|
|
1409
1409
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1410
1410
|
lookbehind: true,
|
|
1411
|
-
inside:
|
|
1411
|
+
inside: a.languages.javascript
|
|
1412
1412
|
}, {
|
|
1413
1413
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1414
1414
|
lookbehind: true,
|
|
1415
|
-
inside:
|
|
1415
|
+
inside: a.languages.javascript
|
|
1416
1416
|
}, {
|
|
1417
1417
|
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*\{)/,
|
|
1418
1418
|
lookbehind: true,
|
|
1419
|
-
inside:
|
|
1419
|
+
inside: a.languages.javascript
|
|
1420
1420
|
} ],
|
|
1421
1421
|
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1422
1422
|
});
|
|
1423
|
-
|
|
1423
|
+
a.languages.insertBefore("javascript", "string", {
|
|
1424
1424
|
hashbang: {
|
|
1425
1425
|
pattern: /^#!.*/,
|
|
1426
1426
|
greedy: true,
|
|
@@ -1442,7 +1442,7 @@
|
|
|
1442
1442
|
pattern: /^\$\{|\}$/,
|
|
1443
1443
|
alias: "punctuation"
|
|
1444
1444
|
},
|
|
1445
|
-
rest:
|
|
1445
|
+
rest: a.languages.javascript
|
|
1446
1446
|
}
|
|
1447
1447
|
},
|
|
1448
1448
|
string: /[\s\S]+/
|
|
@@ -1455,55 +1455,55 @@
|
|
|
1455
1455
|
alias: "property"
|
|
1456
1456
|
}
|
|
1457
1457
|
});
|
|
1458
|
-
|
|
1458
|
+
a.languages.insertBefore("javascript", "operator", {
|
|
1459
1459
|
"literal-property": {
|
|
1460
1460
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1461
1461
|
lookbehind: true,
|
|
1462
1462
|
alias: "property"
|
|
1463
1463
|
}
|
|
1464
1464
|
});
|
|
1465
|
-
if (
|
|
1466
|
-
|
|
1465
|
+
if (a.languages.markup) {
|
|
1466
|
+
a.languages.markup.tag.addInlined("script", "javascript");
|
|
1467
1467
|
// add attribute support for all DOM events.
|
|
1468
1468
|
// https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
|
|
1469
|
-
|
|
1469
|
+
a.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, "javascript");
|
|
1470
1470
|
}
|
|
1471
|
-
|
|
1471
|
+
a.languages.js = a.languages.javascript;
|
|
1472
1472
|
(function(e) {
|
|
1473
1473
|
var t = e.util.clone(e.languages.javascript);
|
|
1474
1474
|
var n = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
|
|
1475
|
-
var
|
|
1476
|
-
var
|
|
1475
|
+
var r = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
|
|
1476
|
+
var a = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
|
|
1477
1477
|
/**
|
|
1478
1478
|
* @param {string} source
|
|
1479
1479
|
* @param {string} [flags]
|
|
1480
|
-
*/ function
|
|
1480
|
+
*/ function s(e, t) {
|
|
1481
1481
|
e = e.replace(/<S>/g, (function() {
|
|
1482
1482
|
return n;
|
|
1483
1483
|
})).replace(/<BRACES>/g, (function() {
|
|
1484
|
-
return a;
|
|
1485
|
-
})).replace(/<SPREAD>/g, (function() {
|
|
1486
1484
|
return r;
|
|
1485
|
+
})).replace(/<SPREAD>/g, (function() {
|
|
1486
|
+
return a;
|
|
1487
1487
|
}));
|
|
1488
1488
|
return RegExp(e, t);
|
|
1489
1489
|
}
|
|
1490
|
-
|
|
1490
|
+
a = s(a).source;
|
|
1491
1491
|
e.languages.jsx = e.languages.extend("markup", t);
|
|
1492
|
-
e.languages.jsx.tag.pattern =
|
|
1492
|
+
e.languages.jsx.tag.pattern = s(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source);
|
|
1493
1493
|
e.languages.jsx.tag.inside["tag"].pattern = /^<\/?[^\s>\/]*/;
|
|
1494
1494
|
e.languages.jsx.tag.inside["attr-value"].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
|
|
1495
1495
|
e.languages.jsx.tag.inside["tag"].inside["class-name"] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
|
|
1496
1496
|
e.languages.jsx.tag.inside["comment"] = t["comment"];
|
|
1497
1497
|
e.languages.insertBefore("inside", "attr-name", {
|
|
1498
1498
|
spread: {
|
|
1499
|
-
pattern:
|
|
1499
|
+
pattern: s(/<SPREAD>/.source),
|
|
1500
1500
|
inside: e.languages.jsx
|
|
1501
1501
|
}
|
|
1502
1502
|
}, e.languages.jsx.tag);
|
|
1503
1503
|
e.languages.insertBefore("inside", "special-attr", {
|
|
1504
1504
|
script: {
|
|
1505
1505
|
// Allow for two levels of nesting
|
|
1506
|
-
pattern:
|
|
1506
|
+
pattern: s(/=<BRACES>/.source),
|
|
1507
1507
|
alias: "language-javascript",
|
|
1508
1508
|
inside: {
|
|
1509
1509
|
"script-punctuation": {
|
|
@@ -1515,7 +1515,7 @@
|
|
|
1515
1515
|
}
|
|
1516
1516
|
}, e.languages.jsx.tag);
|
|
1517
1517
|
// The following will handle plain text inside tags
|
|
1518
|
-
var
|
|
1518
|
+
var i = function(e) {
|
|
1519
1519
|
if (!e) {
|
|
1520
1520
|
return "";
|
|
1521
1521
|
}
|
|
@@ -1525,63 +1525,63 @@
|
|
|
1525
1525
|
if (typeof e.content === "string") {
|
|
1526
1526
|
return e.content;
|
|
1527
1527
|
}
|
|
1528
|
-
return e.content.map(
|
|
1528
|
+
return e.content.map(i).join("");
|
|
1529
1529
|
};
|
|
1530
1530
|
var o = function(t) {
|
|
1531
1531
|
var n = [];
|
|
1532
|
-
for (var
|
|
1533
|
-
var
|
|
1534
|
-
var
|
|
1535
|
-
if (typeof
|
|
1536
|
-
if (
|
|
1532
|
+
for (var r = 0; r < t.length; r++) {
|
|
1533
|
+
var a = t[r];
|
|
1534
|
+
var s = false;
|
|
1535
|
+
if (typeof a !== "string") {
|
|
1536
|
+
if (a.type === "tag" && a.content[0] && a.content[0].type === "tag") {
|
|
1537
1537
|
// We found a tag, now find its kind
|
|
1538
|
-
if (
|
|
1538
|
+
if (a.content[0].content[0].content === "</") {
|
|
1539
1539
|
// Closing tag
|
|
1540
|
-
if (n.length > 0 && n[n.length - 1].tagName ===
|
|
1540
|
+
if (n.length > 0 && n[n.length - 1].tagName === i(a.content[0].content[1])) {
|
|
1541
1541
|
// Pop matching opening tag
|
|
1542
1542
|
n.pop();
|
|
1543
1543
|
}
|
|
1544
1544
|
} else {
|
|
1545
|
-
if (
|
|
1545
|
+
if (a.content[a.content.length - 1].content === "/>") {
|
|
1546
1546
|
// Autoclosed tag, ignore
|
|
1547
1547
|
} else {
|
|
1548
1548
|
// Opening tag
|
|
1549
1549
|
n.push({
|
|
1550
|
-
tagName:
|
|
1550
|
+
tagName: i(a.content[0].content[1]),
|
|
1551
1551
|
openedBraces: 0
|
|
1552
1552
|
});
|
|
1553
1553
|
}
|
|
1554
1554
|
}
|
|
1555
|
-
} else if (n.length > 0 &&
|
|
1555
|
+
} else if (n.length > 0 && a.type === "punctuation" && a.content === "{") {
|
|
1556
1556
|
// Here we might have entered a JSX context inside a tag
|
|
1557
1557
|
n[n.length - 1].openedBraces++;
|
|
1558
|
-
} else if (n.length > 0 && n[n.length - 1].openedBraces > 0 &&
|
|
1558
|
+
} else if (n.length > 0 && n[n.length - 1].openedBraces > 0 && a.type === "punctuation" && a.content === "}") {
|
|
1559
1559
|
// Here we might have left a JSX context inside a tag
|
|
1560
1560
|
n[n.length - 1].openedBraces--;
|
|
1561
1561
|
} else {
|
|
1562
|
-
|
|
1562
|
+
s = true;
|
|
1563
1563
|
}
|
|
1564
1564
|
}
|
|
1565
|
-
if (
|
|
1565
|
+
if (s || typeof a === "string") {
|
|
1566
1566
|
if (n.length > 0 && n[n.length - 1].openedBraces === 0) {
|
|
1567
1567
|
// Here we are inside a tag, and not inside a JSX context.
|
|
1568
1568
|
// That's plain text: drop any tokens matched.
|
|
1569
|
-
var l =
|
|
1569
|
+
var l = i(a);
|
|
1570
1570
|
// And merge text with adjacent text
|
|
1571
|
-
if (
|
|
1572
|
-
l +=
|
|
1573
|
-
t.splice(
|
|
1571
|
+
if (r < t.length - 1 && (typeof t[r + 1] === "string" || t[r + 1].type === "plain-text")) {
|
|
1572
|
+
l += i(t[r + 1]);
|
|
1573
|
+
t.splice(r + 1, 1);
|
|
1574
1574
|
}
|
|
1575
|
-
if (
|
|
1576
|
-
l =
|
|
1577
|
-
t.splice(
|
|
1578
|
-
|
|
1575
|
+
if (r > 0 && (typeof t[r - 1] === "string" || t[r - 1].type === "plain-text")) {
|
|
1576
|
+
l = i(t[r - 1]) + l;
|
|
1577
|
+
t.splice(r - 1, 1);
|
|
1578
|
+
r--;
|
|
1579
1579
|
}
|
|
1580
|
-
t[
|
|
1580
|
+
t[r] = new e.Token("plain-text", l, null, l);
|
|
1581
1581
|
}
|
|
1582
1582
|
}
|
|
1583
|
-
if (
|
|
1584
|
-
o(
|
|
1583
|
+
if (a.content && typeof a.content !== "string") {
|
|
1584
|
+
o(a.content);
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
1587
1587
|
};
|
|
@@ -1591,7 +1591,7 @@
|
|
|
1591
1591
|
}
|
|
1592
1592
|
o(e.tokens);
|
|
1593
1593
|
}));
|
|
1594
|
-
})(
|
|
1594
|
+
})(a);
|
|
1595
1595
|
(function(e) {
|
|
1596
1596
|
e.languages.typescript = e.languages.extend("javascript", {
|
|
1597
1597
|
"class-name": {
|
|
@@ -1642,7 +1642,7 @@
|
|
|
1642
1642
|
}
|
|
1643
1643
|
});
|
|
1644
1644
|
e.languages.ts = e.languages.typescript;
|
|
1645
|
-
})(
|
|
1645
|
+
})(a);
|
|
1646
1646
|
(function(e) {
|
|
1647
1647
|
var t = e.util.clone(e.languages.typescript);
|
|
1648
1648
|
e.languages.tsx = e.languages.extend("jsx", t);
|
|
@@ -1655,7 +1655,7 @@
|
|
|
1655
1655
|
var n = e.languages.tsx.tag;
|
|
1656
1656
|
n.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + "(?:" + n.pattern.source + ")", n.pattern.flags);
|
|
1657
1657
|
n.lookbehind = true;
|
|
1658
|
-
})(
|
|
1658
|
+
})(a);
|
|
1659
1659
|
(function(e) {
|
|
1660
1660
|
var t = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1661
1661
|
e.languages.css = {
|
|
@@ -1713,7 +1713,7 @@
|
|
|
1713
1713
|
n.tag.addInlined("style", "css");
|
|
1714
1714
|
n.tag.addAttribute("style", "css");
|
|
1715
1715
|
}
|
|
1716
|
-
})(
|
|
1716
|
+
})(a);
|
|
1717
1717
|
(function(e) {
|
|
1718
1718
|
// $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
|
|
1719
1719
|
// + LC_ALL, RANDOM, REPLY, SECONDS.
|
|
@@ -1727,7 +1727,7 @@
|
|
|
1727
1727
|
// this looks reasonably well in all themes
|
|
1728
1728
|
inside: null
|
|
1729
1729
|
};
|
|
1730
|
-
var
|
|
1730
|
+
var r = {
|
|
1731
1731
|
bash: n,
|
|
1732
1732
|
environment: {
|
|
1733
1733
|
pattern: RegExp("\\$" + t),
|
|
@@ -1832,7 +1832,7 @@
|
|
|
1832
1832
|
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
1833
1833
|
lookbehind: true,
|
|
1834
1834
|
greedy: true,
|
|
1835
|
-
inside:
|
|
1835
|
+
inside: r
|
|
1836
1836
|
},
|
|
1837
1837
|
// Here-document with quotes around the tag
|
|
1838
1838
|
// → No expansion (so no “inside”).
|
|
@@ -1850,7 +1850,7 @@
|
|
|
1850
1850
|
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
1851
1851
|
lookbehind: true,
|
|
1852
1852
|
greedy: true,
|
|
1853
|
-
inside:
|
|
1853
|
+
inside: r
|
|
1854
1854
|
}, {
|
|
1855
1855
|
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
1856
1856
|
pattern: /(^|[^$\\])'[^']*'/,
|
|
@@ -1861,14 +1861,14 @@
|
|
|
1861
1861
|
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
1862
1862
|
greedy: true,
|
|
1863
1863
|
inside: {
|
|
1864
|
-
entity:
|
|
1864
|
+
entity: r.entity
|
|
1865
1865
|
}
|
|
1866
1866
|
} ],
|
|
1867
1867
|
environment: {
|
|
1868
1868
|
pattern: RegExp("\\$?" + t),
|
|
1869
1869
|
alias: "constant"
|
|
1870
1870
|
},
|
|
1871
|
-
variable:
|
|
1871
|
+
variable: r.variable,
|
|
1872
1872
|
function: {
|
|
1873
1873
|
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;|&])/,
|
|
1874
1874
|
lookbehind: true
|
|
@@ -1909,14 +1909,14 @@
|
|
|
1909
1909
|
}
|
|
1910
1910
|
};
|
|
1911
1911
|
n.inside = e.languages.bash;
|
|
1912
|
-
/* Patterns in command substitution. */ var
|
|
1913
|
-
var
|
|
1914
|
-
for (var
|
|
1915
|
-
|
|
1912
|
+
/* Patterns in command substitution. */ var a = [ "comment", "function-name", "for-or-select", "assign-left", "parameter", "string", "environment", "function", "keyword", "builtin", "boolean", "file-descriptor", "operator", "punctuation", "number" ];
|
|
1913
|
+
var s = r.variable[1].inside;
|
|
1914
|
+
for (var i = 0; i < a.length; i++) {
|
|
1915
|
+
s[a[i]] = e.languages.bash[a[i]];
|
|
1916
1916
|
}
|
|
1917
1917
|
e.languages.sh = e.languages.bash;
|
|
1918
1918
|
e.languages.shell = e.languages.bash;
|
|
1919
|
-
})(
|
|
1919
|
+
})(a);
|
|
1920
1920
|
(function(e) {
|
|
1921
1921
|
// https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
|
|
1922
1922
|
// https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
|
|
@@ -1924,24 +1924,24 @@
|
|
|
1924
1924
|
// https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
|
|
1925
1925
|
var n = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
|
|
1926
1926
|
// https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
|
|
1927
|
-
var
|
|
1927
|
+
var r = "(?:" + n.source + "(?:[ \t]+" + t.source + ")?|" + t.source + "(?:[ \t]+" + n.source + ")?)";
|
|
1928
1928
|
// https://yaml.org/spec/1.2/spec.html#ns-plain(n,c)
|
|
1929
1929
|
// This is a simplified version that doesn't support "#" and multiline keys
|
|
1930
1930
|
// All these long scarry character classes are simplified versions of YAML's characters
|
|
1931
|
-
var
|
|
1931
|
+
var a = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, (function() {
|
|
1932
1932
|
return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
|
|
1933
1933
|
}));
|
|
1934
|
-
var
|
|
1934
|
+
var s = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
|
|
1935
1935
|
/**
|
|
1936
1936
|
*
|
|
1937
1937
|
* @param {string} value
|
|
1938
1938
|
* @param {string} [flags]
|
|
1939
1939
|
* @returns {RegExp}
|
|
1940
|
-
*/ function
|
|
1940
|
+
*/ function i(e, t) {
|
|
1941
1941
|
t = (t || "").replace(/m/g, "") + "m";
|
|
1942
1942
|
// add m flag
|
|
1943
1943
|
var n = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, (function() {
|
|
1944
|
-
return
|
|
1944
|
+
return r;
|
|
1945
1945
|
})).replace(/<<value>>/g, (function() {
|
|
1946
1946
|
return e;
|
|
1947
1947
|
}));
|
|
@@ -1950,7 +1950,7 @@
|
|
|
1950
1950
|
e.languages.yaml = {
|
|
1951
1951
|
scalar: {
|
|
1952
1952
|
pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, (function() {
|
|
1953
|
-
return
|
|
1953
|
+
return r;
|
|
1954
1954
|
}))),
|
|
1955
1955
|
lookbehind: true,
|
|
1956
1956
|
alias: "string"
|
|
@@ -1958,9 +1958,9 @@
|
|
|
1958
1958
|
comment: /#.*/,
|
|
1959
1959
|
key: {
|
|
1960
1960
|
pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, (function() {
|
|
1961
|
-
return
|
|
1961
|
+
return r;
|
|
1962
1962
|
})).replace(/<<key>>/g, (function() {
|
|
1963
|
-
return "(?:" +
|
|
1963
|
+
return "(?:" + a + "|" + s + ")";
|
|
1964
1964
|
}))),
|
|
1965
1965
|
lookbehind: true,
|
|
1966
1966
|
greedy: true,
|
|
@@ -1972,27 +1972,27 @@
|
|
|
1972
1972
|
alias: "important"
|
|
1973
1973
|
},
|
|
1974
1974
|
datetime: {
|
|
1975
|
-
pattern:
|
|
1975
|
+
pattern: i(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
|
|
1976
1976
|
lookbehind: true,
|
|
1977
1977
|
alias: "number"
|
|
1978
1978
|
},
|
|
1979
1979
|
boolean: {
|
|
1980
|
-
pattern:
|
|
1980
|
+
pattern: i(/false|true/.source, "i"),
|
|
1981
1981
|
lookbehind: true,
|
|
1982
1982
|
alias: "important"
|
|
1983
1983
|
},
|
|
1984
1984
|
null: {
|
|
1985
|
-
pattern:
|
|
1985
|
+
pattern: i(/null|~/.source, "i"),
|
|
1986
1986
|
lookbehind: true,
|
|
1987
1987
|
alias: "important"
|
|
1988
1988
|
},
|
|
1989
1989
|
string: {
|
|
1990
|
-
pattern: s
|
|
1990
|
+
pattern: i(s),
|
|
1991
1991
|
lookbehind: true,
|
|
1992
1992
|
greedy: true
|
|
1993
1993
|
},
|
|
1994
1994
|
number: {
|
|
1995
|
-
pattern:
|
|
1995
|
+
pattern: i(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, "i"),
|
|
1996
1996
|
lookbehind: true
|
|
1997
1997
|
},
|
|
1998
1998
|
tag: n,
|
|
@@ -2000,8 +2000,8 @@
|
|
|
2000
2000
|
punctuation: /---|[:[\]{}\-,|>?]|\.\.\./
|
|
2001
2001
|
};
|
|
2002
2002
|
e.languages.yml = e.languages.yaml;
|
|
2003
|
-
})(
|
|
2004
|
-
|
|
2003
|
+
})(a);
|
|
2004
|
+
a.languages["splunk-spl"] = {
|
|
2005
2005
|
comment: /`comment\("(?:\\.|[^\\"])*"\)`/,
|
|
2006
2006
|
string: {
|
|
2007
2007
|
pattern: /"(?:\\.|[^\\"])*"/,
|
|
@@ -2025,7 +2025,7 @@
|
|
|
2025
2025
|
operator: /[<>=]=?|[-+*/%|]/,
|
|
2026
2026
|
punctuation: /[()[\],]/
|
|
2027
2027
|
};
|
|
2028
|
-
|
|
2028
|
+
a.languages.sql = {
|
|
2029
2029
|
comment: {
|
|
2030
2030
|
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
|
2031
2031
|
lookbehind: true
|
|
@@ -2055,6 +2055,603 @@
|
|
|
2055
2055
|
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
2056
2056
|
punctuation: /[;[\]()`,.]/
|
|
2057
2057
|
};
|
|
2058
|
+
a.languages.c = a.languages.extend("clike", {
|
|
2059
|
+
comment: {
|
|
2060
|
+
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2061
|
+
greedy: true
|
|
2062
|
+
},
|
|
2063
|
+
string: {
|
|
2064
|
+
// https://en.cppreference.com/w/c/language/string_literal
|
|
2065
|
+
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
2066
|
+
greedy: true
|
|
2067
|
+
},
|
|
2068
|
+
"class-name": {
|
|
2069
|
+
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
2070
|
+
lookbehind: true
|
|
2071
|
+
},
|
|
2072
|
+
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/,
|
|
2073
|
+
function: /\b[a-z_]\w*(?=\s*\()/i,
|
|
2074
|
+
number: /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
2075
|
+
operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
2076
|
+
});
|
|
2077
|
+
a.languages.insertBefore("c", "string", {
|
|
2078
|
+
char: {
|
|
2079
|
+
// https://en.cppreference.com/w/c/language/character_constant
|
|
2080
|
+
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
2081
|
+
greedy: true
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
a.languages.insertBefore("c", "string", {
|
|
2085
|
+
macro: {
|
|
2086
|
+
// allow for multiline macro definitions
|
|
2087
|
+
// spaces after the # character compile fine with gcc
|
|
2088
|
+
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
2089
|
+
lookbehind: true,
|
|
2090
|
+
greedy: true,
|
|
2091
|
+
alias: "property",
|
|
2092
|
+
inside: {
|
|
2093
|
+
string: [ {
|
|
2094
|
+
// highlight the path of the include statement as a string
|
|
2095
|
+
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
2096
|
+
lookbehind: true
|
|
2097
|
+
}, a.languages.c["string"] ],
|
|
2098
|
+
char: a.languages.c["char"],
|
|
2099
|
+
comment: a.languages.c["comment"],
|
|
2100
|
+
"macro-name": [ {
|
|
2101
|
+
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
2102
|
+
lookbehind: true
|
|
2103
|
+
}, {
|
|
2104
|
+
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
2105
|
+
lookbehind: true,
|
|
2106
|
+
alias: "function"
|
|
2107
|
+
} ],
|
|
2108
|
+
// highlight macro directives as keywords
|
|
2109
|
+
directive: {
|
|
2110
|
+
pattern: /^(#\s*)[a-z]+/,
|
|
2111
|
+
lookbehind: true,
|
|
2112
|
+
alias: "keyword"
|
|
2113
|
+
},
|
|
2114
|
+
"directive-hash": /^#/,
|
|
2115
|
+
punctuation: /##|\\(?=[\r\n])/,
|
|
2116
|
+
expression: {
|
|
2117
|
+
pattern: /\S[\s\S]*/,
|
|
2118
|
+
inside: a.languages.c
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
});
|
|
2123
|
+
a.languages.insertBefore("c", "function", {
|
|
2124
|
+
// highlight predefined macros as constants
|
|
2125
|
+
constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
2126
|
+
});
|
|
2127
|
+
delete a.languages.c["boolean"];
|
|
2128
|
+
(function(e) {
|
|
2129
|
+
var t = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
|
|
2130
|
+
var n = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, (function() {
|
|
2131
|
+
return t.source;
|
|
2132
|
+
}));
|
|
2133
|
+
e.languages.cpp = e.languages.extend("c", {
|
|
2134
|
+
"class-name": [ {
|
|
2135
|
+
pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g, (function() {
|
|
2136
|
+
return t.source;
|
|
2137
|
+
}))),
|
|
2138
|
+
lookbehind: true
|
|
2139
|
+
},
|
|
2140
|
+
// This is intended to capture the class name of method implementations like:
|
|
2141
|
+
// void foo::bar() const {}
|
|
2142
|
+
// However! The `foo` in the above example could also be a namespace, so we only capture the class name if
|
|
2143
|
+
// it starts with an uppercase letter. This approximation should give decent results.
|
|
2144
|
+
/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
|
|
2145
|
+
// This will capture the class name before destructors like:
|
|
2146
|
+
// Foo::~Foo() {}
|
|
2147
|
+
/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
|
|
2148
|
+
// This also intends to capture the class name of method implementations but here the class has template
|
|
2149
|
+
// parameters, so it can't be a namespace (until C++ adds generic namespaces).
|
|
2150
|
+
/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/ ],
|
|
2151
|
+
keyword: t,
|
|
2152
|
+
number: {
|
|
2153
|
+
pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
|
|
2154
|
+
greedy: true
|
|
2155
|
+
},
|
|
2156
|
+
operator: />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
|
|
2157
|
+
boolean: /\b(?:false|true)\b/
|
|
2158
|
+
});
|
|
2159
|
+
e.languages.insertBefore("cpp", "string", {
|
|
2160
|
+
module: {
|
|
2161
|
+
// https://en.cppreference.com/w/cpp/language/modules
|
|
2162
|
+
pattern: RegExp(/(\b(?:import|module)\s+)/.source + "(?:" +
|
|
2163
|
+
// header-name
|
|
2164
|
+
/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + "|" +
|
|
2165
|
+
// module name or partition or both
|
|
2166
|
+
/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, (function() {
|
|
2167
|
+
return n;
|
|
2168
|
+
})) + ")"),
|
|
2169
|
+
lookbehind: true,
|
|
2170
|
+
greedy: true,
|
|
2171
|
+
inside: {
|
|
2172
|
+
string: /^[<"][\s\S]+/,
|
|
2173
|
+
operator: /:/,
|
|
2174
|
+
punctuation: /\./
|
|
2175
|
+
}
|
|
2176
|
+
},
|
|
2177
|
+
"raw-string": {
|
|
2178
|
+
pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
|
|
2179
|
+
alias: "string",
|
|
2180
|
+
greedy: true
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
e.languages.insertBefore("cpp", "keyword", {
|
|
2184
|
+
"generic-function": {
|
|
2185
|
+
pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
|
|
2186
|
+
inside: {
|
|
2187
|
+
function: /^\w+/,
|
|
2188
|
+
generic: {
|
|
2189
|
+
pattern: /<[\s\S]+/,
|
|
2190
|
+
alias: "class-name",
|
|
2191
|
+
inside: e.languages.cpp
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
e.languages.insertBefore("cpp", "operator", {
|
|
2197
|
+
"double-colon": {
|
|
2198
|
+
pattern: /::/,
|
|
2199
|
+
alias: "punctuation"
|
|
2200
|
+
}
|
|
2201
|
+
});
|
|
2202
|
+
e.languages.insertBefore("cpp", "class-name", {
|
|
2203
|
+
// the base clause is an optional list of parent classes
|
|
2204
|
+
// https://en.cppreference.com/w/cpp/language/class
|
|
2205
|
+
"base-clause": {
|
|
2206
|
+
pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
|
|
2207
|
+
lookbehind: true,
|
|
2208
|
+
greedy: true,
|
|
2209
|
+
inside: e.languages.extend("cpp", {})
|
|
2210
|
+
}
|
|
2211
|
+
});
|
|
2212
|
+
e.languages.insertBefore("inside", "double-colon", {
|
|
2213
|
+
// All untokenized words that are not namespaces should be class names
|
|
2214
|
+
"class-name": /\b[a-z_]\w*\b(?!\s*::)/i
|
|
2215
|
+
}, e.languages.cpp["base-clause"]);
|
|
2216
|
+
})(a);
|
|
2217
|
+
(function(e) {
|
|
2218
|
+
/**
|
|
2219
|
+
* Replaces all placeholders "<<n>>" of given pattern with the n-th replacement (zero based).
|
|
2220
|
+
*
|
|
2221
|
+
* Note: This is a simple text based replacement. Be careful when using backreferences!
|
|
2222
|
+
*
|
|
2223
|
+
* @param {string} pattern the given pattern.
|
|
2224
|
+
* @param {string[]} replacements a list of replacement which can be inserted into the given pattern.
|
|
2225
|
+
* @returns {string} the pattern with all placeholders replaced with their corresponding replacements.
|
|
2226
|
+
* @example replace(/a<<0>>a/.source, [/b+/.source]) === /a(?:b+)a/.source
|
|
2227
|
+
*/
|
|
2228
|
+
function t(e, t) {
|
|
2229
|
+
return e.replace(/<<(\d+)>>/g, (function(e, n) {
|
|
2230
|
+
return "(?:" + t[+n] + ")";
|
|
2231
|
+
}));
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* @param {string} pattern
|
|
2235
|
+
* @param {string[]} replacements
|
|
2236
|
+
* @param {string} [flags]
|
|
2237
|
+
* @returns {RegExp}
|
|
2238
|
+
*/ function n(e, n, r) {
|
|
2239
|
+
return RegExp(t(e, n), r || "");
|
|
2240
|
+
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Creates a nested pattern where all occurrences of the string `<<self>>` are replaced with the pattern itself.
|
|
2243
|
+
*
|
|
2244
|
+
* @param {string} pattern
|
|
2245
|
+
* @param {number} depthLog2
|
|
2246
|
+
* @returns {string}
|
|
2247
|
+
*/ function r(e, t) {
|
|
2248
|
+
for (var n = 0; n < t; n++) {
|
|
2249
|
+
e = e.replace(/<<self>>/g, (function() {
|
|
2250
|
+
return "(?:" + e + ")";
|
|
2251
|
+
}));
|
|
2252
|
+
}
|
|
2253
|
+
return e.replace(/<<self>>/g, "[^\\s\\S]");
|
|
2254
|
+
}
|
|
2255
|
+
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
|
|
2256
|
+
var a = {
|
|
2257
|
+
// keywords which represent a return or variable type
|
|
2258
|
+
type: "bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void",
|
|
2259
|
+
// keywords which are used to declare a type
|
|
2260
|
+
typeDeclaration: "class enum interface record struct",
|
|
2261
|
+
// contextual keywords
|
|
2262
|
+
// ("var" and "dynamic" are missing because they are used like types)
|
|
2263
|
+
contextual: "add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)",
|
|
2264
|
+
// all other keywords
|
|
2265
|
+
other: "abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield"
|
|
2266
|
+
};
|
|
2267
|
+
// keywords
|
|
2268
|
+
function s(e) {
|
|
2269
|
+
return "\\b(?:" + e.trim().replace(/ /g, "|") + ")\\b";
|
|
2270
|
+
}
|
|
2271
|
+
var i = s(a.typeDeclaration);
|
|
2272
|
+
var o = RegExp(s(a.type + " " + a.typeDeclaration + " " + a.contextual + " " + a.other));
|
|
2273
|
+
var l = s(a.typeDeclaration + " " + a.contextual + " " + a.other);
|
|
2274
|
+
var u = s(a.type + " " + a.typeDeclaration + " " + a.other);
|
|
2275
|
+
// types
|
|
2276
|
+
var c = r(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source, 2);
|
|
2277
|
+
// the idea behind the other forbidden characters is to prevent false positives. Same for tupleElement.
|
|
2278
|
+
var p = r(/\((?:[^()]|<<self>>)*\)/.source, 2);
|
|
2279
|
+
var d = /@?\b[A-Za-z_]\w*\b/.source;
|
|
2280
|
+
var g = t(/<<0>>(?:\s*<<1>>)?/.source, [ d, c ]);
|
|
2281
|
+
var f = t(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [ l, g ]);
|
|
2282
|
+
var m = /\[\s*(?:,\s*)*\]/.source;
|
|
2283
|
+
var b = t(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [ f, m ]);
|
|
2284
|
+
var h = t(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [ c, p, m ]);
|
|
2285
|
+
var v = t(/\(<<0>>+(?:,<<0>>+)+\)/.source, [ h ]);
|
|
2286
|
+
var E = t(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [ v, f, m ]);
|
|
2287
|
+
var y = {
|
|
2288
|
+
keyword: o,
|
|
2289
|
+
punctuation: /[<>()?,.:[\]]/
|
|
2290
|
+
};
|
|
2291
|
+
// strings & characters
|
|
2292
|
+
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#character-literals
|
|
2293
|
+
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#string-literals
|
|
2294
|
+
var S = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source;
|
|
2295
|
+
// simplified pattern
|
|
2296
|
+
var A = /"(?:\\.|[^\\"\r\n])*"/.source;
|
|
2297
|
+
var k = /@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;
|
|
2298
|
+
e.languages.csharp = e.languages.extend("clike", {
|
|
2299
|
+
string: [ {
|
|
2300
|
+
pattern: n(/(^|[^$\\])<<0>>/.source, [ k ]),
|
|
2301
|
+
lookbehind: true,
|
|
2302
|
+
greedy: true
|
|
2303
|
+
}, {
|
|
2304
|
+
pattern: n(/(^|[^@$\\])<<0>>/.source, [ A ]),
|
|
2305
|
+
lookbehind: true,
|
|
2306
|
+
greedy: true
|
|
2307
|
+
} ],
|
|
2308
|
+
"class-name": [ {
|
|
2309
|
+
// Using static
|
|
2310
|
+
// using static System.Math;
|
|
2311
|
+
pattern: n(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [ f ]),
|
|
2312
|
+
lookbehind: true,
|
|
2313
|
+
inside: y
|
|
2314
|
+
}, {
|
|
2315
|
+
// Using alias (type)
|
|
2316
|
+
// using Project = PC.MyCompany.Project;
|
|
2317
|
+
pattern: n(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [ d, E ]),
|
|
2318
|
+
lookbehind: true,
|
|
2319
|
+
inside: y
|
|
2320
|
+
}, {
|
|
2321
|
+
// Using alias (alias)
|
|
2322
|
+
// using Project = PC.MyCompany.Project;
|
|
2323
|
+
pattern: n(/(\busing\s+)<<0>>(?=\s*=)/.source, [ d ]),
|
|
2324
|
+
lookbehind: true
|
|
2325
|
+
}, {
|
|
2326
|
+
// Type declarations
|
|
2327
|
+
// class Foo<A, B>
|
|
2328
|
+
// interface Foo<out A, B>
|
|
2329
|
+
pattern: n(/(\b<<0>>\s+)<<1>>/.source, [ i, g ]),
|
|
2330
|
+
lookbehind: true,
|
|
2331
|
+
inside: y
|
|
2332
|
+
}, {
|
|
2333
|
+
// Single catch exception declaration
|
|
2334
|
+
// catch(Foo)
|
|
2335
|
+
// (things like catch(Foo e) is covered by variable declaration)
|
|
2336
|
+
pattern: n(/(\bcatch\s*\(\s*)<<0>>/.source, [ f ]),
|
|
2337
|
+
lookbehind: true,
|
|
2338
|
+
inside: y
|
|
2339
|
+
}, {
|
|
2340
|
+
// Name of the type parameter of generic constraints
|
|
2341
|
+
// where Foo : class
|
|
2342
|
+
pattern: n(/(\bwhere\s+)<<0>>/.source, [ d ]),
|
|
2343
|
+
lookbehind: true
|
|
2344
|
+
}, {
|
|
2345
|
+
// Casts and checks via as and is.
|
|
2346
|
+
// as Foo<A>, is Bar<B>
|
|
2347
|
+
// (things like if(a is Foo b) is covered by variable declaration)
|
|
2348
|
+
pattern: n(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [ b ]),
|
|
2349
|
+
lookbehind: true,
|
|
2350
|
+
inside: y
|
|
2351
|
+
}, {
|
|
2352
|
+
// Variable, field and parameter declaration
|
|
2353
|
+
// (Foo bar, Bar baz, Foo[,,] bay, Foo<Bar, FooBar<Bar>> bax)
|
|
2354
|
+
pattern: n(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [ E, u, d ]),
|
|
2355
|
+
inside: y
|
|
2356
|
+
} ],
|
|
2357
|
+
keyword: o,
|
|
2358
|
+
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#literals
|
|
2359
|
+
number: /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,
|
|
2360
|
+
operator: />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
|
|
2361
|
+
punctuation: /\?\.?|::|[{}[\];(),.:]/
|
|
2362
|
+
});
|
|
2363
|
+
e.languages.insertBefore("csharp", "number", {
|
|
2364
|
+
range: {
|
|
2365
|
+
pattern: /\.\./,
|
|
2366
|
+
alias: "operator"
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
e.languages.insertBefore("csharp", "punctuation", {
|
|
2370
|
+
"named-parameter": {
|
|
2371
|
+
pattern: n(/([(,]\s*)<<0>>(?=\s*:)/.source, [ d ]),
|
|
2372
|
+
lookbehind: true,
|
|
2373
|
+
alias: "punctuation"
|
|
2374
|
+
}
|
|
2375
|
+
});
|
|
2376
|
+
e.languages.insertBefore("csharp", "class-name", {
|
|
2377
|
+
namespace: {
|
|
2378
|
+
// namespace Foo.Bar {}
|
|
2379
|
+
// using Foo.Bar;
|
|
2380
|
+
pattern: n(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source, [ d ]),
|
|
2381
|
+
lookbehind: true,
|
|
2382
|
+
inside: {
|
|
2383
|
+
punctuation: /\./
|
|
2384
|
+
}
|
|
2385
|
+
},
|
|
2386
|
+
"type-expression": {
|
|
2387
|
+
// default(Foo), typeof(Foo<Bar>), sizeof(int)
|
|
2388
|
+
pattern: n(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source, [ p ]),
|
|
2389
|
+
lookbehind: true,
|
|
2390
|
+
alias: "class-name",
|
|
2391
|
+
inside: y
|
|
2392
|
+
},
|
|
2393
|
+
"return-type": {
|
|
2394
|
+
// Foo<Bar> ForBar(); Foo IFoo.Bar() => 0
|
|
2395
|
+
// int this[int index] => 0; T IReadOnlyList<T>.this[int index] => this[index];
|
|
2396
|
+
// int Foo => 0; int Foo { get; set } = 0;
|
|
2397
|
+
pattern: n(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source, [ E, f ]),
|
|
2398
|
+
inside: y,
|
|
2399
|
+
alias: "class-name"
|
|
2400
|
+
},
|
|
2401
|
+
"constructor-invocation": {
|
|
2402
|
+
// new List<Foo<Bar[]>> { }
|
|
2403
|
+
pattern: n(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [ E ]),
|
|
2404
|
+
lookbehind: true,
|
|
2405
|
+
inside: y,
|
|
2406
|
+
alias: "class-name"
|
|
2407
|
+
},
|
|
2408
|
+
/*'explicit-implementation': {
|
|
2409
|
+
// int IFoo<Foo>.Bar => 0; void IFoo<Foo<Foo>>.Foo<T>();
|
|
2410
|
+
pattern: replace(/\b<<0>>(?=\.<<1>>)/, className, methodOrPropertyDeclaration),
|
|
2411
|
+
inside: classNameInside,
|
|
2412
|
+
alias: 'class-name'
|
|
2413
|
+
},*/
|
|
2414
|
+
"generic-method": {
|
|
2415
|
+
// foo<Bar>()
|
|
2416
|
+
pattern: n(/<<0>>\s*<<1>>(?=\s*\()/.source, [ d, c ]),
|
|
2417
|
+
inside: {
|
|
2418
|
+
function: n(/^<<0>>/.source, [ d ]),
|
|
2419
|
+
generic: {
|
|
2420
|
+
pattern: RegExp(c),
|
|
2421
|
+
alias: "class-name",
|
|
2422
|
+
inside: y
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
},
|
|
2426
|
+
"type-list": {
|
|
2427
|
+
// The list of types inherited or of generic constraints
|
|
2428
|
+
// class Foo<F> : Bar, IList<FooBar>
|
|
2429
|
+
// where F : Bar, IList<int>
|
|
2430
|
+
pattern: n(/\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source, [ i, g, d, E, o.source, p, /\bnew\s*\(\s*\)/.source ]),
|
|
2431
|
+
lookbehind: true,
|
|
2432
|
+
inside: {
|
|
2433
|
+
"record-arguments": {
|
|
2434
|
+
pattern: n(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source, [ g, p ]),
|
|
2435
|
+
lookbehind: true,
|
|
2436
|
+
greedy: true,
|
|
2437
|
+
inside: e.languages.csharp
|
|
2438
|
+
},
|
|
2439
|
+
keyword: o,
|
|
2440
|
+
"class-name": {
|
|
2441
|
+
pattern: RegExp(E),
|
|
2442
|
+
greedy: true,
|
|
2443
|
+
inside: y
|
|
2444
|
+
},
|
|
2445
|
+
punctuation: /[,()]/
|
|
2446
|
+
}
|
|
2447
|
+
},
|
|
2448
|
+
preprocessor: {
|
|
2449
|
+
pattern: /(^[\t ]*)#.*/m,
|
|
2450
|
+
lookbehind: true,
|
|
2451
|
+
alias: "property",
|
|
2452
|
+
inside: {
|
|
2453
|
+
// highlight preprocessor directives as keywords
|
|
2454
|
+
directive: {
|
|
2455
|
+
pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
|
|
2456
|
+
lookbehind: true,
|
|
2457
|
+
alias: "keyword"
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
// attributes
|
|
2463
|
+
var x = A + "|" + S;
|
|
2464
|
+
var T = t(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [ x ]);
|
|
2465
|
+
var I = r(t(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [ T ]), 2);
|
|
2466
|
+
// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/#attribute-targets
|
|
2467
|
+
var R = /\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source;
|
|
2468
|
+
var w = t(/<<0>>(?:\s*\(<<1>>*\))?/.source, [ f, I ]);
|
|
2469
|
+
e.languages.insertBefore("csharp", "class-name", {
|
|
2470
|
+
attribute: {
|
|
2471
|
+
// Attributes
|
|
2472
|
+
// [Foo], [Foo(1), Bar(2, Prop = "foo")], [return: Foo(1), Bar(2)], [assembly: Foo(Bar)]
|
|
2473
|
+
pattern: n(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source, [ R, w ]),
|
|
2474
|
+
lookbehind: true,
|
|
2475
|
+
greedy: true,
|
|
2476
|
+
inside: {
|
|
2477
|
+
target: {
|
|
2478
|
+
pattern: n(/^<<0>>(?=\s*:)/.source, [ R ]),
|
|
2479
|
+
alias: "keyword"
|
|
2480
|
+
},
|
|
2481
|
+
"attribute-arguments": {
|
|
2482
|
+
pattern: n(/\(<<0>>*\)/.source, [ I ]),
|
|
2483
|
+
inside: e.languages.csharp
|
|
2484
|
+
},
|
|
2485
|
+
"class-name": {
|
|
2486
|
+
pattern: RegExp(f),
|
|
2487
|
+
inside: {
|
|
2488
|
+
punctuation: /\./
|
|
2489
|
+
}
|
|
2490
|
+
},
|
|
2491
|
+
punctuation: /[:,]/
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2495
|
+
// string interpolation
|
|
2496
|
+
var N = /:[^}\r\n]+/.source;
|
|
2497
|
+
// multi line
|
|
2498
|
+
var O = r(t(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [ T ]), 2);
|
|
2499
|
+
var _ = t(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [ O, N ]);
|
|
2500
|
+
// single line
|
|
2501
|
+
var L = r(t(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [ x ]), 2);
|
|
2502
|
+
var F = t(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [ L, N ]);
|
|
2503
|
+
function C(t, r) {
|
|
2504
|
+
return {
|
|
2505
|
+
interpolation: {
|
|
2506
|
+
pattern: n(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [ t ]),
|
|
2507
|
+
lookbehind: true,
|
|
2508
|
+
inside: {
|
|
2509
|
+
"format-string": {
|
|
2510
|
+
pattern: n(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source, [ r, N ]),
|
|
2511
|
+
lookbehind: true,
|
|
2512
|
+
inside: {
|
|
2513
|
+
punctuation: /^:/
|
|
2514
|
+
}
|
|
2515
|
+
},
|
|
2516
|
+
punctuation: /^\{|\}$/,
|
|
2517
|
+
expression: {
|
|
2518
|
+
pattern: /[\s\S]+/,
|
|
2519
|
+
alias: "language-csharp",
|
|
2520
|
+
inside: e.languages.csharp
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
},
|
|
2524
|
+
string: /[\s\S]+/
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
e.languages.insertBefore("csharp", "string", {
|
|
2528
|
+
"interpolation-string": [ {
|
|
2529
|
+
pattern: n(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source, [ _ ]),
|
|
2530
|
+
lookbehind: true,
|
|
2531
|
+
greedy: true,
|
|
2532
|
+
inside: C(_, O)
|
|
2533
|
+
}, {
|
|
2534
|
+
pattern: n(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source, [ F ]),
|
|
2535
|
+
lookbehind: true,
|
|
2536
|
+
greedy: true,
|
|
2537
|
+
inside: C(F, L)
|
|
2538
|
+
} ],
|
|
2539
|
+
char: {
|
|
2540
|
+
pattern: RegExp(S),
|
|
2541
|
+
greedy: true
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
e.languages.dotnet = e.languages.cs = e.languages.csharp;
|
|
2545
|
+
})(a);
|
|
2546
|
+
(function(e) {
|
|
2547
|
+
var t = e.languages.powershell = {
|
|
2548
|
+
comment: [ {
|
|
2549
|
+
pattern: /(^|[^`])<#[\s\S]*?#>/,
|
|
2550
|
+
lookbehind: true
|
|
2551
|
+
}, {
|
|
2552
|
+
pattern: /(^|[^`])#.*/,
|
|
2553
|
+
lookbehind: true
|
|
2554
|
+
} ],
|
|
2555
|
+
string: [ {
|
|
2556
|
+
pattern: /"(?:`[\s\S]|[^`"])*"/,
|
|
2557
|
+
greedy: true,
|
|
2558
|
+
inside: null
|
|
2559
|
+
}, {
|
|
2560
|
+
pattern: /'(?:[^']|'')*'/,
|
|
2561
|
+
greedy: true
|
|
2562
|
+
} ],
|
|
2563
|
+
// Matches name spaces as well as casts, attribute decorators. Force starting with letter to avoid matching array indices
|
|
2564
|
+
// Supports two levels of nested brackets (e.g. `[OutputType([System.Collections.Generic.List[int]])]`)
|
|
2565
|
+
namespace: /\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,
|
|
2566
|
+
boolean: /\$(?:false|true)\b/i,
|
|
2567
|
+
variable: /\$\w+\b/,
|
|
2568
|
+
// Cmdlets and aliases. Aliases should come last, otherwise "write" gets preferred over "write-host" for example
|
|
2569
|
+
// Get-Command | ?{ $_.ModuleName -match "Microsoft.PowerShell.(Util|Core|Management)" }
|
|
2570
|
+
// Get-Alias | ?{ $_.ReferencedCommand.Module.Name -match "Microsoft.PowerShell.(Util|Core|Management)" }
|
|
2571
|
+
function: [ /\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i, /\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i ],
|
|
2572
|
+
// per http://technet.microsoft.com/en-us/library/hh847744.aspx
|
|
2573
|
+
keyword: /\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,
|
|
2574
|
+
operator: {
|
|
2575
|
+
pattern: /(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,
|
|
2576
|
+
lookbehind: true
|
|
2577
|
+
},
|
|
2578
|
+
punctuation: /[|{}[\];(),.]/
|
|
2579
|
+
};
|
|
2580
|
+
// Variable interpolation inside strings, and nested expressions
|
|
2581
|
+
t.string[0].inside = {
|
|
2582
|
+
function: {
|
|
2583
|
+
// Allow for one level of nesting
|
|
2584
|
+
pattern: /(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,
|
|
2585
|
+
lookbehind: true,
|
|
2586
|
+
inside: t
|
|
2587
|
+
},
|
|
2588
|
+
boolean: t.boolean,
|
|
2589
|
+
variable: t.variable
|
|
2590
|
+
};
|
|
2591
|
+
})(a);
|
|
2592
|
+
a.languages.python = {
|
|
2593
|
+
comment: {
|
|
2594
|
+
pattern: /(^|[^\\])#.*/,
|
|
2595
|
+
lookbehind: true,
|
|
2596
|
+
greedy: true
|
|
2597
|
+
},
|
|
2598
|
+
"string-interpolation": {
|
|
2599
|
+
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
2600
|
+
greedy: true,
|
|
2601
|
+
inside: {
|
|
2602
|
+
interpolation: {
|
|
2603
|
+
// "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
|
2604
|
+
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
2605
|
+
lookbehind: true,
|
|
2606
|
+
inside: {
|
|
2607
|
+
"format-spec": {
|
|
2608
|
+
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
2609
|
+
lookbehind: true
|
|
2610
|
+
},
|
|
2611
|
+
"conversion-option": {
|
|
2612
|
+
pattern: //,
|
|
2613
|
+
alias: "punctuation"
|
|
2614
|
+
},
|
|
2615
|
+
rest: null
|
|
2616
|
+
}
|
|
2617
|
+
},
|
|
2618
|
+
string: /[\s\S]+/
|
|
2619
|
+
}
|
|
2620
|
+
},
|
|
2621
|
+
"triple-quoted-string": {
|
|
2622
|
+
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
2623
|
+
greedy: true,
|
|
2624
|
+
alias: "string"
|
|
2625
|
+
},
|
|
2626
|
+
string: {
|
|
2627
|
+
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
2628
|
+
greedy: true
|
|
2629
|
+
},
|
|
2630
|
+
function: {
|
|
2631
|
+
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
2632
|
+
lookbehind: true
|
|
2633
|
+
},
|
|
2634
|
+
"class-name": {
|
|
2635
|
+
pattern: /(\bclass\s+)\w+/i,
|
|
2636
|
+
lookbehind: true
|
|
2637
|
+
},
|
|
2638
|
+
decorator: {
|
|
2639
|
+
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
2640
|
+
lookbehind: true,
|
|
2641
|
+
alias: [ "annotation", "punctuation" ],
|
|
2642
|
+
inside: {
|
|
2643
|
+
punctuation: /\./
|
|
2644
|
+
}
|
|
2645
|
+
},
|
|
2646
|
+
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/,
|
|
2647
|
+
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/,
|
|
2648
|
+
boolean: /\b(?:False|None|True)\b/,
|
|
2649
|
+
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,
|
|
2650
|
+
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
2651
|
+
punctuation: /[{}[\];(),.:]/
|
|
2652
|
+
};
|
|
2653
|
+
a.languages.python["string-interpolation"].inside["interpolation"].inside.rest = a.languages.python;
|
|
2654
|
+
a.languages.py = a.languages.python;
|
|
2058
2655
|
})();
|
|
2059
2656
|
/***/
|
|
2060
2657
|
/******/ }
|
|
@@ -2064,24 +2661,24 @@
|
|
|
2064
2661
|
/******/ var t = {};
|
|
2065
2662
|
/******/
|
|
2066
2663
|
/******/ // The require function
|
|
2067
|
-
/******/ function n(
|
|
2664
|
+
/******/ function n(r) {
|
|
2068
2665
|
/******/ // Check if module is in cache
|
|
2069
|
-
/******/ var
|
|
2070
|
-
/******/ if (
|
|
2071
|
-
/******/ return
|
|
2666
|
+
/******/ var a = t[r];
|
|
2667
|
+
/******/ if (a !== undefined) {
|
|
2668
|
+
/******/ return a.exports;
|
|
2072
2669
|
/******/ }
|
|
2073
2670
|
/******/ // Create a new module (and put it into the cache)
|
|
2074
|
-
/******/ var
|
|
2671
|
+
/******/ var s = t[r] = {
|
|
2075
2672
|
/******/ // no module.id needed
|
|
2076
2673
|
/******/ // no module.loaded needed
|
|
2077
2674
|
/******/ exports: {}
|
|
2078
2675
|
/******/ };
|
|
2079
2676
|
/******/
|
|
2080
2677
|
/******/ // Execute the module function
|
|
2081
|
-
/******/ e[
|
|
2678
|
+
/******/ e[r](s, s.exports, n);
|
|
2082
2679
|
/******/
|
|
2083
2680
|
/******/ // Return the exports of the module
|
|
2084
|
-
/******/ return
|
|
2681
|
+
/******/ return s.exports;
|
|
2085
2682
|
/******/ }
|
|
2086
2683
|
/******/
|
|
2087
2684
|
/************************************************************************/
|
|
@@ -2104,11 +2701,11 @@
|
|
|
2104
2701
|
/******/ (() => {
|
|
2105
2702
|
/******/ // define getter functions for harmony exports
|
|
2106
2703
|
/******/ n.d = (e, t) => {
|
|
2107
|
-
/******/ for (var
|
|
2108
|
-
/******/ if (n.o(t,
|
|
2109
|
-
/******/ Object.defineProperty(e,
|
|
2704
|
+
/******/ for (var r in t) {
|
|
2705
|
+
/******/ if (n.o(t, r) && !n.o(e, r)) {
|
|
2706
|
+
/******/ Object.defineProperty(e, r, {
|
|
2110
2707
|
enumerable: true,
|
|
2111
|
-
get: t[
|
|
2708
|
+
get: t[r]
|
|
2112
2709
|
});
|
|
2113
2710
|
/******/ }
|
|
2114
2711
|
/******/ }
|
|
@@ -2136,25 +2733,25 @@
|
|
|
2136
2733
|
/******/ };
|
|
2137
2734
|
/******/ })();
|
|
2138
2735
|
/******/
|
|
2139
|
-
/************************************************************************/ var
|
|
2736
|
+
/************************************************************************/ var r = {};
|
|
2140
2737
|
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
|
2141
2738
|
(() => {
|
|
2142
2739
|
"use strict";
|
|
2143
2740
|
// ESM COMPAT FLAG
|
|
2144
|
-
n.r(
|
|
2741
|
+
n.r(r);
|
|
2145
2742
|
// EXPORTS
|
|
2146
|
-
n.d(
|
|
2147
|
-
default: () => /* reexport */
|
|
2743
|
+
n.d(r, {
|
|
2744
|
+
default: () => /* reexport */ se
|
|
2148
2745
|
});
|
|
2149
2746
|
// CONCATENATED MODULE: external "react"
|
|
2150
2747
|
const e = require("react");
|
|
2151
2748
|
var t = n.n(e);
|
|
2152
2749
|
// CONCATENATED MODULE: external "lodash/castArray"
|
|
2153
|
-
const
|
|
2154
|
-
var
|
|
2750
|
+
const a = require("lodash/castArray");
|
|
2751
|
+
var s = n.n(a);
|
|
2155
2752
|
// CONCATENATED MODULE: external "lodash/flatten"
|
|
2156
|
-
const
|
|
2157
|
-
var o = n.n(
|
|
2753
|
+
const i = require("lodash/flatten");
|
|
2754
|
+
var o = n.n(i);
|
|
2158
2755
|
// CONCATENATED MODULE: external "lodash/indexOf"
|
|
2159
2756
|
const l = require("lodash/indexOf");
|
|
2160
2757
|
var u = n.n(l);
|
|
@@ -2168,39 +2765,39 @@
|
|
|
2168
2765
|
const f = require("prop-types");
|
|
2169
2766
|
var m = n.n(f);
|
|
2170
2767
|
// CONCATENATED MODULE: external "@splunk/react-ui/useResizeObserver"
|
|
2171
|
-
const
|
|
2172
|
-
var
|
|
2768
|
+
const b = require("@splunk/react-ui/useResizeObserver");
|
|
2769
|
+
var h = n.n(b);
|
|
2173
2770
|
// CONCATENATED MODULE: external "styled-components"
|
|
2174
|
-
const
|
|
2175
|
-
var
|
|
2771
|
+
const v = require("styled-components");
|
|
2772
|
+
var E = n.n(v);
|
|
2176
2773
|
// CONCATENATED MODULE: external "@splunk/themes"
|
|
2177
2774
|
const y = require("@splunk/themes");
|
|
2178
2775
|
// CONCATENATED MODULE: ./src/Code/CodeStyles.ts
|
|
2179
2776
|
var S = "lineHeightSpacious";
|
|
2180
2777
|
var A = "spacingLarge";
|
|
2181
|
-
var
|
|
2778
|
+
var k = E().code.withConfig({
|
|
2182
2779
|
displayName: "CodeStyles__StyledCode",
|
|
2183
2780
|
componentId: "sc-1eq4k68-0"
|
|
2184
2781
|
})([ "font-family:", ";position:relative;z-index:1;", ";" ], y.variables.monoFontFamily, (function(e) {
|
|
2185
2782
|
var t = e.$isPlaintext;
|
|
2186
|
-
return !t && (0,
|
|
2783
|
+
return !t && (0, v.css)([ "color:", ";" ], y.variables.syntaxTeal);
|
|
2187
2784
|
}));
|
|
2188
|
-
var
|
|
2785
|
+
var x = E().pre.withConfig({
|
|
2189
2786
|
displayName: "CodeStyles__StyledPre",
|
|
2190
2787
|
componentId: "sc-1eq4k68-1"
|
|
2191
2788
|
})([ "", ";", ";line-height:", ";position:relative;text-align:left;tab-size:4;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;hyphens:none;overflow-x:auto;&:focus-visible{box-shadow:", ";}", " ", ";" ], y.mixins.reset("grid"), y.mixins.typography("monoBody"), y.variables[S], y.variables.focusShadow, (function(e) {
|
|
2192
2789
|
var t = e.$showLineNumbers, n = e.$counterReset;
|
|
2193
|
-
return t && (0,
|
|
2790
|
+
return t && (0, v.css)([ "grid-template-columns:min-content auto;counter-reset:linenumber ", ";" ], n);
|
|
2194
2791
|
}), (function(e) {
|
|
2195
2792
|
var t = e.$containerAppearance;
|
|
2196
|
-
return t === "none" ? (0,
|
|
2197
|
-
|
|
2793
|
+
return t === "none" ? (0, v.css)([ "gap:", ";" ], y.variables.spacingMedium) : (0,
|
|
2794
|
+
v.css)([ "background-color:", ";border-radius:", ";", "{margin:", ";}" ], y.variables.neutral50, y.variables.borderRadius, /* sc-sel */ k, y.variables[A]);
|
|
2198
2795
|
}));
|
|
2199
|
-
var
|
|
2796
|
+
var T = E().span.withConfig({
|
|
2200
2797
|
displayName: "CodeStyles__StyledIndent",
|
|
2201
2798
|
componentId: "sc-1eq4k68-2"
|
|
2202
2799
|
})([ "&:not(:last-child){background-image:linear-gradient( to left,", " 1px,transparent 1px,transparent );}" ], y.variables.syntaxGray);
|
|
2203
|
-
var
|
|
2800
|
+
var I = {
|
|
2204
2801
|
comment: y.variables.syntaxGray,
|
|
2205
2802
|
prolog: y.variables.syntaxGray,
|
|
2206
2803
|
doctype: y.variables.syntaxGray,
|
|
@@ -2231,12 +2828,12 @@
|
|
|
2231
2828
|
important: y.variables.syntaxOrange,
|
|
2232
2829
|
variable: y.variables.syntaxOrange
|
|
2233
2830
|
};
|
|
2234
|
-
var
|
|
2831
|
+
var R = E().span.withConfig({
|
|
2235
2832
|
displayName: "CodeStyles__StyledToken",
|
|
2236
2833
|
componentId: "sc-1eq4k68-3"
|
|
2237
2834
|
})([ "color:", ";cursor:", ";opacity:", ";font-style:", ";font-weight:", ";" ], (function(e) {
|
|
2238
2835
|
var t = e.partType;
|
|
2239
|
-
return
|
|
2836
|
+
return I[t];
|
|
2240
2837
|
}), (function(e) {
|
|
2241
2838
|
var t = e.partType;
|
|
2242
2839
|
return t === "entity" ? "help" : null;
|
|
@@ -2251,7 +2848,7 @@
|
|
|
2251
2848
|
return t === "important" || t === "bold" ? y.variables.fontWeightBold : null;
|
|
2252
2849
|
}));
|
|
2253
2850
|
// CONCATENATED MODULE: ./src/Code/LineHighlightsStyles.ts
|
|
2254
|
-
var
|
|
2851
|
+
var w = E().div.withConfig({
|
|
2255
2852
|
displayName: "LineHighlightsStyles__StyledLineHighlight",
|
|
2256
2853
|
componentId: "sc-1x2b02z-0"
|
|
2257
2854
|
})([ "position:absolute;left:0;height:1lh;background:", ";border-left:2px solid ", ";pointer-events:none;line-height:inherit;width:", "px;", ";" ], y.variables.notificationColorInfoWeak, y.variables.notificationColorInfo, (function(e) {
|
|
@@ -2259,69 +2856,69 @@
|
|
|
2259
2856
|
return t;
|
|
2260
2857
|
}), (function(e) {
|
|
2261
2858
|
var t = e.$containerAppearance, n = e.$lineNum;
|
|
2262
|
-
return t === "none" ? (0,
|
|
2263
|
-
|
|
2859
|
+
return t === "none" ? (0, v.css)([ "top:calc(", " * ", "em);" ], n - 1, y.variables[S]) : (0,
|
|
2860
|
+
v.css)([ "top:calc( ", " * ", "em + ", " );" ], n - 1, y.variables[S], y.variables[A]);
|
|
2264
2861
|
}));
|
|
2265
2862
|
// CONCATENATED MODULE: ./src/Code/LineHighlights.tsx
|
|
2266
|
-
function
|
|
2267
|
-
return
|
|
2863
|
+
function N(e, t) {
|
|
2864
|
+
return C(e) || F(e, t) || _(e, t) || O();
|
|
2268
2865
|
}
|
|
2269
|
-
function
|
|
2866
|
+
function O() {
|
|
2270
2867
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2271
2868
|
}
|
|
2272
|
-
function
|
|
2869
|
+
function _(e, t) {
|
|
2273
2870
|
if (e) {
|
|
2274
|
-
if ("string" == typeof e) return
|
|
2871
|
+
if ("string" == typeof e) return L(e, t);
|
|
2275
2872
|
var n = {}.toString.call(e).slice(8, -1);
|
|
2276
|
-
return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ?
|
|
2873
|
+
return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? L(e, t) : void 0;
|
|
2277
2874
|
}
|
|
2278
2875
|
}
|
|
2279
|
-
function
|
|
2876
|
+
function L(e, t) {
|
|
2280
2877
|
(null == t || t > e.length) && (t = e.length);
|
|
2281
|
-
for (var n = 0,
|
|
2282
|
-
|
|
2878
|
+
for (var n = 0, r = Array(t); n < t; n++) {
|
|
2879
|
+
r[n] = e[n];
|
|
2283
2880
|
}
|
|
2284
|
-
return
|
|
2881
|
+
return r;
|
|
2285
2882
|
}
|
|
2286
|
-
function
|
|
2883
|
+
function F(e, t) {
|
|
2287
2884
|
var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
2288
2885
|
if (null != n) {
|
|
2289
|
-
var a,
|
|
2886
|
+
var r, a, s, i, o = [], l = !0, u = !1;
|
|
2290
2887
|
try {
|
|
2291
|
-
if (
|
|
2888
|
+
if (s = (n = n.call(e)).next, 0 === t) {
|
|
2292
2889
|
if (Object(n) !== n) return;
|
|
2293
2890
|
l = !1;
|
|
2294
|
-
} else for (;!(l = (
|
|
2891
|
+
} else for (;!(l = (r = s.call(n)).done) && (o.push(r.value), o.length !== t); l = !0) {
|
|
2295
2892
|
}
|
|
2296
2893
|
} catch (e) {
|
|
2297
|
-
u = !0,
|
|
2894
|
+
u = !0, a = e;
|
|
2298
2895
|
} finally {
|
|
2299
2896
|
try {
|
|
2300
|
-
if (!l && null != n["return"] && (
|
|
2897
|
+
if (!l && null != n["return"] && (i = n["return"](), Object(i) !== i)) return;
|
|
2301
2898
|
} finally {
|
|
2302
|
-
if (u) throw
|
|
2899
|
+
if (u) throw a;
|
|
2303
2900
|
}
|
|
2304
2901
|
}
|
|
2305
2902
|
return o;
|
|
2306
2903
|
}
|
|
2307
2904
|
}
|
|
2308
|
-
function
|
|
2905
|
+
function C(e) {
|
|
2309
2906
|
if (Array.isArray(e)) return e;
|
|
2310
2907
|
}
|
|
2311
2908
|
// parseHighlightLines will turn a string like "2,4-5" into an array of ranges like [[2, 2], [4, 5]]
|
|
2312
|
-
var
|
|
2909
|
+
var D = function e(t) {
|
|
2313
2910
|
return t.replace(/\s+/g, "").split(",").filter(Boolean).map((function(e) {
|
|
2314
|
-
var t = e.split("-").map(Number), n =
|
|
2315
|
-
return [
|
|
2911
|
+
var t = e.split("-").map(Number), n = N(t, 2), r = n[0], a = n[1];
|
|
2912
|
+
return [ r, a || r ];
|
|
2316
2913
|
}));
|
|
2317
2914
|
};
|
|
2318
2915
|
// Flatten the array of ranges into a single array of line numbers
|
|
2319
2916
|
// example: [[2, 2], [4, 5]] will become [2, 4, 5]
|
|
2320
|
-
var
|
|
2917
|
+
var P = function e(t) {
|
|
2321
2918
|
var n = t.map((function(e) {
|
|
2322
|
-
var t =
|
|
2919
|
+
var t = N(e, 2), n = t[0], r = t[1];
|
|
2323
2920
|
return Array.from({
|
|
2324
|
-
length:
|
|
2921
|
+
length: r - n + 1
|
|
2325
2922
|
}, (function(e, t) {
|
|
2326
2923
|
return n + t;
|
|
2327
2924
|
}));
|
|
@@ -2332,42 +2929,42 @@
|
|
|
2332
2929
|
// Remove duplicates
|
|
2333
2930
|
};
|
|
2334
2931
|
var $ = function e(n) {
|
|
2335
|
-
var
|
|
2336
|
-
var
|
|
2337
|
-
var o =
|
|
2932
|
+
var r = n.containerAppearance, a = n.highlight, s = n.width;
|
|
2933
|
+
var i = D(a);
|
|
2934
|
+
var o = P(i);
|
|
2338
2935
|
|
|
2339
2936
|
return t().createElement(t().Fragment, null, o.map((function(e) {
|
|
2340
2937
|
|
|
2341
|
-
return t().createElement(
|
|
2938
|
+
return t().createElement(w, {
|
|
2342
2939
|
key: e,
|
|
2343
2940
|
className: "line-highlight",
|
|
2344
2941
|
"aria-hidden": "true",
|
|
2345
|
-
$containerAppearance:
|
|
2942
|
+
$containerAppearance: r,
|
|
2346
2943
|
$lineNum: e,
|
|
2347
|
-
$width:
|
|
2944
|
+
$width: s
|
|
2348
2945
|
});
|
|
2349
2946
|
})));
|
|
2350
2947
|
};
|
|
2351
2948
|
/* harmony default export */ const U = $;
|
|
2352
2949
|
// CONCATENATED MODULE: ./src/Code/LineNumbersStyles.ts
|
|
2353
|
-
var
|
|
2950
|
+
var B = E().span.withConfig({
|
|
2354
2951
|
displayName: "LineNumbersStyles__StyledLineNumberRows",
|
|
2355
2952
|
componentId: "sc-1h4k3dh-0"
|
|
2356
2953
|
})([ "pointer-events:none;user-select:none;", ";& > span{display:block;counter-increment:linenumber;position:relative;z-index:1;&::before{display:block;content:counter(linenumber);color:", ";text-align:right;", "}}" ], (function(e) {
|
|
2357
2954
|
var t = e.$containerAppearance;
|
|
2358
|
-
return t === "none" ? (0,
|
|
2359
|
-
|
|
2955
|
+
return t === "none" ? (0, v.css)([ "border-right:1px solid ", ";z-index:1;" ], y.variables.borderColor) : (0,
|
|
2956
|
+
v.css)([ "padding:", ";background-color:", ";" ], y.variables[A], y.variables.neutral200);
|
|
2360
2957
|
}), y.variables.contentColorDefault, (function(e) {
|
|
2361
2958
|
var t = e.$containerAppearance;
|
|
2362
|
-
return t === "none" && (0,
|
|
2959
|
+
return t === "none" && (0, v.css)([ "padding-inline-end:", ";" ], y.variables.spacingSmall);
|
|
2363
2960
|
}));
|
|
2364
2961
|
// CONCATENATED MODULE: ./src/Code/LineNumbers.tsx
|
|
2365
|
-
function
|
|
2366
|
-
var n = e.containerAppearance,
|
|
2962
|
+
function M(e) {
|
|
2963
|
+
var n = e.containerAppearance, r = n === void 0 ? "none" : n, a = e.value, s = a === void 0 ? "" : a;
|
|
2367
2964
|
// Use a regex to see how many lines there are in the value, then output an
|
|
2368
2965
|
// empty span for each line. The numbers themselves are handled by the CSS counter.
|
|
2369
|
-
var
|
|
2370
|
-
var o =
|
|
2966
|
+
var i = s.match(/\n(?!$)/g);
|
|
2967
|
+
var o = i ? i.length + 1 : 1;
|
|
2371
2968
|
var l = Array.from({
|
|
2372
2969
|
length: o
|
|
2373
2970
|
}, (function(e, n) {
|
|
@@ -2377,15 +2974,15 @@
|
|
|
2377
2974
|
});
|
|
2378
2975
|
}));
|
|
2379
2976
|
|
|
2380
|
-
return t().createElement(
|
|
2381
|
-
$containerAppearance:
|
|
2977
|
+
return t().createElement(B, {
|
|
2978
|
+
$containerAppearance: r,
|
|
2382
2979
|
"aria-hidden": true
|
|
2383
2980
|
}, l);
|
|
2384
2981
|
}
|
|
2385
|
-
/* harmony default export */ const G =
|
|
2982
|
+
/* harmony default export */ const G = M;
|
|
2386
2983
|
// EXTERNAL MODULE: ./src/Code/prism/prism.empty
|
|
2387
|
-
var
|
|
2388
|
-
var
|
|
2984
|
+
var j = n(74);
|
|
2985
|
+
var H = n.n(j);
|
|
2389
2986
|
// CONCATENATED MODULE: ./src/utils/updateReactRef.ts
|
|
2390
2987
|
/**
|
|
2391
2988
|
* Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
|
|
@@ -2406,24 +3003,24 @@
|
|
|
2406
3003
|
}
|
|
2407
3004
|
}
|
|
2408
3005
|
// CONCATENATED MODULE: ./src/Code/Code.tsx
|
|
2409
|
-
function
|
|
2410
|
-
return
|
|
3006
|
+
function W() {
|
|
3007
|
+
return W = Object.assign ? Object.assign.bind() : function(e) {
|
|
2411
3008
|
for (var t = 1; t < arguments.length; t++) {
|
|
2412
3009
|
var n = arguments[t];
|
|
2413
|
-
for (var
|
|
2414
|
-
({}).hasOwnProperty.call(n,
|
|
3010
|
+
for (var r in n) {
|
|
3011
|
+
({}).hasOwnProperty.call(n, r) && (e[r] = n[r]);
|
|
2415
3012
|
}
|
|
2416
3013
|
}
|
|
2417
3014
|
return e;
|
|
2418
|
-
},
|
|
3015
|
+
}, W.apply(null, arguments);
|
|
2419
3016
|
}
|
|
2420
|
-
function
|
|
2421
|
-
return
|
|
3017
|
+
function Y(e, t) {
|
|
3018
|
+
return V(e) || Z(e, t) || X(e, t) || q();
|
|
2422
3019
|
}
|
|
2423
|
-
function
|
|
3020
|
+
function q() {
|
|
2424
3021
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2425
3022
|
}
|
|
2426
|
-
function
|
|
3023
|
+
function X(e, t) {
|
|
2427
3024
|
if (e) {
|
|
2428
3025
|
if ("string" == typeof e) return K(e, t);
|
|
2429
3026
|
var n = {}.toString.call(e).slice(8, -1);
|
|
@@ -2432,54 +3029,54 @@
|
|
|
2432
3029
|
}
|
|
2433
3030
|
function K(e, t) {
|
|
2434
3031
|
(null == t || t > e.length) && (t = e.length);
|
|
2435
|
-
for (var n = 0,
|
|
2436
|
-
|
|
3032
|
+
for (var n = 0, r = Array(t); n < t; n++) {
|
|
3033
|
+
r[n] = e[n];
|
|
2437
3034
|
}
|
|
2438
|
-
return
|
|
3035
|
+
return r;
|
|
2439
3036
|
}
|
|
2440
|
-
function
|
|
3037
|
+
function Z(e, t) {
|
|
2441
3038
|
var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
2442
3039
|
if (null != n) {
|
|
2443
|
-
var a,
|
|
3040
|
+
var r, a, s, i, o = [], l = !0, u = !1;
|
|
2444
3041
|
try {
|
|
2445
|
-
if (
|
|
3042
|
+
if (s = (n = n.call(e)).next, 0 === t) {
|
|
2446
3043
|
if (Object(n) !== n) return;
|
|
2447
3044
|
l = !1;
|
|
2448
|
-
} else for (;!(l = (
|
|
3045
|
+
} else for (;!(l = (r = s.call(n)).done) && (o.push(r.value), o.length !== t); l = !0) {
|
|
2449
3046
|
}
|
|
2450
3047
|
} catch (e) {
|
|
2451
|
-
u = !0,
|
|
3048
|
+
u = !0, a = e;
|
|
2452
3049
|
} finally {
|
|
2453
3050
|
try {
|
|
2454
|
-
if (!l && null != n["return"] && (
|
|
3051
|
+
if (!l && null != n["return"] && (i = n["return"](), Object(i) !== i)) return;
|
|
2455
3052
|
} finally {
|
|
2456
|
-
if (u) throw
|
|
3053
|
+
if (u) throw a;
|
|
2457
3054
|
}
|
|
2458
3055
|
}
|
|
2459
3056
|
return o;
|
|
2460
3057
|
}
|
|
2461
3058
|
}
|
|
2462
|
-
function
|
|
3059
|
+
function V(e) {
|
|
2463
3060
|
if (Array.isArray(e)) return e;
|
|
2464
3061
|
}
|
|
2465
|
-
function
|
|
3062
|
+
function J(e, t) {
|
|
2466
3063
|
if (null == e) return {};
|
|
2467
|
-
var n,
|
|
3064
|
+
var n, r, a = Q(e, t);
|
|
2468
3065
|
if (Object.getOwnPropertySymbols) {
|
|
2469
|
-
var
|
|
2470
|
-
for (
|
|
2471
|
-
n =
|
|
3066
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
3067
|
+
for (r = 0; r < s.length; r++) {
|
|
3068
|
+
n = s[r], -1 === t.indexOf(n) && {}.propertyIsEnumerable.call(e, n) && (a[n] = e[n]);
|
|
2472
3069
|
}
|
|
2473
3070
|
}
|
|
2474
|
-
return
|
|
3071
|
+
return a;
|
|
2475
3072
|
}
|
|
2476
|
-
function
|
|
3073
|
+
function Q(e, t) {
|
|
2477
3074
|
if (null == e) return {};
|
|
2478
3075
|
var n = {};
|
|
2479
|
-
for (var
|
|
2480
|
-
if ({}.hasOwnProperty.call(e,
|
|
2481
|
-
if (-1 !== t.indexOf(
|
|
2482
|
-
n[
|
|
3076
|
+
for (var r in e) {
|
|
3077
|
+
if ({}.hasOwnProperty.call(e, r)) {
|
|
3078
|
+
if (-1 !== t.indexOf(r)) continue;
|
|
3079
|
+
n[r] = e[r];
|
|
2483
3080
|
}
|
|
2484
3081
|
}
|
|
2485
3082
|
return n;
|
|
@@ -2488,17 +3085,17 @@
|
|
|
2488
3085
|
// auto formatting. The import below points to an empty file which is replaced at build
|
|
2489
3086
|
// time, see ./prism/build-isolated-prism.js for details.
|
|
2490
3087
|
// typed as 'prismjs'
|
|
2491
|
-
var ee = [ "bash", "clike", "
|
|
3088
|
+
var ee = [ "bash", "c", "clike", "cpp", "cs", "csharp", "css", "html", "javascript", "js", "json", "jsx", "markup", "mathml", "plain", "plaintext", "powershell", "py", "python", "sh", "shell", "splunk-spl", "sql", "svg", "text", "ts", "tsx", "txt", "typescript", "xml", "yaml", "yml" ];
|
|
2492
3089
|
function te(e) {
|
|
2493
3090
|
return [ "plain", "plaintext", "text", "txt" ].includes(e);
|
|
2494
3091
|
}
|
|
2495
3092
|
function ne(e, t) {
|
|
2496
3093
|
if (te(t)) {
|
|
2497
|
-
return
|
|
3094
|
+
return H().tokenize(e, {});
|
|
2498
3095
|
}
|
|
2499
|
-
return
|
|
3096
|
+
return H().tokenize(e, H().languages[t]);
|
|
2500
3097
|
}
|
|
2501
|
-
var
|
|
3098
|
+
var re = {
|
|
2502
3099
|
containerAppearance: m().oneOf([ "none", "section" ]),
|
|
2503
3100
|
elementRef: m().oneOfType([ m().func, m().object ]),
|
|
2504
3101
|
indentChars: m().number,
|
|
@@ -2510,105 +3107,105 @@
|
|
|
2510
3107
|
showLineNumbers: m().bool,
|
|
2511
3108
|
value: m().string
|
|
2512
3109
|
};
|
|
2513
|
-
function
|
|
2514
|
-
var
|
|
3110
|
+
function ae(n) {
|
|
3111
|
+
var r = n.containerAppearance, a = r === void 0 ? "none" : r, i = n.elementRef, l = n.indentChars, c = l === void 0 ? 4 : l, d = n.language, f = n.languageFallback, m = f === void 0 ? "javascript" : f, b = n.lineHighlights, v = n.lineNumberStart, E = n.showIndentGuide, y = E === void 0 ? true : E, S = n.showLineNumbers, A = n.value, I = A === void 0 ? "" : A, w = J(n, [ "containerAppearance", "elementRef", "indentChars", "language", "languageFallback", "lineHighlights", "lineNumberStart", "showIndentGuide", "showLineNumbers", "value" ]);
|
|
2515
3112
|
// @docs-props-type CodePropsBase
|
|
2516
|
-
var
|
|
2517
|
-
var
|
|
2518
|
-
var
|
|
3113
|
+
var N = (0, e.useRef)(null);
|
|
3114
|
+
var O = (0, e.useState)(undefined), _ = Y(O, 2), L = _[0], F = _[1];
|
|
3115
|
+
var C = h()(N), D = C.width, P = C.height;
|
|
2519
3116
|
var $ = (0, e.useCallback)((function(e) {
|
|
2520
|
-
z(
|
|
2521
|
-
z(
|
|
2522
|
-
}), [
|
|
3117
|
+
z(N, e);
|
|
3118
|
+
z(i, e);
|
|
3119
|
+
}), [ i ]);
|
|
2523
3120
|
(0, e.useEffect)((function() {
|
|
2524
|
-
var e =
|
|
3121
|
+
var e = N.current;
|
|
2525
3122
|
if (e) {
|
|
2526
|
-
var t = e.scrollHeight > Math.round(
|
|
2527
|
-
var n = e.scrollWidth > Math.round(
|
|
2528
|
-
var
|
|
2529
|
-
|
|
3123
|
+
var t = e.scrollHeight > Math.round(P);
|
|
3124
|
+
var n = e.scrollWidth > Math.round(D);
|
|
3125
|
+
var r = t || n;
|
|
3126
|
+
F(r ? 0 : undefined);
|
|
2530
3127
|
}
|
|
2531
|
-
}), [
|
|
2532
|
-
var
|
|
2533
|
-
var
|
|
2534
|
-
var
|
|
2535
|
-
var
|
|
2536
|
-
var
|
|
3128
|
+
}), [ N, D, P ]);
|
|
3129
|
+
var B = p()(" ", c);
|
|
3130
|
+
var M = function e(n) {
|
|
3131
|
+
var r = Math.floor(n / c);
|
|
3132
|
+
var a = n % c;
|
|
3133
|
+
var s = g()(r, (function(e) {
|
|
2537
3134
|
|
|
2538
|
-
return t().createElement(
|
|
3135
|
+
return t().createElement(T, {
|
|
2539
3136
|
key: e.toString()
|
|
2540
|
-
},
|
|
3137
|
+
}, B);
|
|
2541
3138
|
}));
|
|
2542
|
-
if (
|
|
2543
|
-
|
|
3139
|
+
if (a) {
|
|
3140
|
+
s.push(p()(" ", a));
|
|
2544
3141
|
}
|
|
2545
|
-
return
|
|
3142
|
+
return s;
|
|
2546
3143
|
};
|
|
2547
|
-
var
|
|
3144
|
+
var j = d ? u()(ee, d) > -1 : true;
|
|
2548
3145
|
(0, e.useEffect)((function() {
|
|
2549
3146
|
// a fix for SUI-5425, where the Markdown component doesn't pass a valid language in some circumstances
|
|
2550
3147
|
if (false) {}
|
|
2551
|
-
}), [
|
|
2552
|
-
var
|
|
2553
|
-
var
|
|
2554
|
-
var
|
|
3148
|
+
}), [ j, d, m ]);
|
|
3149
|
+
var H = j && d ? d : m;
|
|
3150
|
+
var q = ne(I, H);
|
|
3151
|
+
var X = te(H);
|
|
2555
3152
|
var K = function e(n) {
|
|
2556
|
-
return
|
|
3153
|
+
return s()(n).map((function(n, r) {
|
|
2557
3154
|
if (typeof n === "string") {
|
|
2558
3155
|
if (!y) {
|
|
2559
3156
|
return n;
|
|
2560
3157
|
}
|
|
2561
|
-
var
|
|
2562
|
-
if (
|
|
3158
|
+
var a = n.split("\n");
|
|
3159
|
+
if (a.length === 1) {
|
|
2563
3160
|
return n;
|
|
2564
3161
|
}
|
|
2565
|
-
return o()(
|
|
2566
|
-
var
|
|
2567
|
-
var
|
|
2568
|
-
if (!
|
|
2569
|
-
|
|
3162
|
+
return o()(a.map((function(e, n) {
|
|
3163
|
+
var a = n === 0 ? [] : [ "\n" ];
|
|
3164
|
+
var s = e.match(/^(\s+)(.*)/);
|
|
3165
|
+
if (!s) {
|
|
3166
|
+
a.push(e);
|
|
2570
3167
|
} else {
|
|
2571
|
-
|
|
2572
|
-
key: "".concat(
|
|
2573
|
-
},
|
|
3168
|
+
a.push( t().createElement("span", {
|
|
3169
|
+
key: "".concat(r.toString(), ":").concat(n.toString())
|
|
3170
|
+
}, M(s[1].length)), s[2]);
|
|
2574
3171
|
}
|
|
2575
|
-
return
|
|
3172
|
+
return a;
|
|
2576
3173
|
})));
|
|
2577
3174
|
}
|
|
2578
|
-
var
|
|
3175
|
+
var s = typeof n.content === "string" ? n.content : e(n.content);
|
|
2579
3176
|
|
|
2580
3177
|
// eslint-disable-next-line react/no-array-index-key
|
|
2581
|
-
return t().createElement(
|
|
3178
|
+
return t().createElement(R, {
|
|
2582
3179
|
"data-part-type": n.type,
|
|
2583
3180
|
partType: n.type,
|
|
2584
|
-
key:
|
|
2585
|
-
},
|
|
3181
|
+
key: r.toString()
|
|
3182
|
+
}, s);
|
|
2586
3183
|
}));
|
|
2587
3184
|
};
|
|
2588
|
-
var
|
|
3185
|
+
var Z = K(q);
|
|
2589
3186
|
|
|
2590
|
-
return t().createElement(
|
|
3187
|
+
return t().createElement(x, W({
|
|
2591
3188
|
"data-test": "code",
|
|
2592
3189
|
ref: $,
|
|
2593
|
-
tabIndex:
|
|
2594
|
-
$containerAppearance:
|
|
3190
|
+
tabIndex: L,
|
|
3191
|
+
$containerAppearance: a,
|
|
2595
3192
|
$showLineNumbers: S,
|
|
2596
|
-
$counterReset:
|
|
2597
|
-
},
|
|
2598
|
-
containerAppearance:
|
|
2599
|
-
value:
|
|
2600
|
-
}), t().createElement(
|
|
2601
|
-
className: "language-".concat(
|
|
2602
|
-
$isPlaintext:
|
|
2603
|
-
},
|
|
2604
|
-
containerAppearance:
|
|
2605
|
-
width:
|
|
2606
|
-
highlight:
|
|
3193
|
+
$counterReset: v && v - 1
|
|
3194
|
+
}, w), S && t().createElement(G, {
|
|
3195
|
+
containerAppearance: a,
|
|
3196
|
+
value: I
|
|
3197
|
+
}), t().createElement(k, {
|
|
3198
|
+
className: "language-".concat(H),
|
|
3199
|
+
$isPlaintext: X
|
|
3200
|
+
}, Z), b && t().createElement(U, {
|
|
3201
|
+
containerAppearance: a,
|
|
3202
|
+
width: D,
|
|
3203
|
+
highlight: b
|
|
2607
3204
|
}));
|
|
2608
3205
|
}
|
|
2609
|
-
|
|
2610
|
-
/* harmony default export */ const
|
|
3206
|
+
ae.propTypes = re;
|
|
3207
|
+
/* harmony default export */ const se = ae;
|
|
2611
3208
|
}) // CONCATENATED MODULE: ./src/Code/index.ts
|
|
2612
3209
|
();
|
|
2613
|
-
module.exports =
|
|
3210
|
+
module.exports = r;
|
|
2614
3211
|
/******/})();
|