@splunk/react-ui 4.21.0 → 4.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/Accordion.js +425 -325
  2. package/Anchor.js +147 -117
  3. package/Animation.js +142 -94
  4. package/AnimationToggle.js +197 -193
  5. package/Box.js +145 -118
  6. package/Breadcrumbs.js +288 -206
  7. package/Button.js +488 -465
  8. package/ButtonGroup.js +160 -128
  9. package/ButtonSimple.js +543 -462
  10. package/CHANGELOG.md +7 -2
  11. package/Calendar.js +1111 -1001
  12. package/Card.js +771 -598
  13. package/CardLayout.js +205 -147
  14. package/Chip.js +509 -488
  15. package/Clickable.js +414 -352
  16. package/CloseButton.js +165 -142
  17. package/Code.js +1808 -2084
  18. package/Code.js.LICENSE.txt +8 -0
  19. package/CollapsiblePanel.js +586 -519
  20. package/Color.js +1066 -1069
  21. package/ColumnLayout.js +402 -363
  22. package/ComboBox.js +891 -794
  23. package/Concertina.js +997 -802
  24. package/ControlGroup.js +687 -594
  25. package/Date.js +567 -547
  26. package/DefinitionList.js +308 -234
  27. package/Divider.js +149 -118
  28. package/Dropdown.js +459 -416
  29. package/DualListbox.js +1479 -1541
  30. package/EventListener.js +94 -97
  31. package/File.js +1051 -969
  32. package/FormRows.js +883 -696
  33. package/Heading.js +216 -193
  34. package/Image.js +446 -402
  35. package/JSONTree.js +690 -551
  36. package/Layer.js +437 -410
  37. package/Link.js +336 -255
  38. package/List.js +213 -161
  39. package/Markdown.js +509 -487
  40. package/Menu.js +1105 -1056
  41. package/Message.js +475 -441
  42. package/MessageBar.js +387 -373
  43. package/Modal.js +810 -634
  44. package/ModalLayer.js +326 -243
  45. package/Monogram.js +308 -276
  46. package/Multiselect.js +3550 -3364
  47. package/Number.js +729 -687
  48. package/Paginator.js +510 -449
  49. package/Paragraph.js +145 -112
  50. package/Popover.js +1459 -1432
  51. package/Progress.js +301 -246
  52. package/RadioBar.js +610 -527
  53. package/RadioList.js +483 -444
  54. package/Resize.js +530 -489
  55. package/ResultsMenu.js +494 -455
  56. package/ScreenReaderContent.js +142 -111
  57. package/Scroll.js +595 -456
  58. package/ScrollContainerContext.js +197 -206
  59. package/Search.js +744 -650
  60. package/Select.js +2442 -2345
  61. package/SidePanel.js +390 -284
  62. package/Slider.js +669 -676
  63. package/SlidingPanels.js +639 -503
  64. package/SplitButton.js +464 -367
  65. package/StaticContent.js +161 -133
  66. package/StepBar.js +386 -358
  67. package/Switch.js +710 -640
  68. package/TabBar.js +726 -680
  69. package/TabLayout.js +406 -322
  70. package/Table.js +4842 -4616
  71. package/Text.js +1170 -1138
  72. package/TextArea.js +1102 -1090
  73. package/Tooltip.js +624 -581
  74. package/TransitionOpen.js +489 -422
  75. package/Typography.js +176 -153
  76. package/WaitSpinner.js +230 -206
  77. package/package.json +5 -5
  78. package/types/src/JSONTree/JSONTreeContext.d.ts +7 -0
  79. package/types/src/JSONTree/TreeNode.d.ts +5 -0
  80. package/useForceUpdate.js +112 -82
  81. package/useKeyPress.js +74 -71
  82. package/usePrevious.js +65 -65
  83. package/useRovingFocus.js +122 -138
package/Code.js CHANGED
@@ -1,43 +1,29 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ var __webpack_modules__ = ({
3
-
4
- /***/ 74:
5
- /***/ ((module) => {
6
-
7
-
8
- (function() {
9
- var window = undefined;
10
- var global = undefined;
11
- /// <reference lib="WebWorker"/>
12
-
13
- var _self = (typeof window !== 'undefined')
14
- ? window // if in browser
15
- : (
16
- (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
17
- ? self // if in worker
18
- : {} // if in node js
19
- );
20
-
21
- /**
1
+ /*! For license information please see Code.js.LICENSE.txt */
2
+ /******/ (() => {
3
+ // webpackBootstrap
4
+ /******/ var e = {
5
+ /***/ 74:
6
+ /***/ e => {
7
+ (function() {
8
+ var t = undefined;
9
+ var a = undefined;
10
+ /// <reference lib="WebWorker"/>
11
+ var n = typeof t !== "undefined" ? t : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
12
+ /**
22
13
  * Prism: Lightweight, robust, elegant syntax highlighting
23
14
  *
24
15
  * @license MIT <https://opensource.org/licenses/MIT>
25
16
  * @author Lea Verou <https://lea.verou.me>
26
17
  * @namespace
27
18
  * @public
28
- */
29
- var Prism = (function (_self) {
30
-
31
- // Private helper vars
32
- var lang = /\blang(?:uage)?-([\w-]+)\b/i;
33
- var uniqueId = 0;
34
-
35
- // The grammar object for plaintext
36
- var plainTextGrammar = {};
37
-
38
-
39
- var _ = {
40
- /**
19
+ */ var r = function(e) {
20
+ // Private helper vars
21
+ var a = /\blang(?:uage)?-([\w-]+)\b/i;
22
+ var n = 0;
23
+ // The grammar object for plaintext
24
+ var r = {};
25
+ var s = {
26
+ /**
41
27
  * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
42
28
  * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
43
29
  * additional languages or plugins yourself.
@@ -58,10 +44,9 @@ var Prism = (function (_self) {
58
44
  * @memberof Prism
59
45
  * @public
60
46
  */
61
- manual: _self.Prism && _self.Prism.manual,
62
- disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
63
-
64
- /**
47
+ manual: e.Prism && e.Prism.manual,
48
+ disableWorkerMessageHandler: e.Prism && e.Prism.disableWorkerMessageHandler,
49
+ /**
65
50
  * A namespace for utility methods.
66
51
  *
67
52
  * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
@@ -70,18 +55,17 @@ var Prism = (function (_self) {
70
55
  * @namespace
71
56
  * @memberof Prism
72
57
  */
73
- util: {
74
- encode: function encode(tokens) {
75
- if (tokens instanceof Token) {
76
- return new Token(tokens.type, encode(tokens.content), tokens.alias);
77
- } else if (Array.isArray(tokens)) {
78
- return tokens.map(encode);
79
- } else {
80
- return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
81
- }
82
- },
83
-
84
- /**
58
+ util: {
59
+ encode: function e(t) {
60
+ if (t instanceof i) {
61
+ return new i(t.type, e(t.content), t.alias);
62
+ } else if (Array.isArray(t)) {
63
+ return t.map(e);
64
+ } else {
65
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\u00a0/g, " ");
66
+ }
67
+ },
68
+ /**
85
69
  * Returns the name of the type of the given value.
86
70
  *
87
71
  * @param {any} o
@@ -97,24 +81,24 @@ var Prism = (function (_self) {
97
81
  * type(String) === 'Function'
98
82
  * type(/abc+/) === 'RegExp'
99
83
  */
100
- type: function (o) {
101
- return Object.prototype.toString.call(o).slice(8, -1);
102
- },
103
-
104
- /**
84
+ type: function(e) {
85
+ return Object.prototype.toString.call(e).slice(8, -1);
86
+ },
87
+ /**
105
88
  * Returns a unique number for the given object. Later calls will still return the same number.
106
89
  *
107
90
  * @param {Object} obj
108
91
  * @returns {number}
109
92
  */
110
- objId: function (obj) {
111
- if (!obj['__id']) {
112
- Object.defineProperty(obj, '__id', { value: ++uniqueId });
113
- }
114
- return obj['__id'];
115
- },
116
-
117
- /**
93
+ objId: function(e) {
94
+ if (!e["__id"]) {
95
+ Object.defineProperty(e, "__id", {
96
+ value: ++n
97
+ });
98
+ }
99
+ return e["__id"];
100
+ },
101
+ /**
118
102
  * Creates a deep clone of the given object.
119
103
  *
120
104
  * The main intended use of this function is to clone language definitions.
@@ -124,47 +108,44 @@ var Prism = (function (_self) {
124
108
  * @returns {T}
125
109
  * @template T
126
110
  */
127
- clone: function deepClone(o, visited) {
128
- visited = visited || {};
129
-
130
- var clone; var id;
131
- switch (_.util.type(o)) {
132
- case 'Object':
133
- id = _.util.objId(o);
134
- if (visited[id]) {
135
- return visited[id];
136
- }
137
- clone = /** @type {Record<string, any>} */ ({});
138
- visited[id] = clone;
139
-
140
- for (var key in o) {
141
- if (o.hasOwnProperty(key)) {
142
- clone[key] = deepClone(o[key], visited);
143
- }
144
- }
145
-
146
- return /** @type {any} */ (clone);
147
-
148
- case 'Array':
149
- id = _.util.objId(o);
150
- if (visited[id]) {
151
- return visited[id];
152
- }
153
- clone = [];
154
- visited[id] = clone;
155
-
156
- (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
157
- clone[i] = deepClone(v, visited);
158
- });
159
-
160
- return /** @type {any} */ (clone);
161
-
162
- default:
163
- return o;
164
- }
165
- },
166
-
167
- /**
111
+ clone: function e(t, a) {
112
+ a = a || {};
113
+ var n;
114
+ var r;
115
+ switch (s.util.type(t)) {
116
+ case "Object":
117
+ r = s.util.objId(t);
118
+ if (a[r]) {
119
+ return a[r];
120
+ }
121
+ n = /** @type {Record<string, any>} */ {};
122
+ a[r] = n;
123
+ for (var i in t) {
124
+ if (t.hasOwnProperty(i)) {
125
+ n[i] = e(t[i], a);
126
+ }
127
+ }
128
+ /** @type {any} */
129
+ return n;
130
+
131
+ case "Array":
132
+ r = s.util.objId(t);
133
+ if (a[r]) {
134
+ return a[r];
135
+ }
136
+ n = [];
137
+ a[r] = n;
138
+ /** @type {Array} */ /** @type {any} */ t.forEach((function(t, r) {
139
+ n[r] = e(t, a);
140
+ }));
141
+ /** @type {any} */
142
+ return n;
143
+
144
+ default:
145
+ return t;
146
+ }
147
+ },
148
+ /**
168
149
  * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
169
150
  *
170
151
  * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
@@ -172,59 +153,54 @@ var Prism = (function (_self) {
172
153
  * @param {Element} element
173
154
  * @returns {string}
174
155
  */
175
- getLanguage: function (element) {
176
- while (element && !lang.test(element.className)) {
177
- element = element.parentElement;
178
- }
179
- if (element) {
180
- return (element.className.match(lang) || [, 'none'])[1].toLowerCase();
181
- }
182
- return 'none';
183
- },
184
-
185
- /**
156
+ getLanguage: function(e) {
157
+ while (e && !a.test(e.className)) {
158
+ e = e.parentElement;
159
+ }
160
+ if (e) {
161
+ return (e.className.match(a) || [ , "none" ])[1].toLowerCase();
162
+ }
163
+ return "none";
164
+ },
165
+ /**
186
166
  * Returns the script element that is currently executing.
187
167
  *
188
168
  * This does __not__ work for line script element.
189
169
  *
190
170
  * @returns {HTMLScriptElement | null}
191
171
  */
192
- currentScript: function () {
193
- if (typeof document === 'undefined') {
194
- return null;
195
- }
196
- if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
197
- return /** @type {any} */ (document.currentScript);
198
- }
199
-
200
- // IE11 workaround
201
- // we'll get the src of the current script by parsing IE11's error stack trace
202
- // this will not work for inline scripts
203
-
204
- try {
205
- throw new Error();
206
- } catch (err) {
207
- // Get file src url from stack. Specifically works with the format of stack traces in IE.
208
- // A stack will look like this:
209
- //
210
- // Error
211
- // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
212
- // at Global code (http://localhost/components/prism-core.js:606:1)
213
-
214
- var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
215
- if (src) {
216
- var scripts = document.getElementsByTagName('script');
217
- for (var i in scripts) {
218
- if (scripts[i].src == src) {
219
- return scripts[i];
220
- }
221
- }
222
- }
223
- return null;
224
- }
225
- },
226
-
227
- /**
172
+ currentScript: function() {
173
+ if (typeof document === "undefined") {
174
+ return null;
175
+ }
176
+ if ("currentScript" in document && 1 < 2 /* hack to trip TS' flow analysis */) {
177
+ /** @type {any} */
178
+ return document.currentScript;
179
+ }
180
+ // IE11 workaround
181
+ // we'll get the src of the current script by parsing IE11's error stack trace
182
+ // this will not work for inline scripts
183
+ try {
184
+ throw new Error;
185
+ } catch (n) {
186
+ // Get file src url from stack. Specifically works with the format of stack traces in IE.
187
+ // A stack will look like this:
188
+ // Error
189
+ // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
190
+ // at Global code (http://localhost/components/prism-core.js:606:1)
191
+ var e = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(n.stack) || [])[1];
192
+ if (e) {
193
+ var t = document.getElementsByTagName("script");
194
+ for (var a in t) {
195
+ if (t[a].src == e) {
196
+ return t[a];
197
+ }
198
+ }
199
+ }
200
+ return null;
201
+ }
202
+ },
203
+ /**
228
204
  * Returns whether a given class is active for `element`.
229
205
  *
230
206
  * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
@@ -243,40 +219,37 @@ var Prism = (function (_self) {
243
219
  * @param {boolean} [defaultActivation=false]
244
220
  * @returns {boolean}
245
221
  */
246
- isActive: function (element, className, defaultActivation) {
247
- var no = 'no-' + className;
248
-
249
- while (element) {
250
- var classList = element.classList;
251
- if (classList.contains(className)) {
252
- return true;
253
- }
254
- if (classList.contains(no)) {
255
- return false;
256
- }
257
- element = element.parentElement;
258
- }
259
- return !!defaultActivation;
260
- }
261
- },
262
-
263
- /**
222
+ isActive: function(e, t, a) {
223
+ var n = "no-" + t;
224
+ while (e) {
225
+ var r = e.classList;
226
+ if (r.contains(t)) {
227
+ return true;
228
+ }
229
+ if (r.contains(n)) {
230
+ return false;
231
+ }
232
+ e = e.parentElement;
233
+ }
234
+ return !!a;
235
+ }
236
+ },
237
+ /**
264
238
  * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
265
239
  *
266
240
  * @namespace
267
241
  * @memberof Prism
268
242
  * @public
269
243
  */
270
- languages: {
271
- /**
244
+ languages: {
245
+ /**
272
246
  * The grammar for plain, unformatted text.
273
247
  */
274
- plain: plainTextGrammar,
275
- plaintext: plainTextGrammar,
276
- text: plainTextGrammar,
277
- txt: plainTextGrammar,
278
-
279
- /**
248
+ plain: r,
249
+ plaintext: r,
250
+ text: r,
251
+ txt: r,
252
+ /**
280
253
  * Creates a deep copy of the language with the given id and appends the given tokens.
281
254
  *
282
255
  * If a token in `redef` also appears in the copied language, then the existing token in the copied language
@@ -304,17 +277,14 @@ var Prism = (function (_self) {
304
277
  * 'color': /\b(?:red|green|blue)\b/
305
278
  * });
306
279
  */
307
- extend: function (id, redef) {
308
- var lang = _.util.clone(_.languages[id]);
309
-
310
- for (var key in redef) {
311
- lang[key] = redef[key];
312
- }
313
-
314
- return lang;
315
- },
316
-
317
- /**
280
+ extend: function(e, t) {
281
+ var a = s.util.clone(s.languages[e]);
282
+ for (var n in t) {
283
+ a[n] = t[n];
284
+ }
285
+ return a;
286
+ },
287
+ /**
318
288
  * Inserts tokens _before_ another token in a language definition or any other grammar.
319
289
  *
320
290
  * ## Usage
@@ -389,71 +359,57 @@ var Prism = (function (_self) {
389
359
  * @returns {Grammar} The new grammar object.
390
360
  * @public
391
361
  */
392
- insertBefore: function (inside, before, insert, root) {
393
- root = root || /** @type {any} */ (_.languages);
394
- var grammar = root[inside];
395
- /** @type {Grammar} */
396
- var ret = {};
397
-
398
- for (var token in grammar) {
399
- if (grammar.hasOwnProperty(token)) {
400
-
401
- if (token == before) {
402
- for (var newToken in insert) {
403
- if (insert.hasOwnProperty(newToken)) {
404
- ret[newToken] = insert[newToken];
405
- }
406
- }
407
- }
408
-
409
- // Do not insert token which also occur in insert. See #1525
410
- if (!insert.hasOwnProperty(token)) {
411
- ret[token] = grammar[token];
412
- }
413
- }
414
- }
415
-
416
- var old = root[inside];
417
- root[inside] = ret;
418
-
419
- // Update references in other language definitions
420
- _.languages.DFS(_.languages, function (key, value) {
421
- if (value === old && key != inside) {
422
- this[key] = ret;
423
- }
424
- });
425
-
426
- return ret;
427
- },
428
-
429
- // Traverse a language definition with Depth First Search
430
- DFS: function DFS(o, callback, type, visited) {
431
- visited = visited || {};
432
-
433
- var objId = _.util.objId;
434
-
435
- for (var i in o) {
436
- if (o.hasOwnProperty(i)) {
437
- callback.call(o, i, o[i], type || i);
438
-
439
- var property = o[i];
440
- var propertyType = _.util.type(property);
441
-
442
- if (propertyType === 'Object' && !visited[objId(property)]) {
443
- visited[objId(property)] = true;
444
- DFS(property, callback, null, visited);
445
- } else if (propertyType === 'Array' && !visited[objId(property)]) {
446
- visited[objId(property)] = true;
447
- DFS(property, callback, i, visited);
448
- }
449
- }
450
- }
451
- }
452
- },
453
-
454
- plugins: {},
455
-
456
- /**
362
+ insertBefore: function(e, t, a, n) {
363
+ n = n || /** @type {any} */ s.languages;
364
+ var r = n[e];
365
+ /** @type {Grammar} */ var i = {};
366
+ for (var o in r) {
367
+ if (r.hasOwnProperty(o)) {
368
+ if (o == t) {
369
+ for (var l in a) {
370
+ if (a.hasOwnProperty(l)) {
371
+ i[l] = a[l];
372
+ }
373
+ }
374
+ }
375
+ // Do not insert token which also occur in insert. See #1525
376
+ if (!a.hasOwnProperty(o)) {
377
+ i[o] = r[o];
378
+ }
379
+ }
380
+ }
381
+ var u = n[e];
382
+ n[e] = i;
383
+ // Update references in other language definitions
384
+ s.languages.DFS(s.languages, (function(t, a) {
385
+ if (a === u && t != e) {
386
+ this[t] = i;
387
+ }
388
+ }));
389
+ return i;
390
+ },
391
+ // Traverse a language definition with Depth First Search
392
+ DFS: function e(t, a, n, r) {
393
+ r = r || {};
394
+ var i = s.util.objId;
395
+ for (var o in t) {
396
+ if (t.hasOwnProperty(o)) {
397
+ a.call(t, o, t[o], n || o);
398
+ var l = t[o];
399
+ var u = s.util.type(l);
400
+ if (u === "Object" && !r[i(l)]) {
401
+ r[i(l)] = true;
402
+ e(l, a, null, r);
403
+ } else if (u === "Array" && !r[i(l)]) {
404
+ r[i(l)] = true;
405
+ e(l, a, o, r);
406
+ }
407
+ }
408
+ }
409
+ }
410
+ },
411
+ plugins: {},
412
+ /**
457
413
  * This is the most high-level function in Prism’s API.
458
414
  * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
459
415
  * each one of them.
@@ -465,11 +421,10 @@ var Prism = (function (_self) {
465
421
  * @memberof Prism
466
422
  * @public
467
423
  */
468
- highlightAll: function (async, callback) {
469
- _.highlightAllUnder(document, async, callback);
470
- },
471
-
472
- /**
424
+ highlightAll: function(e, t) {
425
+ s.highlightAllUnder(document, e, t);
426
+ },
427
+ /**
473
428
  * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
474
429
  * {@link Prism.highlightElement} on each one of them.
475
430
  *
@@ -484,25 +439,20 @@ var Prism = (function (_self) {
484
439
  * @memberof Prism
485
440
  * @public
486
441
  */
487
- highlightAllUnder: function (container, async, callback) {
488
- var env = {
489
- callback: callback,
490
- container: container,
491
- selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
492
- };
493
-
494
- _.hooks.run('before-highlightall', env);
495
-
496
- env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
497
-
498
- _.hooks.run('before-all-elements-highlight', env);
499
-
500
- for (var i = 0, element; (element = env.elements[i++]);) {
501
- _.highlightElement(element, async === true, env.callback);
502
- }
503
- },
504
-
505
- /**
442
+ highlightAllUnder: function(e, t, a) {
443
+ var n = {
444
+ callback: a,
445
+ container: e,
446
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
447
+ };
448
+ s.hooks.run("before-highlightall", n);
449
+ n.elements = Array.prototype.slice.apply(n.container.querySelectorAll(n.selector));
450
+ s.hooks.run("before-all-elements-highlight", n);
451
+ for (var r = 0, i; i = n.elements[r++]; ) {
452
+ s.highlightElement(i, t === true, n.callback);
453
+ }
454
+ },
455
+ /**
506
456
  * Highlights the code inside a single element.
507
457
  *
508
458
  * The following hooks will be run:
@@ -530,80 +480,63 @@ var Prism = (function (_self) {
530
480
  * @memberof Prism
531
481
  * @public
532
482
  */
533
- highlightElement: function (element, async, callback) {
534
- // Find language
535
- var language = _.util.getLanguage(element);
536
- var grammar = _.languages[language];
537
-
538
- // Set language on the element, if not present
539
- element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
540
-
541
- // Set language on the parent, for styling
542
- var parent = element.parentElement;
543
- if (parent && parent.nodeName.toLowerCase() === 'pre') {
544
- parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
545
- }
546
-
547
- var code = element.textContent;
548
-
549
- var env = {
550
- element: element,
551
- language: language,
552
- grammar: grammar,
553
- code: code
554
- };
555
-
556
- function insertHighlightedCode(highlightedCode) {
557
- env.highlightedCode = highlightedCode;
558
-
559
- _.hooks.run('before-insert', env);
560
-
561
- env.element.innerHTML = env.highlightedCode;
562
-
563
- _.hooks.run('after-highlight', env);
564
- _.hooks.run('complete', env);
565
- callback && callback.call(env.element);
566
- }
567
-
568
- _.hooks.run('before-sanity-check', env);
569
-
570
- // plugins may change/add the parent/element
571
- parent = env.element.parentElement;
572
- if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
573
- parent.setAttribute('tabindex', '0');
574
- }
575
-
576
- if (!env.code) {
577
- _.hooks.run('complete', env);
578
- callback && callback.call(env.element);
579
- return;
580
- }
581
-
582
- _.hooks.run('before-highlight', env);
583
-
584
- if (!env.grammar) {
585
- insertHighlightedCode(_.util.encode(env.code));
586
- return;
587
- }
588
-
589
- if (async && _self.Worker) {
590
- var worker = new Worker(_.filename);
591
-
592
- worker.onmessage = function (evt) {
593
- insertHighlightedCode(evt.data);
594
- };
595
-
596
- worker.postMessage(JSON.stringify({
597
- language: env.language,
598
- code: env.code,
599
- immediateClose: true
600
- }));
601
- } else {
602
- insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
603
- }
604
- },
605
-
606
- /**
483
+ highlightElement: function(t, n, r) {
484
+ // Find language
485
+ var i = s.util.getLanguage(t);
486
+ var o = s.languages[i];
487
+ // Set language on the element, if not present
488
+ t.className = t.className.replace(a, "").replace(/\s+/g, " ") + " language-" + i;
489
+ // Set language on the parent, for styling
490
+ var l = t.parentElement;
491
+ if (l && l.nodeName.toLowerCase() === "pre") {
492
+ l.className = l.className.replace(a, "").replace(/\s+/g, " ") + " language-" + i;
493
+ }
494
+ var u = t.textContent;
495
+ var c = {
496
+ element: t,
497
+ language: i,
498
+ grammar: o,
499
+ code: u
500
+ };
501
+ function p(e) {
502
+ c.highlightedCode = e;
503
+ s.hooks.run("before-insert", c);
504
+ c.element.innerHTML = c.highlightedCode;
505
+ s.hooks.run("after-highlight", c);
506
+ s.hooks.run("complete", c);
507
+ r && r.call(c.element);
508
+ }
509
+ s.hooks.run("before-sanity-check", c);
510
+ // plugins may change/add the parent/element
511
+ l = c.element.parentElement;
512
+ if (l && l.nodeName.toLowerCase() === "pre" && !l.hasAttribute("tabindex")) {
513
+ l.setAttribute("tabindex", "0");
514
+ }
515
+ if (!c.code) {
516
+ s.hooks.run("complete", c);
517
+ r && r.call(c.element);
518
+ return;
519
+ }
520
+ s.hooks.run("before-highlight", c);
521
+ if (!c.grammar) {
522
+ p(s.util.encode(c.code));
523
+ return;
524
+ }
525
+ if (n && e.Worker) {
526
+ var d = new Worker(s.filename);
527
+ d.onmessage = function(e) {
528
+ p(e.data);
529
+ };
530
+ d.postMessage(JSON.stringify({
531
+ language: c.language,
532
+ code: c.code,
533
+ immediateClose: true
534
+ }));
535
+ } else {
536
+ p(s.highlight(c.code, c.grammar, c.language));
537
+ }
538
+ },
539
+ /**
607
540
  * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
608
541
  * and the language definitions to use, and returns a string with the HTML produced.
609
542
  *
@@ -623,19 +556,18 @@ var Prism = (function (_self) {
623
556
  * @example
624
557
  * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
625
558
  */
626
- highlight: function (text, grammar, language) {
627
- var env = {
628
- code: text,
629
- grammar: grammar,
630
- language: language
631
- };
632
- _.hooks.run('before-tokenize', env);
633
- env.tokens = _.tokenize(env.code, env.grammar);
634
- _.hooks.run('after-tokenize', env);
635
- return Token.stringify(_.util.encode(env.tokens), env.language);
636
- },
637
-
638
- /**
559
+ highlight: function(e, t, a) {
560
+ var n = {
561
+ code: e,
562
+ grammar: t,
563
+ language: a
564
+ };
565
+ s.hooks.run("before-tokenize", n);
566
+ n.tokens = s.tokenize(n.code, n.grammar);
567
+ s.hooks.run("after-tokenize", n);
568
+ return i.stringify(s.util.encode(n.tokens), n.language);
569
+ },
570
+ /**
639
571
  * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
640
572
  * and the language definitions to use, and returns an array with the tokenized code.
641
573
  *
@@ -659,33 +591,27 @@ var Prism = (function (_self) {
659
591
  * }
660
592
  * });
661
593
  */
662
- tokenize: function (text, grammar) {
663
- var rest = grammar.rest;
664
- if (rest) {
665
- for (var token in rest) {
666
- grammar[token] = rest[token];
667
- }
668
-
669
- delete grammar.rest;
670
- }
671
-
672
- var tokenList = new LinkedList();
673
- addAfter(tokenList, tokenList.head, text);
674
-
675
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
676
-
677
- return toArray(tokenList);
678
- },
679
-
680
- /**
594
+ tokenize: function(e, t) {
595
+ var a = t.rest;
596
+ if (a) {
597
+ for (var n in a) {
598
+ t[n] = a[n];
599
+ }
600
+ delete t.rest;
601
+ }
602
+ var r = new u;
603
+ c(r, r.head, e);
604
+ l(e, r, t, r.head, 0);
605
+ return d(r);
606
+ },
607
+ /**
681
608
  * @namespace
682
609
  * @memberof Prism
683
610
  * @public
684
611
  */
685
- hooks: {
686
- all: {},
687
-
688
- /**
612
+ hooks: {
613
+ all: {},
614
+ /**
689
615
  * Adds the given callback to the list of callbacks for the given hook.
690
616
  *
691
617
  * The callback will be invoked when the hook it is registered for is run.
@@ -697,15 +623,12 @@ var Prism = (function (_self) {
697
623
  * @param {HookCallback} callback The callback function which is given environment variables.
698
624
  * @public
699
625
  */
700
- add: function (name, callback) {
701
- var hooks = _.hooks.all;
702
-
703
- hooks[name] = hooks[name] || [];
704
-
705
- hooks[name].push(callback);
706
- },
707
-
708
- /**
626
+ add: function(e, t) {
627
+ var a = s.hooks.all;
628
+ a[e] = a[e] || [];
629
+ a[e].push(t);
630
+ },
631
+ /**
709
632
  * Runs a hook invoking all registered callbacks with the given environment variables.
710
633
  *
711
634
  * Callbacks will be invoked synchronously and in the order in which they were registered.
@@ -714,30 +637,24 @@ var Prism = (function (_self) {
714
637
  * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
715
638
  * @public
716
639
  */
717
- run: function (name, env) {
718
- var callbacks = _.hooks.all[name];
719
-
720
- if (!callbacks || !callbacks.length) {
721
- return;
722
- }
723
-
724
- for (var i = 0, callback; (callback = callbacks[i++]);) {
725
- callback(env);
726
- }
727
- }
728
- },
729
-
730
- Token: Token
731
- };
732
- _self.Prism = _;
733
-
734
-
735
- // Typescript note:
736
- // The following can be used to import the Token type in JSDoc:
737
- //
738
- // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
739
-
740
- /**
640
+ run: function(e, t) {
641
+ var a = s.hooks.all[e];
642
+ if (!a || !a.length) {
643
+ return;
644
+ }
645
+ for (var n = 0, r; r = a[n++]; ) {
646
+ r(t);
647
+ }
648
+ }
649
+ },
650
+ Token: i
651
+ };
652
+ e.Prism = s;
653
+ // Typescript note:
654
+ // The following can be used to import the Token type in JSDoc:
655
+
656
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
657
+ /**
741
658
  * Creates a new token.
742
659
  *
743
660
  * @param {string} type See {@link Token#type type}
@@ -747,9 +664,8 @@ var Prism = (function (_self) {
747
664
  * @class
748
665
  * @global
749
666
  * @public
750
- */
751
- function Token(type, content, alias, matchedStr) {
752
- /**
667
+ */ function i(e, t, a, n) {
668
+ /**
753
669
  * The type of the token.
754
670
  *
755
671
  * This is usually the key of a pattern in a {@link Grammar}.
@@ -758,29 +674,26 @@ var Prism = (function (_self) {
758
674
  * @see GrammarToken
759
675
  * @public
760
676
  */
761
- this.type = type;
762
- /**
677
+ this.type = e;
678
+ /**
763
679
  * The strings or tokens contained by this token.
764
680
  *
765
681
  * This will be a token stream if the pattern matched also defined an `inside` grammar.
766
682
  *
767
683
  * @type {string | TokenStream}
768
684
  * @public
769
- */
770
- this.content = content;
771
- /**
685
+ */ this.content = t;
686
+ /**
772
687
  * The alias(es) of the token.
773
688
  *
774
689
  * @type {string|string[]}
775
690
  * @see GrammarToken
776
691
  * @public
777
- */
778
- this.alias = alias;
779
- // Copy of the full string this token was created from
780
- this.length = (matchedStr || '').length | 0;
781
- }
782
-
783
- /**
692
+ */ this.alias = a;
693
+ // Copy of the full string this token was created from
694
+ this.length = (n || "").length | 0;
695
+ }
696
+ /**
784
697
  * A token stream is an array of strings and {@link Token Token} objects.
785
698
  *
786
699
  * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
@@ -795,8 +708,7 @@ var Prism = (function (_self) {
795
708
  * @global
796
709
  * @public
797
710
  */
798
-
799
- /**
711
+ /**
800
712
  * Converts the given token or token stream to an HTML representation.
801
713
  *
802
714
  * The following hooks will be run:
@@ -807,67 +719,58 @@ var Prism = (function (_self) {
807
719
  * @returns {string} The HTML representation of the token or token stream.
808
720
  * @memberof Token
809
721
  * @static
810
- */
811
- Token.stringify = function stringify(o, language) {
812
- if (typeof o == 'string') {
813
- return o;
814
- }
815
- if (Array.isArray(o)) {
816
- var s = '';
817
- o.forEach(function (e) {
818
- s += stringify(e, language);
819
- });
820
- return s;
821
- }
822
-
823
- var env = {
824
- type: o.type,
825
- content: stringify(o.content, language),
826
- tag: 'span',
827
- classes: ['token', o.type],
828
- attributes: {},
829
- language: language
830
- };
831
-
832
- var aliases = o.alias;
833
- if (aliases) {
834
- if (Array.isArray(aliases)) {
835
- Array.prototype.push.apply(env.classes, aliases);
836
- } else {
837
- env.classes.push(aliases);
838
- }
839
- }
840
-
841
- _.hooks.run('wrap', env);
842
-
843
- var attributes = '';
844
- for (var name in env.attributes) {
845
- attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
846
- }
847
-
848
- return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
849
- };
850
-
851
- /**
722
+ */ i.stringify = function e(t, a) {
723
+ if (typeof t == "string") {
724
+ return t;
725
+ }
726
+ if (Array.isArray(t)) {
727
+ var n = "";
728
+ t.forEach((function(t) {
729
+ n += e(t, a);
730
+ }));
731
+ return n;
732
+ }
733
+ var r = {
734
+ type: t.type,
735
+ content: e(t.content, a),
736
+ tag: "span",
737
+ classes: [ "token", t.type ],
738
+ attributes: {},
739
+ language: a
740
+ };
741
+ var i = t.alias;
742
+ if (i) {
743
+ if (Array.isArray(i)) {
744
+ Array.prototype.push.apply(r.classes, i);
745
+ } else {
746
+ r.classes.push(i);
747
+ }
748
+ }
749
+ s.hooks.run("wrap", r);
750
+ var o = "";
751
+ for (var l in r.attributes) {
752
+ o += " " + l + '="' + (r.attributes[l] || "").replace(/"/g, "&quot;") + '"';
753
+ }
754
+ return "<" + r.tag + ' class="' + r.classes.join(" ") + '"' + o + ">" + r.content + "</" + r.tag + ">";
755
+ };
756
+ /**
852
757
  * @param {RegExp} pattern
853
758
  * @param {number} pos
854
759
  * @param {string} text
855
760
  * @param {boolean} lookbehind
856
761
  * @returns {RegExpExecArray | null}
857
- */
858
- function matchPattern(pattern, pos, text, lookbehind) {
859
- pattern.lastIndex = pos;
860
- var match = pattern.exec(text);
861
- if (match && lookbehind && match[1]) {
862
- // change the match to remove the text matched by the Prism lookbehind group
863
- var lookbehindLength = match[1].length;
864
- match.index += lookbehindLength;
865
- match[0] = match[0].slice(lookbehindLength);
866
- }
867
- return match;
868
- }
869
-
870
- /**
762
+ */ function o(e, t, a, n) {
763
+ e.lastIndex = t;
764
+ var r = e.exec(a);
765
+ if (r && n && r[1]) {
766
+ // change the match to remove the text matched by the Prism lookbehind group
767
+ var s = r[1].length;
768
+ r.index += s;
769
+ r[0] = r[0].slice(s);
770
+ }
771
+ return r;
772
+ }
773
+ /**
871
774
  * @param {string} text
872
775
  * @param {LinkedList<string | Token>} tokenList
873
776
  * @param {any} grammar
@@ -880,155 +783,119 @@ var Prism = (function (_self) {
880
783
  * @typedef RematchOptions
881
784
  * @property {string} cause
882
785
  * @property {number} reach
883
- */
884
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
885
- for (var token in grammar) {
886
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
887
- continue;
888
- }
889
-
890
- var patterns = grammar[token];
891
- patterns = Array.isArray(patterns) ? patterns : [patterns];
892
-
893
- for (var j = 0; j < patterns.length; ++j) {
894
- if (rematch && rematch.cause == token + ',' + j) {
895
- return;
896
- }
897
-
898
- var patternObj = patterns[j];
899
- var inside = patternObj.inside;
900
- var lookbehind = !!patternObj.lookbehind;
901
- var greedy = !!patternObj.greedy;
902
- var alias = patternObj.alias;
903
-
904
- if (greedy && !patternObj.pattern.global) {
905
- // Without the global flag, lastIndex won't work
906
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
907
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
908
- }
909
-
910
- /** @type {RegExp} */
911
- var pattern = patternObj.pattern || patternObj;
912
-
913
- for ( // iterate the token list and keep track of the current token/string position
914
- var currentNode = startNode.next, pos = startPos;
915
- currentNode !== tokenList.tail;
916
- pos += currentNode.value.length, currentNode = currentNode.next
917
- ) {
918
-
919
- if (rematch && pos >= rematch.reach) {
920
- break;
921
- }
922
-
923
- var str = currentNode.value;
924
-
925
- if (tokenList.length > text.length) {
926
- // Something went terribly wrong, ABORT, ABORT!
927
- return;
928
- }
929
-
930
- if (str instanceof Token) {
931
- continue;
932
- }
933
-
934
- var removeCount = 1; // this is the to parameter of removeBetween
935
- var match;
936
-
937
- if (greedy) {
938
- match = matchPattern(pattern, pos, text, lookbehind);
939
- if (!match) {
940
- break;
941
- }
942
-
943
- var from = match.index;
944
- var to = match.index + match[0].length;
945
- var p = pos;
946
-
947
- // find the node that contains the match
948
- p += currentNode.value.length;
949
- while (from >= p) {
950
- currentNode = currentNode.next;
951
- p += currentNode.value.length;
952
- }
953
- // adjust pos (and p)
954
- p -= currentNode.value.length;
955
- pos = p;
956
-
957
- // the current node is a Token, then the match starts inside another Token, which is invalid
958
- if (currentNode.value instanceof Token) {
959
- continue;
960
- }
961
-
962
- // find the last node which is affected by this match
963
- for (
964
- var k = currentNode;
965
- k !== tokenList.tail && (p < to || typeof k.value === 'string');
966
- k = k.next
967
- ) {
968
- removeCount++;
969
- p += k.value.length;
970
- }
971
- removeCount--;
972
-
973
- // replace with the new match
974
- str = text.slice(pos, p);
975
- match.index -= pos;
976
- } else {
977
- match = matchPattern(pattern, 0, str, lookbehind);
978
- if (!match) {
979
- continue;
980
- }
981
- }
982
-
983
- // eslint-disable-next-line no-redeclare
984
- var from = match.index;
985
- var matchStr = match[0];
986
- var before = str.slice(0, from);
987
- var after = str.slice(from + matchStr.length);
988
-
989
- var reach = pos + str.length;
990
- if (rematch && reach > rematch.reach) {
991
- rematch.reach = reach;
992
- }
993
-
994
- var removeFrom = currentNode.prev;
995
-
996
- if (before) {
997
- removeFrom = addAfter(tokenList, removeFrom, before);
998
- pos += before.length;
999
- }
1000
-
1001
- removeRange(tokenList, removeFrom, removeCount);
1002
-
1003
- var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1004
- currentNode = addAfter(tokenList, removeFrom, wrapped);
1005
-
1006
- if (after) {
1007
- addAfter(tokenList, currentNode, after);
1008
- }
1009
-
1010
- if (removeCount > 1) {
1011
- // at least one Token object was removed, so we have to do some rematching
1012
- // this can only happen if the current pattern is greedy
1013
-
1014
- /** @type {RematchOptions} */
1015
- var nestedRematch = {
1016
- cause: token + ',' + j,
1017
- reach: reach
1018
- };
1019
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1020
-
1021
- // the reach might have been extended because of the rematching
1022
- if (rematch && nestedRematch.reach > rematch.reach) {
1023
- rematch.reach = nestedRematch.reach;
1024
- }
1025
- }
1026
- }
1027
- }
1028
- }
1029
- }
1030
-
1031
- /**
786
+ */ function l(e, t, a, n, r, u) {
787
+ for (var d in a) {
788
+ if (!a.hasOwnProperty(d) || !a[d]) {
789
+ continue;
790
+ }
791
+ var g = a[d];
792
+ g = Array.isArray(g) ? g : [ g ];
793
+ for (var f = 0; f < g.length; ++f) {
794
+ if (u && u.cause == d + "," + f) {
795
+ return;
796
+ }
797
+ var m = g[f];
798
+ var h = m.inside;
799
+ var v = !!m.lookbehind;
800
+ var b = !!m.greedy;
801
+ var y = m.alias;
802
+ if (b && !m.pattern.global) {
803
+ // Without the global flag, lastIndex won't work
804
+ var k = m.pattern.toString().match(/[imsuy]*$/)[0];
805
+ m.pattern = RegExp(m.pattern.source, k + "g");
806
+ }
807
+ /** @type {RegExp} */ var x = m.pattern || m;
808
+ for (// iterate the token list and keep track of the current token/string position
809
+ var S = n.next, A = r; S !== t.tail; A += S.value.length, S = S.next) {
810
+ if (u && A >= u.reach) {
811
+ break;
812
+ }
813
+ var F = S.value;
814
+ if (t.length > e.length) {
815
+ // Something went terribly wrong, ABORT, ABORT!
816
+ return;
817
+ }
818
+ if (F instanceof i) {
819
+ continue;
820
+ }
821
+ var w = 1;
822
+ // this is the to parameter of removeBetween
823
+ var E;
824
+ if (b) {
825
+ E = o(x, A, e, v);
826
+ if (!E) {
827
+ break;
828
+ }
829
+ var _ = E.index;
830
+ var O = E.index + E[0].length;
831
+ var T = A;
832
+ // find the node that contains the match
833
+ T += S.value.length;
834
+ while (_ >= T) {
835
+ S = S.next;
836
+ T += S.value.length;
837
+ }
838
+ // adjust pos (and p)
839
+ T -= S.value.length;
840
+ A = T;
841
+ // the current node is a Token, then the match starts inside another Token, which is invalid
842
+ if (S.value instanceof i) {
843
+ continue;
844
+ }
845
+ // find the last node which is affected by this match
846
+ for (var I = S; I !== t.tail && (T < O || typeof I.value === "string"); I = I.next) {
847
+ w++;
848
+ T += I.value.length;
849
+ }
850
+ w--;
851
+ // replace with the new match
852
+ F = e.slice(A, T);
853
+ E.index -= A;
854
+ } else {
855
+ E = o(x, 0, F, v);
856
+ if (!E) {
857
+ continue;
858
+ }
859
+ }
860
+ // eslint-disable-next-line no-redeclare
861
+ var _ = E.index;
862
+ var $ = E[0];
863
+ var N = F.slice(0, _);
864
+ var P = F.slice(_ + $.length);
865
+ var R = A + F.length;
866
+ if (u && R > u.reach) {
867
+ u.reach = R;
868
+ }
869
+ var C = S.prev;
870
+ if (N) {
871
+ C = c(t, C, N);
872
+ A += N.length;
873
+ }
874
+ p(t, C, w);
875
+ var D = new i(d, h ? s.tokenize($, h) : $, y, $);
876
+ S = c(t, C, D);
877
+ if (P) {
878
+ c(t, S, P);
879
+ }
880
+ if (w > 1) {
881
+ // at least one Token object was removed, so we have to do some rematching
882
+ // this can only happen if the current pattern is greedy
883
+ /** @type {RematchOptions} */
884
+ var j = {
885
+ cause: d + "," + f,
886
+ reach: R
887
+ };
888
+ l(e, t, a, S.prev, A, j);
889
+ // the reach might have been extended because of the rematching
890
+ if (u && j.reach > u.reach) {
891
+ u.reach = j.reach;
892
+ }
893
+ }
894
+ }
895
+ }
896
+ }
897
+ }
898
+ /**
1032
899
  * @typedef LinkedListNode
1033
900
  * @property {T} value
1034
901
  * @property {LinkedListNode<T> | null} prev The previous node.
@@ -1036,26 +903,27 @@ var Prism = (function (_self) {
1036
903
  * @template T
1037
904
  * @private
1038
905
  */
1039
-
1040
- /**
906
+ /**
1041
907
  * @template T
1042
908
  * @private
1043
- */
1044
- function LinkedList() {
1045
- /** @type {LinkedListNode<T>} */
1046
- var head = { value: null, prev: null, next: null };
1047
- /** @type {LinkedListNode<T>} */
1048
- var tail = { value: null, prev: head, next: null };
1049
- head.next = tail;
1050
-
1051
- /** @type {LinkedListNode<T>} */
1052
- this.head = head;
1053
- /** @type {LinkedListNode<T>} */
1054
- this.tail = tail;
1055
- this.length = 0;
1056
- }
1057
-
1058
- /**
909
+ */ function u() {
910
+ /** @type {LinkedListNode<T>} */
911
+ var e = {
912
+ value: null,
913
+ prev: null,
914
+ next: null
915
+ };
916
+ /** @type {LinkedListNode<T>} */ var t = {
917
+ value: null,
918
+ prev: e,
919
+ next: null
920
+ };
921
+ e.next = t;
922
+ /** @type {LinkedListNode<T>} */ this.head = e;
923
+ /** @type {LinkedListNode<T>} */ this.tail = t;
924
+ this.length = 0;
925
+ }
926
+ /**
1059
927
  * Adds a new node with the given value to the list.
1060
928
  *
1061
929
  * @param {LinkedList<T>} list
@@ -1063,127 +931,110 @@ var Prism = (function (_self) {
1063
931
  * @param {T} value
1064
932
  * @returns {LinkedListNode<T>} The added node.
1065
933
  * @template T
1066
- */
1067
- function addAfter(list, node, value) {
1068
- // assumes that node != list.tail && values.length >= 0
1069
- var next = node.next;
1070
-
1071
- var newNode = { value: value, prev: node, next: next };
1072
- node.next = newNode;
1073
- next.prev = newNode;
1074
- list.length++;
1075
-
1076
- return newNode;
1077
- }
1078
- /**
934
+ */ function c(e, t, a) {
935
+ // assumes that node != list.tail && values.length >= 0
936
+ var n = t.next;
937
+ var r = {
938
+ value: a,
939
+ prev: t,
940
+ next: n
941
+ };
942
+ t.next = r;
943
+ n.prev = r;
944
+ e.length++;
945
+ return r;
946
+ }
947
+ /**
1079
948
  * Removes `count` nodes after the given node. The given node will not be removed.
1080
949
  *
1081
950
  * @param {LinkedList<T>} list
1082
951
  * @param {LinkedListNode<T>} node
1083
952
  * @param {number} count
1084
953
  * @template T
1085
- */
1086
- function removeRange(list, node, count) {
1087
- var next = node.next;
1088
- for (var i = 0; i < count && next !== list.tail; i++) {
1089
- next = next.next;
1090
- }
1091
- node.next = next;
1092
- next.prev = node;
1093
- list.length -= i;
1094
- }
1095
- /**
954
+ */ function p(e, t, a) {
955
+ var n = t.next;
956
+ for (var r = 0; r < a && n !== e.tail; r++) {
957
+ n = n.next;
958
+ }
959
+ t.next = n;
960
+ n.prev = t;
961
+ e.length -= r;
962
+ }
963
+ /**
1096
964
  * @param {LinkedList<T>} list
1097
965
  * @returns {T[]}
1098
966
  * @template T
1099
- */
1100
- function toArray(list) {
1101
- var array = [];
1102
- var node = list.head.next;
1103
- while (node !== list.tail) {
1104
- array.push(node.value);
1105
- node = node.next;
1106
- }
1107
- return array;
1108
- }
1109
-
1110
-
1111
- if (!_self.document) {
1112
- if (!_self.addEventListener) {
1113
- // in Node.js
1114
- return _;
1115
- }
1116
-
1117
- if (!_.disableWorkerMessageHandler) {
1118
- // In worker
1119
- _self.addEventListener('message', function (evt) {
1120
- var message = JSON.parse(evt.data);
1121
- var lang = message.language;
1122
- var code = message.code;
1123
- var immediateClose = message.immediateClose;
1124
-
1125
- _self.postMessage(_.highlight(code, _.languages[lang], lang));
1126
- if (immediateClose) {
1127
- _self.close();
1128
- }
1129
- }, false);
1130
- }
1131
-
1132
- return _;
1133
- }
1134
-
1135
- // Get current script and highlight
1136
- var script = _.util.currentScript();
1137
-
1138
- if (script) {
1139
- _.filename = script.src;
1140
-
1141
- if (script.hasAttribute('data-manual')) {
1142
- _.manual = true;
1143
- }
1144
- }
1145
-
1146
- function highlightAutomaticallyCallback() {
1147
- if (!_.manual) {
1148
- _.highlightAll();
1149
- }
1150
- }
1151
-
1152
- if (!_.manual) {
1153
- // If the document state is "loading", then we'll use DOMContentLoaded.
1154
- // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1155
- // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1156
- // might take longer one animation frame to execute which can create a race condition where only some plugins have
1157
- // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1158
- // See https://github.com/PrismJS/prism/issues/2102
1159
- var readyState = document.readyState;
1160
- if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1161
- document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1162
- } else {
1163
- if (window.requestAnimationFrame) {
1164
- window.requestAnimationFrame(highlightAutomaticallyCallback);
1165
- } else {
1166
- window.setTimeout(highlightAutomaticallyCallback, 16);
1167
- }
1168
- }
1169
- }
1170
-
1171
- return _;
1172
-
1173
- }(_self));
1174
-
1175
- if ( true && module.exports) {
1176
- module.exports = Prism;
1177
- }
1178
-
1179
- // hack for components to work correctly in node.js
1180
- if (typeof global !== 'undefined') {
1181
- global.Prism = Prism;
1182
- }
1183
-
1184
- // some additional documentation/types
1185
-
1186
- /**
967
+ */ function d(e) {
968
+ var t = [];
969
+ var a = e.head.next;
970
+ while (a !== e.tail) {
971
+ t.push(a.value);
972
+ a = a.next;
973
+ }
974
+ return t;
975
+ }
976
+ if (!e.document) {
977
+ if (!e.addEventListener) {
978
+ // in Node.js
979
+ return s;
980
+ }
981
+ if (!s.disableWorkerMessageHandler) {
982
+ // In worker
983
+ e.addEventListener("message", (function(t) {
984
+ var a = JSON.parse(t.data);
985
+ var n = a.language;
986
+ var r = a.code;
987
+ var i = a.immediateClose;
988
+ e.postMessage(s.highlight(r, s.languages[n], n));
989
+ if (i) {
990
+ e.close();
991
+ }
992
+ }), false);
993
+ }
994
+ return s;
995
+ }
996
+ // Get current script and highlight
997
+ var g = s.util.currentScript();
998
+ if (g) {
999
+ s.filename = g.src;
1000
+ if (g.hasAttribute("data-manual")) {
1001
+ s.manual = true;
1002
+ }
1003
+ }
1004
+ function f() {
1005
+ if (!s.manual) {
1006
+ s.highlightAll();
1007
+ }
1008
+ }
1009
+ if (!s.manual) {
1010
+ // If the document state is "loading", then we'll use DOMContentLoaded.
1011
+ // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1012
+ // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1013
+ // might take longer one animation frame to execute which can create a race condition where only some plugins have
1014
+ // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1015
+ // See https://github.com/PrismJS/prism/issues/2102
1016
+ var m = document.readyState;
1017
+ if (m === "loading" || m === "interactive" && g && g.defer) {
1018
+ document.addEventListener("DOMContentLoaded", f);
1019
+ } else {
1020
+ if (t.requestAnimationFrame) {
1021
+ t.requestAnimationFrame(f);
1022
+ } else {
1023
+ t.setTimeout(f, 16);
1024
+ }
1025
+ }
1026
+ }
1027
+ return s;
1028
+ }(n);
1029
+ if (true && e.exports) {
1030
+ e.exports = r;
1031
+ }
1032
+ // hack for components to work correctly in node.js
1033
+ if (typeof a !== "undefined") {
1034
+ a.Prism = r;
1035
+ }
1036
+ // some additional documentation/types
1037
+ /**
1187
1038
  * The expansion of a simple `RegExp` literal to support additional properties.
1188
1039
  *
1189
1040
  * @typedef GrammarToken
@@ -1203,16 +1054,14 @@ if (typeof global !== 'undefined') {
1203
1054
  * @global
1204
1055
  * @public
1205
1056
  */
1206
-
1207
- /**
1057
+ /**
1208
1058
  * @typedef Grammar
1209
1059
  * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1210
1060
  * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1211
1061
  * @global
1212
1062
  * @public
1213
1063
  */
1214
-
1215
- /**
1064
+ /**
1216
1065
  * A function which will invoked after an element was successfully highlighted.
1217
1066
  *
1218
1067
  * @callback HighlightCallback
@@ -1221,133 +1070,117 @@ if (typeof global !== 'undefined') {
1221
1070
  * @global
1222
1071
  * @public
1223
1072
  */
1224
-
1225
- /**
1073
+ /**
1226
1074
  * @callback HookCallback
1227
1075
  * @param {Object<string, any>} env The environment variables of the hook.
1228
1076
  * @returns {void}
1229
1077
  * @global
1230
1078
  * @public
1231
1079
  */
1232
-
1233
- // https://www.json.org/json-en.html
1234
- Prism.languages.json = {
1235
- 'property': {
1236
- pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
1237
- lookbehind: true,
1238
- greedy: true
1239
- },
1240
- 'string': {
1241
- pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1242
- lookbehind: true,
1243
- greedy: true
1244
- },
1245
- 'comment': {
1246
- pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
1247
- greedy: true
1248
- },
1249
- 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
1250
- 'punctuation': /[{}[\],]/,
1251
- 'operator': /:/,
1252
- 'boolean': /\b(?:true|false)\b/,
1253
- 'null': {
1254
- pattern: /\bnull\b/,
1255
- alias: 'keyword'
1256
- }
1257
- };
1258
-
1259
- Prism.languages.webmanifest = Prism.languages.json;
1260
-
1261
- Prism.languages.markup = {
1262
- 'comment': {
1263
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1264
- greedy: true
1265
- },
1266
- 'prolog': {
1267
- pattern: /<\?[\s\S]+?\?>/,
1268
- greedy: true
1269
- },
1270
- 'doctype': {
1271
- // https://www.w3.org/TR/xml/#NT-doctypedecl
1272
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1273
- greedy: true,
1274
- inside: {
1275
- 'internal-subset': {
1276
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1277
- lookbehind: true,
1278
- greedy: true,
1279
- inside: null // see below
1280
- },
1281
- 'string': {
1282
- pattern: /"[^"]*"|'[^']*'/,
1283
- greedy: true
1284
- },
1285
- 'punctuation': /^<!|>$|[[\]]/,
1286
- 'doctype-tag': /^DOCTYPE/i,
1287
- 'name': /[^\s<>'"]+/
1288
- }
1289
- },
1290
- 'cdata': {
1291
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1292
- greedy: true
1293
- },
1294
- 'tag': {
1295
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1296
- greedy: true,
1297
- inside: {
1298
- 'tag': {
1299
- pattern: /^<\/?[^\s>\/]+/,
1300
- inside: {
1301
- 'punctuation': /^<\/?/,
1302
- 'namespace': /^[^\s>\/:]+:/
1303
- }
1304
- },
1305
- 'special-attr': [],
1306
- 'attr-value': {
1307
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1308
- inside: {
1309
- 'punctuation': [
1310
- {
1311
- pattern: /^=/,
1312
- alias: 'attr-equals'
1313
- },
1314
- /"|'/
1315
- ]
1316
- }
1317
- },
1318
- 'punctuation': /\/?>/,
1319
- 'attr-name': {
1320
- pattern: /[^\s>\/]+/,
1321
- inside: {
1322
- 'namespace': /^[^\s>\/:]+:/
1323
- }
1324
- }
1325
-
1326
- }
1327
- },
1328
- 'entity': [
1329
- {
1330
- pattern: /&[\da-z]{1,8};/i,
1331
- alias: 'named-entity'
1332
- },
1333
- /&#x?[\da-f]{1,8};/i
1334
- ]
1335
- };
1336
-
1337
- Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
1338
- Prism.languages.markup['entity'];
1339
- Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
1340
-
1341
- // Plugin to make entity title show the real entity, idea by Roman Komarov
1342
- Prism.hooks.add('wrap', function (env) {
1343
-
1344
- if (env.type === 'entity') {
1345
- env.attributes['title'] = env.content.replace(/&amp;/, '&');
1346
- }
1347
- });
1348
-
1349
- Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1350
- /**
1080
+ // https://www.json.org/json-en.html
1081
+ r.languages.json = {
1082
+ property: {
1083
+ pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
1084
+ lookbehind: true,
1085
+ greedy: true
1086
+ },
1087
+ string: {
1088
+ pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1089
+ lookbehind: true,
1090
+ greedy: true
1091
+ },
1092
+ comment: {
1093
+ pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
1094
+ greedy: true
1095
+ },
1096
+ number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
1097
+ punctuation: /[{}[\],]/,
1098
+ operator: /:/,
1099
+ boolean: /\b(?:true|false)\b/,
1100
+ null: {
1101
+ pattern: /\bnull\b/,
1102
+ alias: "keyword"
1103
+ }
1104
+ };
1105
+ r.languages.webmanifest = r.languages.json;
1106
+ r.languages.markup = {
1107
+ comment: {
1108
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1109
+ greedy: true
1110
+ },
1111
+ prolog: {
1112
+ pattern: /<\?[\s\S]+?\?>/,
1113
+ greedy: true
1114
+ },
1115
+ doctype: {
1116
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
1117
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1118
+ greedy: true,
1119
+ inside: {
1120
+ "internal-subset": {
1121
+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1122
+ lookbehind: true,
1123
+ greedy: true,
1124
+ inside: null
1125
+ },
1126
+ string: {
1127
+ pattern: /"[^"]*"|'[^']*'/,
1128
+ greedy: true
1129
+ },
1130
+ punctuation: /^<!|>$|[[\]]/,
1131
+ "doctype-tag": /^DOCTYPE/i,
1132
+ name: /[^\s<>'"]+/
1133
+ }
1134
+ },
1135
+ cdata: {
1136
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1137
+ greedy: true
1138
+ },
1139
+ tag: {
1140
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1141
+ greedy: true,
1142
+ inside: {
1143
+ tag: {
1144
+ pattern: /^<\/?[^\s>\/]+/,
1145
+ inside: {
1146
+ punctuation: /^<\/?/,
1147
+ namespace: /^[^\s>\/:]+:/
1148
+ }
1149
+ },
1150
+ "special-attr": [],
1151
+ "attr-value": {
1152
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1153
+ inside: {
1154
+ punctuation: [ {
1155
+ pattern: /^=/,
1156
+ alias: "attr-equals"
1157
+ }, /"|'/ ]
1158
+ }
1159
+ },
1160
+ punctuation: /\/?>/,
1161
+ "attr-name": {
1162
+ pattern: /[^\s>\/]+/,
1163
+ inside: {
1164
+ namespace: /^[^\s>\/:]+:/
1165
+ }
1166
+ }
1167
+ }
1168
+ },
1169
+ entity: [ {
1170
+ pattern: /&[\da-z]{1,8};/i,
1171
+ alias: "named-entity"
1172
+ }, /&#x?[\da-f]{1,8};/i ]
1173
+ };
1174
+ r.languages.markup["tag"].inside["attr-value"].inside["entity"] = r.languages.markup["entity"];
1175
+ r.languages.markup["doctype"].inside["internal-subset"].inside = r.languages.markup;
1176
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
1177
+ r.hooks.add("wrap", (function(e) {
1178
+ if (e.type === "entity") {
1179
+ e.attributes["title"] = e.content.replace(/&amp;/, "&");
1180
+ }
1181
+ }));
1182
+ Object.defineProperty(r.languages.markup.tag, "addInlined", {
1183
+ /**
1351
1184
  * Adds an inlined language to markup.
1352
1185
  *
1353
1186
  * An example of an inlined language is CSS with `<style>` tags.
@@ -1358,39 +1191,38 @@ Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1358
1191
  * @example
1359
1192
  * addInlined('style', 'css');
1360
1193
  */
1361
- value: function addInlined(tagName, lang) {
1362
- var includedCdataInside = {};
1363
- includedCdataInside['language-' + lang] = {
1364
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1365
- lookbehind: true,
1366
- inside: Prism.languages[lang]
1367
- };
1368
- includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
1369
-
1370
- var inside = {
1371
- 'included-cdata': {
1372
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1373
- inside: includedCdataInside
1374
- }
1375
- };
1376
- inside['language-' + lang] = {
1377
- pattern: /[\s\S]+/,
1378
- inside: Prism.languages[lang]
1379
- };
1380
-
1381
- var def = {};
1382
- def[tagName] = {
1383
- pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
1384
- lookbehind: true,
1385
- greedy: true,
1386
- inside: inside
1387
- };
1388
-
1389
- Prism.languages.insertBefore('markup', 'cdata', def);
1390
- }
1391
- });
1392
- Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
1393
- /**
1194
+ value: function e(t, a) {
1195
+ var n = {};
1196
+ n["language-" + a] = {
1197
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1198
+ lookbehind: true,
1199
+ inside: r.languages[a]
1200
+ };
1201
+ n["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
1202
+ var s = {
1203
+ "included-cdata": {
1204
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1205
+ inside: n
1206
+ }
1207
+ };
1208
+ s["language-" + a] = {
1209
+ pattern: /[\s\S]+/,
1210
+ inside: r.languages[a]
1211
+ };
1212
+ var i = {};
1213
+ i[t] = {
1214
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, (function() {
1215
+ return t;
1216
+ })), "i"),
1217
+ lookbehind: true,
1218
+ greedy: true,
1219
+ inside: s
1220
+ };
1221
+ r.languages.insertBefore("markup", "cdata", i);
1222
+ }
1223
+ });
1224
+ Object.defineProperty(r.languages.markup.tag, "addAttribute", {
1225
+ /**
1394
1226
  * Adds an pattern to highlight languages embedded in HTML attributes.
1395
1227
  *
1396
1228
  * An example of an inlined language is CSS with `style` attributes.
@@ -1401,1166 +1233,1058 @@ Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
1401
1233
  * @example
1402
1234
  * addAttribute('style', 'css');
1403
1235
  */
1404
- value: function (attrName, lang) {
1405
- Prism.languages.markup.tag.inside['special-attr'].push({
1406
- pattern: RegExp(
1407
- /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1408
- 'i'
1409
- ),
1410
- lookbehind: true,
1411
- inside: {
1412
- 'attr-name': /^[^\s=]+/,
1413
- 'attr-value': {
1414
- pattern: /=[\s\S]+/,
1415
- inside: {
1416
- 'value': {
1417
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1418
- lookbehind: true,
1419
- alias: [lang, 'language-' + lang],
1420
- inside: Prism.languages[lang]
1421
- },
1422
- 'punctuation': [
1423
- {
1424
- pattern: /^=/,
1425
- alias: 'attr-equals'
1426
- },
1427
- /"|'/
1428
- ]
1429
- }
1430
- }
1431
- }
1432
- });
1433
- }
1434
- });
1435
-
1436
- Prism.languages.html = Prism.languages.markup;
1437
- Prism.languages.mathml = Prism.languages.markup;
1438
- Prism.languages.svg = Prism.languages.markup;
1439
-
1440
- Prism.languages.xml = Prism.languages.extend('markup', {});
1441
- Prism.languages.ssml = Prism.languages.xml;
1442
- Prism.languages.atom = Prism.languages.xml;
1443
- Prism.languages.rss = Prism.languages.xml;
1444
-
1445
- Prism.languages.clike = {
1446
- 'comment': [
1447
- {
1448
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1449
- lookbehind: true,
1450
- greedy: true
1451
- },
1452
- {
1453
- pattern: /(^|[^\\:])\/\/.*/,
1454
- lookbehind: true,
1455
- greedy: true
1456
- }
1457
- ],
1458
- 'string': {
1459
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1460
- greedy: true
1461
- },
1462
- 'class-name': {
1463
- pattern: /(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,
1464
- lookbehind: true,
1465
- inside: {
1466
- 'punctuation': /[.\\]/
1467
- }
1468
- },
1469
- 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
1470
- 'boolean': /\b(?:true|false)\b/,
1471
- 'function': /\b\w+(?=\()/,
1472
- 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1473
- 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1474
- 'punctuation': /[{}[\];(),.:]/
1475
- };
1476
-
1477
- Prism.languages.javascript = Prism.languages.extend('clike', {
1478
- 'class-name': [
1479
- Prism.languages.clike['class-name'],
1480
- {
1481
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:prototype|constructor))/,
1482
- lookbehind: true
1483
- }
1484
- ],
1485
- 'keyword': [
1486
- {
1487
- pattern: /((?:^|\})\s*)catch\b/,
1488
- lookbehind: true
1489
- },
1490
- {
1491
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1492
- lookbehind: true
1493
- },
1494
- ],
1495
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1496
- 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1497
- 'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
1498
- 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1499
- });
1500
-
1501
- Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
1502
-
1503
- Prism.languages.insertBefore('javascript', 'keyword', {
1504
- 'regex': {
1505
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
1506
- pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
1507
- lookbehind: true,
1508
- greedy: true,
1509
- inside: {
1510
- 'regex-source': {
1511
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1512
- lookbehind: true,
1513
- alias: 'language-regex',
1514
- inside: Prism.languages.regex
1515
- },
1516
- 'regex-delimiter': /^\/|\/$/,
1517
- 'regex-flags': /^[a-z]+$/,
1518
- }
1519
- },
1520
- // This must be declared before keyword because we use "function" inside the look-forward
1521
- 'function-variable': {
1522
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
1523
- alias: 'function'
1524
- },
1525
- 'parameter': [
1526
- {
1527
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1528
- lookbehind: true,
1529
- inside: Prism.languages.javascript
1530
- },
1531
- {
1532
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1533
- lookbehind: true,
1534
- inside: Prism.languages.javascript
1535
- },
1536
- {
1537
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1538
- lookbehind: true,
1539
- inside: Prism.languages.javascript
1540
- },
1541
- {
1542
- 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*\{)/,
1543
- lookbehind: true,
1544
- inside: Prism.languages.javascript
1545
- }
1546
- ],
1547
- 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1548
- });
1549
-
1550
- Prism.languages.insertBefore('javascript', 'string', {
1551
- 'hashbang': {
1552
- pattern: /^#!.*/,
1553
- greedy: true,
1554
- alias: 'comment'
1555
- },
1556
- 'template-string': {
1557
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1558
- greedy: true,
1559
- inside: {
1560
- 'template-punctuation': {
1561
- pattern: /^`|`$/,
1562
- alias: 'string'
1563
- },
1564
- 'interpolation': {
1565
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1566
- lookbehind: true,
1567
- inside: {
1568
- 'interpolation-punctuation': {
1569
- pattern: /^\$\{|\}$/,
1570
- alias: 'punctuation'
1571
- },
1572
- rest: Prism.languages.javascript
1573
- }
1574
- },
1575
- 'string': /[\s\S]+/
1576
- }
1577
- }
1578
- });
1579
-
1580
- if (Prism.languages.markup) {
1581
- Prism.languages.markup.tag.addInlined('script', 'javascript');
1582
-
1583
- // add attribute support for all DOM events.
1584
- // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
1585
- Prism.languages.markup.tag.addAttribute(
1586
- /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,
1587
- 'javascript'
1588
- );
1589
- }
1590
-
1591
- Prism.languages.js = Prism.languages.javascript;
1592
-
1593
- (function (Prism) {
1594
-
1595
- var javascript = Prism.util.clone(Prism.languages.javascript);
1596
-
1597
- var space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
1598
- var braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
1599
- var spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
1600
-
1601
- /**
1236
+ value: function(e, t) {
1237
+ r.languages.markup.tag.inside["special-attr"].push({
1238
+ pattern: RegExp(/(^|["'\s])/.source + "(?:" + e + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, "i"),
1239
+ lookbehind: true,
1240
+ inside: {
1241
+ "attr-name": /^[^\s=]+/,
1242
+ "attr-value": {
1243
+ pattern: /=[\s\S]+/,
1244
+ inside: {
1245
+ value: {
1246
+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1247
+ lookbehind: true,
1248
+ alias: [ t, "language-" + t ],
1249
+ inside: r.languages[t]
1250
+ },
1251
+ punctuation: [ {
1252
+ pattern: /^=/,
1253
+ alias: "attr-equals"
1254
+ }, /"|'/ ]
1255
+ }
1256
+ }
1257
+ }
1258
+ });
1259
+ }
1260
+ });
1261
+ r.languages.html = r.languages.markup;
1262
+ r.languages.mathml = r.languages.markup;
1263
+ r.languages.svg = r.languages.markup;
1264
+ r.languages.xml = r.languages.extend("markup", {});
1265
+ r.languages.ssml = r.languages.xml;
1266
+ r.languages.atom = r.languages.xml;
1267
+ r.languages.rss = r.languages.xml;
1268
+ r.languages.clike = {
1269
+ comment: [ {
1270
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1271
+ lookbehind: true,
1272
+ greedy: true
1273
+ }, {
1274
+ pattern: /(^|[^\\:])\/\/.*/,
1275
+ lookbehind: true,
1276
+ greedy: true
1277
+ } ],
1278
+ string: {
1279
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1280
+ greedy: true
1281
+ },
1282
+ "class-name": {
1283
+ pattern: /(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,
1284
+ lookbehind: true,
1285
+ inside: {
1286
+ punctuation: /[.\\]/
1287
+ }
1288
+ },
1289
+ keyword: /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
1290
+ boolean: /\b(?:true|false)\b/,
1291
+ function: /\b\w+(?=\()/,
1292
+ number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1293
+ operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1294
+ punctuation: /[{}[\];(),.:]/
1295
+ };
1296
+ r.languages.javascript = r.languages.extend("clike", {
1297
+ "class-name": [ r.languages.clike["class-name"], {
1298
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:prototype|constructor))/,
1299
+ lookbehind: true
1300
+ } ],
1301
+ keyword: [ {
1302
+ pattern: /((?:^|\})\s*)catch\b/,
1303
+ lookbehind: true
1304
+ }, {
1305
+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1306
+ lookbehind: true
1307
+ } ],
1308
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1309
+ function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1310
+ number: /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
1311
+ operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1312
+ });
1313
+ r.languages.javascript["class-name"][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
1314
+ r.languages.insertBefore("javascript", "keyword", {
1315
+ regex: {
1316
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
1317
+ pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
1318
+ lookbehind: true,
1319
+ greedy: true,
1320
+ inside: {
1321
+ "regex-source": {
1322
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1323
+ lookbehind: true,
1324
+ alias: "language-regex",
1325
+ inside: r.languages.regex
1326
+ },
1327
+ "regex-delimiter": /^\/|\/$/,
1328
+ "regex-flags": /^[a-z]+$/
1329
+ }
1330
+ },
1331
+ // This must be declared before keyword because we use "function" inside the look-forward
1332
+ "function-variable": {
1333
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
1334
+ alias: "function"
1335
+ },
1336
+ parameter: [ {
1337
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1338
+ lookbehind: true,
1339
+ inside: r.languages.javascript
1340
+ }, {
1341
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1342
+ lookbehind: true,
1343
+ inside: r.languages.javascript
1344
+ }, {
1345
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1346
+ lookbehind: true,
1347
+ inside: r.languages.javascript
1348
+ }, {
1349
+ 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*\{)/,
1350
+ lookbehind: true,
1351
+ inside: r.languages.javascript
1352
+ } ],
1353
+ constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1354
+ });
1355
+ r.languages.insertBefore("javascript", "string", {
1356
+ hashbang: {
1357
+ pattern: /^#!.*/,
1358
+ greedy: true,
1359
+ alias: "comment"
1360
+ },
1361
+ "template-string": {
1362
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1363
+ greedy: true,
1364
+ inside: {
1365
+ "template-punctuation": {
1366
+ pattern: /^`|`$/,
1367
+ alias: "string"
1368
+ },
1369
+ interpolation: {
1370
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1371
+ lookbehind: true,
1372
+ inside: {
1373
+ "interpolation-punctuation": {
1374
+ pattern: /^\$\{|\}$/,
1375
+ alias: "punctuation"
1376
+ },
1377
+ rest: r.languages.javascript
1378
+ }
1379
+ },
1380
+ string: /[\s\S]+/
1381
+ }
1382
+ }
1383
+ });
1384
+ if (r.languages.markup) {
1385
+ r.languages.markup.tag.addInlined("script", "javascript");
1386
+ // add attribute support for all DOM events.
1387
+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
1388
+ r.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");
1389
+ }
1390
+ r.languages.js = r.languages.javascript;
1391
+ (function(e) {
1392
+ var t = e.util.clone(e.languages.javascript);
1393
+ var a = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
1394
+ var n = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
1395
+ var r = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
1396
+ /**
1602
1397
  * @param {string} source
1603
1398
  * @param {string} [flags]
1604
- */
1605
- function re(source, flags) {
1606
- source = source
1607
- .replace(/<S>/g, function () { return space; })
1608
- .replace(/<BRACES>/g, function () { return braces; })
1609
- .replace(/<SPREAD>/g, function () { return spread; });
1610
- return RegExp(source, flags);
1611
- }
1612
-
1613
- spread = re(spread).source;
1614
-
1615
-
1616
- Prism.languages.jsx = Prism.languages.extend('markup', javascript);
1617
- Prism.languages.jsx.tag.pattern = re(
1618
- /<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
1619
- );
1620
-
1621
- Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
1622
- Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/i;
1623
- Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
1624
- Prism.languages.jsx.tag.inside['comment'] = javascript['comment'];
1625
-
1626
- Prism.languages.insertBefore('inside', 'attr-name', {
1627
- 'spread': {
1628
- pattern: re(/<SPREAD>/.source),
1629
- inside: Prism.languages.jsx
1630
- }
1631
- }, Prism.languages.jsx.tag);
1632
-
1633
- Prism.languages.insertBefore('inside', 'special-attr', {
1634
- 'script': {
1635
- // Allow for two levels of nesting
1636
- pattern: re(/=<BRACES>/.source),
1637
- inside: {
1638
- 'script-punctuation': {
1639
- pattern: /^=(?=\{)/,
1640
- alias: 'punctuation'
1641
- },
1642
- rest: Prism.languages.jsx
1643
- },
1644
- 'alias': 'language-javascript'
1645
- }
1646
- }, Prism.languages.jsx.tag);
1647
-
1648
- // The following will handle plain text inside tags
1649
- var stringifyToken = function (token) {
1650
- if (!token) {
1651
- return '';
1652
- }
1653
- if (typeof token === 'string') {
1654
- return token;
1655
- }
1656
- if (typeof token.content === 'string') {
1657
- return token.content;
1658
- }
1659
- return token.content.map(stringifyToken).join('');
1660
- };
1661
-
1662
- var walkTokens = function (tokens) {
1663
- var openedTags = [];
1664
- for (var i = 0; i < tokens.length; i++) {
1665
- var token = tokens[i];
1666
- var notTagNorBrace = false;
1667
-
1668
- if (typeof token !== 'string') {
1669
- if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
1670
- // We found a tag, now find its kind
1671
-
1672
- if (token.content[0].content[0].content === '</') {
1673
- // Closing tag
1674
- if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
1675
- // Pop matching opening tag
1676
- openedTags.pop();
1677
- }
1678
- } else {
1679
- if (token.content[token.content.length - 1].content === '/>') {
1680
- // Autoclosed tag, ignore
1681
- } else {
1682
- // Opening tag
1683
- openedTags.push({
1684
- tagName: stringifyToken(token.content[0].content[1]),
1685
- openedBraces: 0
1686
- });
1687
- }
1688
- }
1689
- } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
1690
-
1691
- // Here we might have entered a JSX context inside a tag
1692
- openedTags[openedTags.length - 1].openedBraces++;
1693
-
1694
- } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
1695
-
1696
- // Here we might have left a JSX context inside a tag
1697
- openedTags[openedTags.length - 1].openedBraces--;
1698
-
1699
- } else {
1700
- notTagNorBrace = true;
1701
- }
1702
- }
1703
- if (notTagNorBrace || typeof token === 'string') {
1704
- if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
1705
- // Here we are inside a tag, and not inside a JSX context.
1706
- // That's plain text: drop any tokens matched.
1707
- var plainText = stringifyToken(token);
1708
-
1709
- // And merge text with adjacent text
1710
- if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
1711
- plainText += stringifyToken(tokens[i + 1]);
1712
- tokens.splice(i + 1, 1);
1713
- }
1714
- if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
1715
- plainText = stringifyToken(tokens[i - 1]) + plainText;
1716
- tokens.splice(i - 1, 1);
1717
- i--;
1718
- }
1719
-
1720
- tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
1721
- }
1722
- }
1723
-
1724
- if (token.content && typeof token.content !== 'string') {
1725
- walkTokens(token.content);
1726
- }
1727
- }
1728
- };
1729
-
1730
- Prism.hooks.add('after-tokenize', function (env) {
1731
- if (env.language !== 'jsx' && env.language !== 'tsx') {
1732
- return;
1733
- }
1734
- walkTokens(env.tokens);
1735
- });
1736
-
1737
- }(Prism));
1738
-
1739
- (function (Prism) {
1740
-
1741
- Prism.languages.typescript = Prism.languages.extend('javascript', {
1742
- 'class-name': {
1743
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
1744
- lookbehind: true,
1745
- greedy: true,
1746
- inside: null // see below
1747
- },
1748
- 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
1749
- });
1750
-
1751
- // The keywords TypeScript adds to JavaScript
1752
- Prism.languages.typescript.keyword.push(
1753
- /\b(?:abstract|as|declare|implements|is|keyof|readonly|require)\b/,
1754
- // keywords that have to be followed by an identifier
1755
- /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
1756
- // This is for `import type *, {}`
1757
- /\btype\b(?=\s*(?:[\{*]|$))/
1758
- );
1759
-
1760
- // doesn't work with TS because TS is too complex
1761
- delete Prism.languages.typescript['parameter'];
1762
-
1763
- // a version of typescript specifically for highlighting types
1764
- var typeInside = Prism.languages.extend('typescript', {});
1765
- delete typeInside['class-name'];
1766
-
1767
- Prism.languages.typescript['class-name'].inside = typeInside;
1768
-
1769
- Prism.languages.insertBefore('typescript', 'function', {
1770
- 'decorator': {
1771
- pattern: /@[$\w\xA0-\uFFFF]+/,
1772
- inside: {
1773
- 'at': {
1774
- pattern: /^@/,
1775
- alias: 'operator'
1776
- },
1777
- 'function': /^[\s\S]+/
1778
- }
1779
- },
1780
- 'generic-function': {
1781
- // e.g. foo<T extends "bar" | "baz">( ...
1782
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
1783
- greedy: true,
1784
- inside: {
1785
- 'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
1786
- 'generic': {
1787
- pattern: /<[\s\S]+/, // everything after the first <
1788
- alias: 'class-name',
1789
- inside: typeInside
1790
- }
1791
- }
1792
- }
1793
- });
1794
-
1795
- Prism.languages.ts = Prism.languages.typescript;
1796
-
1797
- }(Prism));
1798
-
1799
- (function (Prism) {
1800
- var typescript = Prism.util.clone(Prism.languages.typescript);
1801
- Prism.languages.tsx = Prism.languages.extend('jsx', typescript);
1802
-
1803
- // This will prevent collisions between TSX tags and TS generic types.
1804
- // Idea by https://github.com/karlhorky
1805
- // Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928
1806
- var tag = Prism.languages.tsx.tag;
1807
- tag.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + '(?:' + tag.pattern.source + ')', tag.pattern.flags);
1808
- tag.lookbehind = true;
1809
- }(Prism));
1810
-
1811
- (function (Prism) {
1812
-
1813
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1814
-
1815
- Prism.languages.css = {
1816
- 'comment': /\/\*[\s\S]*?\*\//,
1817
- 'atrule': {
1818
- pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
1819
- inside: {
1820
- 'rule': /^@[\w-]+/,
1821
- 'selector-function-argument': {
1822
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1823
- lookbehind: true,
1824
- alias: 'selector'
1825
- },
1826
- 'keyword': {
1827
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1828
- lookbehind: true
1829
- }
1830
- // See rest below
1831
- }
1832
- },
1833
- 'url': {
1834
- // https://drafts.csswg.org/css-values-3/#urls
1835
- pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1836
- greedy: true,
1837
- inside: {
1838
- 'function': /^url/i,
1839
- 'punctuation': /^\(|\)$/,
1840
- 'string': {
1841
- pattern: RegExp('^' + string.source + '$'),
1842
- alias: 'url'
1843
- }
1844
- }
1845
- },
1846
- 'selector': {
1847
- pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
1848
- lookbehind: true
1849
- },
1850
- 'string': {
1851
- pattern: string,
1852
- greedy: true
1853
- },
1854
- 'property': {
1855
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1856
- lookbehind: true
1857
- },
1858
- 'important': /!important\b/i,
1859
- 'function': {
1860
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1861
- lookbehind: true
1862
- },
1863
- 'punctuation': /[(){};:,]/
1864
- };
1865
-
1866
- Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
1867
-
1868
- var markup = Prism.languages.markup;
1869
- if (markup) {
1870
- markup.tag.addInlined('style', 'css');
1871
- markup.tag.addAttribute('style', 'css');
1872
- }
1873
-
1874
- }(Prism));
1875
-
1876
- (function (Prism) {
1877
- // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
1878
- // + LC_ALL, RANDOM, REPLY, SECONDS.
1879
- // + make sure PS1..4 are here as they are not always set,
1880
- // - some useless things.
1881
- var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
1882
-
1883
- var commandAfterHeredoc = {
1884
- pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
1885
- lookbehind: true,
1886
- alias: 'punctuation', // this looks reasonably well in all themes
1887
- inside: null // see below
1888
- };
1889
-
1890
- var insideString = {
1891
- 'bash': commandAfterHeredoc,
1892
- 'environment': {
1893
- pattern: RegExp('\\$' + envVars),
1894
- alias: 'constant'
1895
- },
1896
- 'variable': [
1897
- // [0]: Arithmetic Environment
1898
- {
1899
- pattern: /\$?\(\([\s\S]+?\)\)/,
1900
- greedy: true,
1901
- inside: {
1902
- // If there is a $ sign at the beginning highlight $(( and )) as variable
1903
- 'variable': [
1904
- {
1905
- pattern: /(^\$\(\([\s\S]+)\)\)/,
1906
- lookbehind: true
1907
- },
1908
- /^\$\(\(/
1909
- ],
1910
- 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
1911
- // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
1912
- 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
1913
- // If there is no $ sign at the beginning highlight (( and )) as punctuation
1914
- 'punctuation': /\(\(?|\)\)?|,|;/
1915
- }
1916
- },
1917
- // [1]: Command Substitution
1918
- {
1919
- pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
1920
- greedy: true,
1921
- inside: {
1922
- 'variable': /^\$\(|^`|\)$|`$/
1923
- }
1924
- },
1925
- // [2]: Brace expansion
1926
- {
1927
- pattern: /\$\{[^}]+\}/,
1928
- greedy: true,
1929
- inside: {
1930
- 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
1931
- 'punctuation': /[\[\]]/,
1932
- 'environment': {
1933
- pattern: RegExp('(\\{)' + envVars),
1934
- lookbehind: true,
1935
- alias: 'constant'
1936
- }
1937
- }
1938
- },
1939
- /\$(?:\w+|[#?*!@$])/
1940
- ],
1941
- // Escape sequences from echo and printf's manuals, and escaped quotes.
1942
- 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})/
1943
- };
1944
-
1945
- Prism.languages.bash = {
1946
- 'shebang': {
1947
- pattern: /^#!\s*\/.*/,
1948
- alias: 'important'
1949
- },
1950
- 'comment': {
1951
- pattern: /(^|[^"{\\$])#.*/,
1952
- lookbehind: true
1953
- },
1954
- 'function-name': [
1955
- // a) function foo {
1956
- // b) foo() {
1957
- // c) function foo() {
1958
- // but not “foo {”
1959
- {
1960
- // a) and c)
1961
- pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
1962
- lookbehind: true,
1963
- alias: 'function'
1964
- },
1965
- {
1966
- // b)
1967
- pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
1968
- alias: 'function'
1969
- }
1970
- ],
1971
- // Highlight variable names as variables in for and select beginnings.
1972
- 'for-or-select': {
1973
- pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
1974
- alias: 'variable',
1975
- lookbehind: true
1976
- },
1977
- // Highlight variable names as variables in the left-hand part
1978
- // of assignments (“=” and “+=”).
1979
- 'assign-left': {
1980
- pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
1981
- inside: {
1982
- 'environment': {
1983
- pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
1984
- lookbehind: true,
1985
- alias: 'constant'
1986
- }
1987
- },
1988
- alias: 'variable',
1989
- lookbehind: true
1990
- },
1991
- 'string': [
1992
- // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
1993
- {
1994
- pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
1995
- lookbehind: true,
1996
- greedy: true,
1997
- inside: insideString
1998
- },
1999
- // Here-document with quotes around the tag
2000
- // → No expansion (so no “inside”).
2001
- {
2002
- pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
2003
- lookbehind: true,
2004
- greedy: true,
2005
- inside: {
2006
- 'bash': commandAfterHeredoc
2007
- }
2008
- },
2009
- // “Normal” string
2010
- {
2011
- // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
2012
- pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
2013
- lookbehind: true,
2014
- greedy: true,
2015
- inside: insideString
2016
- },
2017
- {
2018
- // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
2019
- pattern: /(^|[^$\\])'[^']*'/,
2020
- lookbehind: true,
2021
- greedy: true
2022
- },
2023
- {
2024
- // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
2025
- pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
2026
- greedy: true,
2027
- inside: {
2028
- 'entity': insideString.entity
2029
- }
2030
- }
2031
- ],
2032
- 'environment': {
2033
- pattern: RegExp('\\$?' + envVars),
2034
- alias: 'constant'
2035
- },
2036
- 'variable': insideString.variable,
2037
- 'function': {
2038
- pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|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|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|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|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|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|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|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
2039
- lookbehind: true
2040
- },
2041
- 'keyword': {
2042
- pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
2043
- lookbehind: true
2044
- },
2045
- // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
2046
- 'builtin': {
2047
- pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|break|cd|continue|eval|exec|exit|export|getopts|hash|pwd|readonly|return|shift|test|times|trap|umask|unset|alias|bind|builtin|caller|command|declare|echo|enable|help|let|local|logout|mapfile|printf|read|readarray|source|type|typeset|ulimit|unalias|set|shopt)(?=$|[)\s;|&])/,
2048
- lookbehind: true,
2049
- // Alias added to make those easier to distinguish from strings.
2050
- alias: 'class-name'
2051
- },
2052
- 'boolean': {
2053
- pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
2054
- lookbehind: true
2055
- },
2056
- 'file-descriptor': {
2057
- pattern: /\B&\d\b/,
2058
- alias: 'important'
2059
- },
2060
- 'operator': {
2061
- // Lots of redirections here, but not just that.
2062
- pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
2063
- inside: {
2064
- 'file-descriptor': {
2065
- pattern: /^\d/,
2066
- alias: 'important'
2067
- }
2068
- }
2069
- },
2070
- 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
2071
- 'number': {
2072
- pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
2073
- lookbehind: true
2074
- }
2075
- };
2076
-
2077
- commandAfterHeredoc.inside = Prism.languages.bash;
2078
-
2079
- /* Patterns in command substitution. */
2080
- var toBeCopied = [
2081
- 'comment',
2082
- 'function-name',
2083
- 'for-or-select',
2084
- 'assign-left',
2085
- 'string',
2086
- 'environment',
2087
- 'function',
2088
- 'keyword',
2089
- 'builtin',
2090
- 'boolean',
2091
- 'file-descriptor',
2092
- 'operator',
2093
- 'punctuation',
2094
- 'number'
2095
- ];
2096
- var inside = insideString.variable[1].inside;
2097
- for (var i = 0; i < toBeCopied.length; i++) {
2098
- inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
2099
- }
2100
-
2101
- Prism.languages.shell = Prism.languages.bash;
2102
- }(Prism));
2103
-
2104
- (function (Prism) {
2105
-
2106
- // https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
2107
- // https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
2108
- var anchorOrAlias = /[*&][^\s[\]{},]+/;
2109
- // https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
2110
- var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
2111
- // https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
2112
- var properties = '(?:' + tag.source + '(?:[ \t]+' + anchorOrAlias.source + ')?|'
2113
- + anchorOrAlias.source + '(?:[ \t]+' + tag.source + ')?)';
2114
- // https://yaml.org/spec/1.2/spec.html#ns-plain(n,c)
2115
- // This is a simplified version that doesn't support "#" and multiline keys
2116
- // All these long scarry character classes are simplified versions of YAML's characters
2117
- var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source
2118
- .replace(/<PLAIN>/g, function () { return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source; });
2119
- var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
2120
-
2121
- /**
1399
+ */ function s(e, t) {
1400
+ e = e.replace(/<S>/g, (function() {
1401
+ return a;
1402
+ })).replace(/<BRACES>/g, (function() {
1403
+ return n;
1404
+ })).replace(/<SPREAD>/g, (function() {
1405
+ return r;
1406
+ }));
1407
+ return RegExp(e, t);
1408
+ }
1409
+ r = s(r).source;
1410
+ e.languages.jsx = e.languages.extend("markup", t);
1411
+ e.languages.jsx.tag.pattern = s(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source);
1412
+ e.languages.jsx.tag.inside["tag"].pattern = /^<\/?[^\s>\/]*/i;
1413
+ e.languages.jsx.tag.inside["attr-value"].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/i;
1414
+ e.languages.jsx.tag.inside["tag"].inside["class-name"] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
1415
+ e.languages.jsx.tag.inside["comment"] = t["comment"];
1416
+ e.languages.insertBefore("inside", "attr-name", {
1417
+ spread: {
1418
+ pattern: s(/<SPREAD>/.source),
1419
+ inside: e.languages.jsx
1420
+ }
1421
+ }, e.languages.jsx.tag);
1422
+ e.languages.insertBefore("inside", "special-attr", {
1423
+ script: {
1424
+ // Allow for two levels of nesting
1425
+ pattern: s(/=<BRACES>/.source),
1426
+ inside: {
1427
+ "script-punctuation": {
1428
+ pattern: /^=(?=\{)/,
1429
+ alias: "punctuation"
1430
+ },
1431
+ rest: e.languages.jsx
1432
+ },
1433
+ alias: "language-javascript"
1434
+ }
1435
+ }, e.languages.jsx.tag);
1436
+ // The following will handle plain text inside tags
1437
+ var i = function(e) {
1438
+ if (!e) {
1439
+ return "";
1440
+ }
1441
+ if (typeof e === "string") {
1442
+ return e;
1443
+ }
1444
+ if (typeof e.content === "string") {
1445
+ return e.content;
1446
+ }
1447
+ return e.content.map(i).join("");
1448
+ };
1449
+ var o = function(t) {
1450
+ var a = [];
1451
+ for (var n = 0; n < t.length; n++) {
1452
+ var r = t[n];
1453
+ var s = false;
1454
+ if (typeof r !== "string") {
1455
+ if (r.type === "tag" && r.content[0] && r.content[0].type === "tag") {
1456
+ // We found a tag, now find its kind
1457
+ if (r.content[0].content[0].content === "</") {
1458
+ // Closing tag
1459
+ if (a.length > 0 && a[a.length - 1].tagName === i(r.content[0].content[1])) {
1460
+ // Pop matching opening tag
1461
+ a.pop();
1462
+ }
1463
+ } else {
1464
+ if (r.content[r.content.length - 1].content === "/>") {
1465
+ // Autoclosed tag, ignore
1466
+ } else {
1467
+ // Opening tag
1468
+ a.push({
1469
+ tagName: i(r.content[0].content[1]),
1470
+ openedBraces: 0
1471
+ });
1472
+ }
1473
+ }
1474
+ } else if (a.length > 0 && r.type === "punctuation" && r.content === "{") {
1475
+ // Here we might have entered a JSX context inside a tag
1476
+ a[a.length - 1].openedBraces++;
1477
+ } else if (a.length > 0 && a[a.length - 1].openedBraces > 0 && r.type === "punctuation" && r.content === "}") {
1478
+ // Here we might have left a JSX context inside a tag
1479
+ a[a.length - 1].openedBraces--;
1480
+ } else {
1481
+ s = true;
1482
+ }
1483
+ }
1484
+ if (s || typeof r === "string") {
1485
+ if (a.length > 0 && a[a.length - 1].openedBraces === 0) {
1486
+ // Here we are inside a tag, and not inside a JSX context.
1487
+ // That's plain text: drop any tokens matched.
1488
+ var l = i(r);
1489
+ // And merge text with adjacent text
1490
+ if (n < t.length - 1 && (typeof t[n + 1] === "string" || t[n + 1].type === "plain-text")) {
1491
+ l += i(t[n + 1]);
1492
+ t.splice(n + 1, 1);
1493
+ }
1494
+ if (n > 0 && (typeof t[n - 1] === "string" || t[n - 1].type === "plain-text")) {
1495
+ l = i(t[n - 1]) + l;
1496
+ t.splice(n - 1, 1);
1497
+ n--;
1498
+ }
1499
+ t[n] = new e.Token("plain-text", l, null, l);
1500
+ }
1501
+ }
1502
+ if (r.content && typeof r.content !== "string") {
1503
+ o(r.content);
1504
+ }
1505
+ }
1506
+ };
1507
+ e.hooks.add("after-tokenize", (function(e) {
1508
+ if (e.language !== "jsx" && e.language !== "tsx") {
1509
+ return;
1510
+ }
1511
+ o(e.tokens);
1512
+ }));
1513
+ })(r);
1514
+ (function(e) {
1515
+ e.languages.typescript = e.languages.extend("javascript", {
1516
+ "class-name": {
1517
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
1518
+ lookbehind: true,
1519
+ greedy: true,
1520
+ inside: null
1521
+ },
1522
+ builtin: /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/
1523
+ });
1524
+ // The keywords TypeScript adds to JavaScript
1525
+ e.languages.typescript.keyword.push(/\b(?:abstract|as|declare|implements|is|keyof|readonly|require)\b/,
1526
+ // keywords that have to be followed by an identifier
1527
+ /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
1528
+ // This is for `import type *, {}`
1529
+ /\btype\b(?=\s*(?:[\{*]|$))/);
1530
+ // doesn't work with TS because TS is too complex
1531
+ delete e.languages.typescript["parameter"];
1532
+ // a version of typescript specifically for highlighting types
1533
+ var t = e.languages.extend("typescript", {});
1534
+ delete t["class-name"];
1535
+ e.languages.typescript["class-name"].inside = t;
1536
+ e.languages.insertBefore("typescript", "function", {
1537
+ decorator: {
1538
+ pattern: /@[$\w\xA0-\uFFFF]+/,
1539
+ inside: {
1540
+ at: {
1541
+ pattern: /^@/,
1542
+ alias: "operator"
1543
+ },
1544
+ function: /^[\s\S]+/
1545
+ }
1546
+ },
1547
+ "generic-function": {
1548
+ // e.g. foo<T extends "bar" | "baz">( ...
1549
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
1550
+ greedy: true,
1551
+ inside: {
1552
+ function: /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
1553
+ generic: {
1554
+ pattern: /<[\s\S]+/,
1555
+ // everything after the first <
1556
+ alias: "class-name",
1557
+ inside: t
1558
+ }
1559
+ }
1560
+ }
1561
+ });
1562
+ e.languages.ts = e.languages.typescript;
1563
+ })(r);
1564
+ (function(e) {
1565
+ var t = e.util.clone(e.languages.typescript);
1566
+ e.languages.tsx = e.languages.extend("jsx", t);
1567
+ // This will prevent collisions between TSX tags and TS generic types.
1568
+ // Idea by https://github.com/karlhorky
1569
+ // Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928
1570
+ var a = e.languages.tsx.tag;
1571
+ a.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + "(?:" + a.pattern.source + ")", a.pattern.flags);
1572
+ a.lookbehind = true;
1573
+ })(r);
1574
+ (function(e) {
1575
+ var t = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1576
+ e.languages.css = {
1577
+ comment: /\/\*[\s\S]*?\*\//,
1578
+ atrule: {
1579
+ pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
1580
+ inside: {
1581
+ rule: /^@[\w-]+/,
1582
+ "selector-function-argument": {
1583
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1584
+ lookbehind: true,
1585
+ alias: "selector"
1586
+ },
1587
+ keyword: {
1588
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1589
+ lookbehind: true
1590
+ }
1591
+ }
1592
+ },
1593
+ url: {
1594
+ // https://drafts.csswg.org/css-values-3/#urls
1595
+ pattern: RegExp("\\burl\\((?:" + t.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
1596
+ greedy: true,
1597
+ inside: {
1598
+ function: /^url/i,
1599
+ punctuation: /^\(|\)$/,
1600
+ string: {
1601
+ pattern: RegExp("^" + t.source + "$"),
1602
+ alias: "url"
1603
+ }
1604
+ }
1605
+ },
1606
+ selector: {
1607
+ pattern: RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|" + t.source + ")*(?=\\s*\\{)"),
1608
+ lookbehind: true
1609
+ },
1610
+ string: {
1611
+ pattern: t,
1612
+ greedy: true
1613
+ },
1614
+ property: {
1615
+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1616
+ lookbehind: true
1617
+ },
1618
+ important: /!important\b/i,
1619
+ function: {
1620
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1621
+ lookbehind: true
1622
+ },
1623
+ punctuation: /[(){};:,]/
1624
+ };
1625
+ e.languages.css["atrule"].inside.rest = e.languages.css;
1626
+ var a = e.languages.markup;
1627
+ if (a) {
1628
+ a.tag.addInlined("style", "css");
1629
+ a.tag.addAttribute("style", "css");
1630
+ }
1631
+ })(r);
1632
+ (function(e) {
1633
+ // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
1634
+ // + LC_ALL, RANDOM, REPLY, SECONDS.
1635
+ // + make sure PS1..4 are here as they are not always set,
1636
+ // - some useless things.
1637
+ var t = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b";
1638
+ var a = {
1639
+ pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
1640
+ lookbehind: true,
1641
+ alias: "punctuation",
1642
+ // this looks reasonably well in all themes
1643
+ inside: null
1644
+ };
1645
+ var n = {
1646
+ bash: a,
1647
+ environment: {
1648
+ pattern: RegExp("\\$" + t),
1649
+ alias: "constant"
1650
+ },
1651
+ variable: [
1652
+ // [0]: Arithmetic Environment
1653
+ {
1654
+ pattern: /\$?\(\([\s\S]+?\)\)/,
1655
+ greedy: true,
1656
+ inside: {
1657
+ // If there is a $ sign at the beginning highlight $(( and )) as variable
1658
+ variable: [ {
1659
+ pattern: /(^\$\(\([\s\S]+)\)\)/,
1660
+ lookbehind: true
1661
+ }, /^\$\(\(/ ],
1662
+ number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
1663
+ // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
1664
+ operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
1665
+ // If there is no $ sign at the beginning highlight (( and )) as punctuation
1666
+ punctuation: /\(\(?|\)\)?|,|;/
1667
+ }
1668
+ },
1669
+ // [1]: Command Substitution
1670
+ {
1671
+ pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
1672
+ greedy: true,
1673
+ inside: {
1674
+ variable: /^\$\(|^`|\)$|`$/
1675
+ }
1676
+ },
1677
+ // [2]: Brace expansion
1678
+ {
1679
+ pattern: /\$\{[^}]+\}/,
1680
+ greedy: true,
1681
+ inside: {
1682
+ operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
1683
+ punctuation: /[\[\]]/,
1684
+ environment: {
1685
+ pattern: RegExp("(\\{)" + t),
1686
+ lookbehind: true,
1687
+ alias: "constant"
1688
+ }
1689
+ }
1690
+ }, /\$(?:\w+|[#?*!@$])/ ],
1691
+ // Escape sequences from echo and printf's manuals, and escaped quotes.
1692
+ entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})/
1693
+ };
1694
+ e.languages.bash = {
1695
+ shebang: {
1696
+ pattern: /^#!\s*\/.*/,
1697
+ alias: "important"
1698
+ },
1699
+ comment: {
1700
+ pattern: /(^|[^"{\\$])#.*/,
1701
+ lookbehind: true
1702
+ },
1703
+ "function-name": [
1704
+ // a) function foo {
1705
+ // b) foo() {
1706
+ // c) function foo() {
1707
+ // but not “foo {”
1708
+ {
1709
+ // a) and c)
1710
+ pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
1711
+ lookbehind: true,
1712
+ alias: "function"
1713
+ }, {
1714
+ // b)
1715
+ pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
1716
+ alias: "function"
1717
+ } ],
1718
+ // Highlight variable names as variables in for and select beginnings.
1719
+ "for-or-select": {
1720
+ pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
1721
+ alias: "variable",
1722
+ lookbehind: true
1723
+ },
1724
+ // Highlight variable names as variables in the left-hand part
1725
+ // of assignments (“=” and “+=”).
1726
+ "assign-left": {
1727
+ pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
1728
+ inside: {
1729
+ environment: {
1730
+ pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + t),
1731
+ lookbehind: true,
1732
+ alias: "constant"
1733
+ }
1734
+ },
1735
+ alias: "variable",
1736
+ lookbehind: true
1737
+ },
1738
+ string: [
1739
+ // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
1740
+ {
1741
+ pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
1742
+ lookbehind: true,
1743
+ greedy: true,
1744
+ inside: n
1745
+ },
1746
+ // Here-document with quotes around the tag
1747
+ // → No expansion (so no “inside”).
1748
+ {
1749
+ pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
1750
+ lookbehind: true,
1751
+ greedy: true,
1752
+ inside: {
1753
+ bash: a
1754
+ }
1755
+ },
1756
+ // “Normal” string
1757
+ {
1758
+ // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
1759
+ pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
1760
+ lookbehind: true,
1761
+ greedy: true,
1762
+ inside: n
1763
+ }, {
1764
+ // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
1765
+ pattern: /(^|[^$\\])'[^']*'/,
1766
+ lookbehind: true,
1767
+ greedy: true
1768
+ }, {
1769
+ // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
1770
+ pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
1771
+ greedy: true,
1772
+ inside: {
1773
+ entity: n.entity
1774
+ }
1775
+ } ],
1776
+ environment: {
1777
+ pattern: RegExp("\\$?" + t),
1778
+ alias: "constant"
1779
+ },
1780
+ variable: n.variable,
1781
+ function: {
1782
+ pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|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|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|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|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|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|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|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1783
+ lookbehind: true
1784
+ },
1785
+ keyword: {
1786
+ pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
1787
+ lookbehind: true
1788
+ },
1789
+ // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
1790
+ builtin: {
1791
+ pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|break|cd|continue|eval|exec|exit|export|getopts|hash|pwd|readonly|return|shift|test|times|trap|umask|unset|alias|bind|builtin|caller|command|declare|echo|enable|help|let|local|logout|mapfile|printf|read|readarray|source|type|typeset|ulimit|unalias|set|shopt)(?=$|[)\s;|&])/,
1792
+ lookbehind: true,
1793
+ // Alias added to make those easier to distinguish from strings.
1794
+ alias: "class-name"
1795
+ },
1796
+ boolean: {
1797
+ pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
1798
+ lookbehind: true
1799
+ },
1800
+ "file-descriptor": {
1801
+ pattern: /\B&\d\b/,
1802
+ alias: "important"
1803
+ },
1804
+ operator: {
1805
+ // Lots of redirections here, but not just that.
1806
+ pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
1807
+ inside: {
1808
+ "file-descriptor": {
1809
+ pattern: /^\d/,
1810
+ alias: "important"
1811
+ }
1812
+ }
1813
+ },
1814
+ punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
1815
+ number: {
1816
+ pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
1817
+ lookbehind: true
1818
+ }
1819
+ };
1820
+ a.inside = e.languages.bash;
1821
+ /* Patterns in command substitution. */ var r = [ "comment", "function-name", "for-or-select", "assign-left", "string", "environment", "function", "keyword", "builtin", "boolean", "file-descriptor", "operator", "punctuation", "number" ];
1822
+ var s = n.variable[1].inside;
1823
+ for (var i = 0; i < r.length; i++) {
1824
+ s[r[i]] = e.languages.bash[r[i]];
1825
+ }
1826
+ e.languages.shell = e.languages.bash;
1827
+ })(r);
1828
+ (function(e) {
1829
+ // https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
1830
+ // https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
1831
+ var t = /[*&][^\s[\]{},]+/;
1832
+ // https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
1833
+ var a = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
1834
+ // https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
1835
+ var n = "(?:" + a.source + "(?:[ \t]+" + t.source + ")?|" + t.source + "(?:[ \t]+" + a.source + ")?)";
1836
+ // https://yaml.org/spec/1.2/spec.html#ns-plain(n,c)
1837
+ // This is a simplified version that doesn't support "#" and multiline keys
1838
+ // All these long scarry character classes are simplified versions of YAML's characters
1839
+ var r = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, (function() {
1840
+ return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
1841
+ }));
1842
+ var s = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
1843
+ /**
2122
1844
  *
2123
1845
  * @param {string} value
2124
1846
  * @param {string} [flags]
2125
1847
  * @returns {RegExp}
2126
- */
2127
- function createValuePattern(value, flags) {
2128
- flags = (flags || '').replace(/m/g, '') + 'm'; // add m flag
2129
- var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source
2130
- .replace(/<<prop>>/g, function () { return properties; }).replace(/<<value>>/g, function () { return value; });
2131
- return RegExp(pattern, flags);
2132
- }
2133
-
2134
- Prism.languages.yaml = {
2135
- 'scalar': {
2136
- pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source
2137
- .replace(/<<prop>>/g, function () { return properties; })),
2138
- lookbehind: true,
2139
- alias: 'string'
2140
- },
2141
- 'comment': /#.*/,
2142
- 'key': {
2143
- pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source
2144
- .replace(/<<prop>>/g, function () { return properties; })
2145
- .replace(/<<key>>/g, function () { return '(?:' + plainKey + '|' + string + ')'; })),
2146
- lookbehind: true,
2147
- greedy: true,
2148
- alias: 'atrule'
2149
- },
2150
- 'directive': {
2151
- pattern: /(^[ \t]*)%.+/m,
2152
- lookbehind: true,
2153
- alias: 'important'
2154
- },
2155
- 'datetime': {
2156
- pattern: createValuePattern(/\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),
2157
- lookbehind: true,
2158
- alias: 'number'
2159
- },
2160
- 'boolean': {
2161
- pattern: createValuePattern(/true|false/.source, 'i'),
2162
- lookbehind: true,
2163
- alias: 'important'
2164
- },
2165
- 'null': {
2166
- pattern: createValuePattern(/null|~/.source, 'i'),
2167
- lookbehind: true,
2168
- alias: 'important'
2169
- },
2170
- 'string': {
2171
- pattern: createValuePattern(string),
2172
- lookbehind: true,
2173
- greedy: true
2174
- },
2175
- 'number': {
2176
- pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, 'i'),
2177
- lookbehind: true
2178
- },
2179
- 'tag': tag,
2180
- 'important': anchorOrAlias,
2181
- 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
2182
- };
2183
-
2184
- Prism.languages.yml = Prism.languages.yaml;
2185
-
2186
- }(Prism));
2187
-
2188
- Prism.languages['splunk-spl'] = {
2189
- 'comment': /`comment\("(?:\\.|[^\\"])*"\)`/,
2190
- 'string': {
2191
- pattern: /"(?:\\.|[^\\"])*"/,
2192
- greedy: true
2193
- },
2194
- // https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/ListOfSearchCommands
2195
- 'keyword': /\b(?:abstract|accum|addcoltotals|addinfo|addtotals|analyzefields|anomalies|anomalousvalue|anomalydetection|append|appendcols|appendcsv|appendlookup|appendpipe|arules|associate|audit|autoregress|bin|bucket|bucketdir|chart|cluster|cofilter|collect|concurrency|contingency|convert|correlate|datamodel|dbinspect|dedup|delete|delta|diff|erex|eval|eventcount|eventstats|extract|fieldformat|fields|fieldsummary|filldown|fillnull|findtypes|folderize|foreach|format|from|gauge|gentimes|geom|geomfilter|geostats|head|highlight|history|iconify|input|inputcsv|inputlookup|iplocation|join|kmeans|kv|kvform|loadjob|localize|localop|lookup|makecontinuous|makemv|makeresults|map|mcollect|metadata|metasearch|meventcollect|mstats|multikv|multisearch|mvcombine|mvexpand|nomv|outlier|outputcsv|outputlookup|outputtext|overlap|pivot|predict|rangemap|rare|regex|relevancy|reltime|rename|replace|rest|return|reverse|rex|rtorder|run|savedsearch|script|scrub|search|searchtxn|selfjoin|sendemail|set|setfields|sichart|sirare|sistats|sitimechart|sitop|sort|spath|stats|strcat|streamstats|table|tags|tail|timechart|timewrap|top|transaction|transpose|trendline|tscollect|tstats|typeahead|typelearner|typer|union|uniq|untable|where|x11|xmlkv|xmlunescape|xpath|xyseries)\b/i,
2196
- 'operator-word': {
2197
- pattern: /\b(?:and|as|by|not|or|xor)\b/i,
2198
- alias: 'operator'
2199
- },
2200
- 'function': /\b\w+(?=\s*\()/,
2201
- 'property': /\b\w+(?=\s*=(?!=))/,
2202
- 'date': {
2203
- // MM/DD/YYYY(:HH:MM:SS)?
2204
- pattern: /\b\d{1,2}\/\d{1,2}\/\d{1,4}(?:(?::\d{1,2}){3})?\b/,
2205
- alias: 'number'
2206
- },
2207
- 'number': /\b\d+(?:\.\d+)?\b/,
2208
- 'boolean': /\b(?:f|false|t|true)\b/i,
2209
- 'operator': /[<>=]=?|[-+*/%|]/,
2210
- 'punctuation': /[()[\],]/
2211
- };
2212
-
1848
+ */ function i(e, t) {
1849
+ t = (t || "").replace(/m/g, "") + "m";
1850
+ // add m flag
1851
+ var a = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, (function() {
1852
+ return n;
1853
+ })).replace(/<<value>>/g, (function() {
1854
+ return e;
1855
+ }));
1856
+ return RegExp(a, t);
1857
+ }
1858
+ e.languages.yaml = {
1859
+ scalar: {
1860
+ pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, (function() {
1861
+ return n;
1862
+ }))),
1863
+ lookbehind: true,
1864
+ alias: "string"
1865
+ },
1866
+ comment: /#.*/,
1867
+ key: {
1868
+ pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, (function() {
1869
+ return n;
1870
+ })).replace(/<<key>>/g, (function() {
1871
+ return "(?:" + r + "|" + s + ")";
1872
+ }))),
1873
+ lookbehind: true,
1874
+ greedy: true,
1875
+ alias: "atrule"
1876
+ },
1877
+ directive: {
1878
+ pattern: /(^[ \t]*)%.+/m,
1879
+ lookbehind: true,
1880
+ alias: "important"
1881
+ },
1882
+ datetime: {
1883
+ 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),
1884
+ lookbehind: true,
1885
+ alias: "number"
1886
+ },
1887
+ boolean: {
1888
+ pattern: i(/true|false/.source, "i"),
1889
+ lookbehind: true,
1890
+ alias: "important"
1891
+ },
1892
+ null: {
1893
+ pattern: i(/null|~/.source, "i"),
1894
+ lookbehind: true,
1895
+ alias: "important"
1896
+ },
1897
+ string: {
1898
+ pattern: i(s),
1899
+ lookbehind: true,
1900
+ greedy: true
1901
+ },
1902
+ number: {
1903
+ pattern: i(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, "i"),
1904
+ lookbehind: true
1905
+ },
1906
+ tag: a,
1907
+ important: t,
1908
+ punctuation: /---|[:[\]{}\-,|>?]|\.\.\./
1909
+ };
1910
+ e.languages.yml = e.languages.yaml;
1911
+ })(r);
1912
+ r.languages["splunk-spl"] = {
1913
+ comment: /`comment\("(?:\\.|[^\\"])*"\)`/,
1914
+ string: {
1915
+ pattern: /"(?:\\.|[^\\"])*"/,
1916
+ greedy: true
1917
+ },
1918
+ // https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/ListOfSearchCommands
1919
+ keyword: /\b(?:abstract|accum|addcoltotals|addinfo|addtotals|analyzefields|anomalies|anomalousvalue|anomalydetection|append|appendcols|appendcsv|appendlookup|appendpipe|arules|associate|audit|autoregress|bin|bucket|bucketdir|chart|cluster|cofilter|collect|concurrency|contingency|convert|correlate|datamodel|dbinspect|dedup|delete|delta|diff|erex|eval|eventcount|eventstats|extract|fieldformat|fields|fieldsummary|filldown|fillnull|findtypes|folderize|foreach|format|from|gauge|gentimes|geom|geomfilter|geostats|head|highlight|history|iconify|input|inputcsv|inputlookup|iplocation|join|kmeans|kv|kvform|loadjob|localize|localop|lookup|makecontinuous|makemv|makeresults|map|mcollect|metadata|metasearch|meventcollect|mstats|multikv|multisearch|mvcombine|mvexpand|nomv|outlier|outputcsv|outputlookup|outputtext|overlap|pivot|predict|rangemap|rare|regex|relevancy|reltime|rename|replace|rest|return|reverse|rex|rtorder|run|savedsearch|script|scrub|search|searchtxn|selfjoin|sendemail|set|setfields|sichart|sirare|sistats|sitimechart|sitop|sort|spath|stats|strcat|streamstats|table|tags|tail|timechart|timewrap|top|transaction|transpose|trendline|tscollect|tstats|typeahead|typelearner|typer|union|uniq|untable|where|x11|xmlkv|xmlunescape|xpath|xyseries)\b/i,
1920
+ "operator-word": {
1921
+ pattern: /\b(?:and|as|by|not|or|xor)\b/i,
1922
+ alias: "operator"
1923
+ },
1924
+ function: /\b\w+(?=\s*\()/,
1925
+ property: /\b\w+(?=\s*=(?!=))/,
1926
+ date: {
1927
+ // MM/DD/YYYY(:HH:MM:SS)?
1928
+ pattern: /\b\d{1,2}\/\d{1,2}\/\d{1,4}(?:(?::\d{1,2}){3})?\b/,
1929
+ alias: "number"
1930
+ },
1931
+ number: /\b\d+(?:\.\d+)?\b/,
1932
+ boolean: /\b(?:f|false|t|true)\b/i,
1933
+ operator: /[<>=]=?|[-+*/%|]/,
1934
+ punctuation: /[()[\],]/
1935
+ };
1936
+ })();
1937
+ /***/
1938
+ /******/ }
1939
+ };
1940
+ /************************************************************************/
1941
+ /******/ // The module cache
1942
+ /******/ var t = {};
1943
+ /******/
1944
+ /******/ // The require function
1945
+ /******/ function a(n) {
1946
+ /******/ // Check if module is in cache
1947
+ /******/ var r = t[n];
1948
+ /******/ if (r !== undefined) {
1949
+ /******/ return r.exports;
1950
+ /******/ }
1951
+ /******/ // Create a new module (and put it into the cache)
1952
+ /******/ var s = t[n] = {
1953
+ /******/ // no module.id needed
1954
+ /******/ // no module.loaded needed
1955
+ /******/ exports: {}
1956
+ /******/ };
1957
+ /******/
1958
+ /******/ // Execute the module function
1959
+ /******/ e[n](s, s.exports, a);
1960
+ /******/
1961
+ /******/ // Return the exports of the module
1962
+ /******/ return s.exports;
1963
+ /******/ }
1964
+ /******/
1965
+ /************************************************************************/
1966
+ /******/ /* webpack/runtime/compat get default export */
1967
+ /******/ (() => {
1968
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
1969
+ /******/ a.n = e => {
1970
+ /******/ var t = e && e.__esModule ?
1971
+ /******/ () => e["default"]
1972
+ /******/ : () => e
1973
+ /******/;
1974
+ a.d(t, {
1975
+ a: t
1976
+ });
1977
+ /******/ return t;
1978
+ /******/ };
1979
+ /******/ })();
1980
+ /******/
1981
+ /******/ /* webpack/runtime/define property getters */
1982
+ /******/ (() => {
1983
+ /******/ // define getter functions for harmony exports
1984
+ /******/ a.d = (e, t) => {
1985
+ /******/ for (var n in t) {
1986
+ /******/ if (a.o(t, n) && !a.o(e, n)) {
1987
+ /******/ Object.defineProperty(e, n, {
1988
+ enumerable: true,
1989
+ get: t[n]
1990
+ });
1991
+ /******/ }
1992
+ /******/ }
1993
+ /******/ };
1994
+ /******/ })();
1995
+ /******/
1996
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
1997
+ /******/ (() => {
1998
+ /******/ a.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t)
1999
+ /******/;
2213
2000
  })();
2214
-
2215
-
2216
- /***/ })
2217
-
2218
- /******/ });
2219
- /************************************************************************/
2220
- /******/ // The module cache
2221
- /******/ var __webpack_module_cache__ = {};
2222
- /******/
2223
- /******/ // The require function
2224
- /******/ function __webpack_require__(moduleId) {
2225
- /******/ // Check if module is in cache
2226
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
2227
- /******/ if (cachedModule !== undefined) {
2228
- /******/ return cachedModule.exports;
2229
- /******/ }
2230
- /******/ // Create a new module (and put it into the cache)
2231
- /******/ var module = __webpack_module_cache__[moduleId] = {
2232
- /******/ // no module.id needed
2233
- /******/ // no module.loaded needed
2234
- /******/ exports: {}
2235
- /******/ };
2236
- /******/
2237
- /******/ // Execute the module function
2238
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
2239
- /******/
2240
- /******/ // Return the exports of the module
2241
- /******/ return module.exports;
2242
- /******/ }
2243
- /******/
2244
- /************************************************************************/
2245
- /******/ /* webpack/runtime/compat get default export */
2246
- /******/ (() => {
2247
- /******/ // getDefaultExport function for compatibility with non-harmony modules
2248
- /******/ __webpack_require__.n = (module) => {
2249
- /******/ var getter = module && module.__esModule ?
2250
- /******/ () => (module['default']) :
2251
- /******/ () => (module);
2252
- /******/ __webpack_require__.d(getter, { a: getter });
2253
- /******/ return getter;
2254
- /******/ };
2255
- /******/ })();
2256
- /******/
2257
- /******/ /* webpack/runtime/define property getters */
2258
- /******/ (() => {
2259
- /******/ // define getter functions for harmony exports
2260
- /******/ __webpack_require__.d = (exports, definition) => {
2261
- /******/ for(var key in definition) {
2262
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
2263
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
2264
- /******/ }
2265
- /******/ }
2266
- /******/ };
2267
- /******/ })();
2268
- /******/
2269
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
2270
- /******/ (() => {
2271
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
2272
- /******/ })();
2273
- /******/
2274
- /******/ /* webpack/runtime/make namespace object */
2275
- /******/ (() => {
2276
- /******/ // define __esModule on exports
2277
- /******/ __webpack_require__.r = (exports) => {
2278
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
2279
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2280
- /******/ }
2281
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
2282
- /******/ };
2283
- /******/ })();
2284
- /******/
2285
- /************************************************************************/
2286
- var __webpack_exports__ = {};
2287
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
2288
- (() => {
2289
- "use strict";
2290
- // ESM COMPAT FLAG
2291
- __webpack_require__.r(__webpack_exports__);
2292
-
2293
- // EXPORTS
2294
- __webpack_require__.d(__webpack_exports__, {
2295
- "default": () => (/* reexport */ Code_Code)
2296
- });
2297
-
2298
- ;// CONCATENATED MODULE: external "react"
2299
- const external_react_namespaceObject = require("react");
2300
- var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_namespaceObject);
2301
- ;// CONCATENATED MODULE: external "prop-types"
2302
- const external_prop_types_namespaceObject = require("prop-types");
2303
- var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_namespaceObject);
2304
- ;// CONCATENATED MODULE: external "lodash/castArray"
2305
- const castArray_namespaceObject = require("lodash/castArray");
2306
- var castArray_default = /*#__PURE__*/__webpack_require__.n(castArray_namespaceObject);
2307
- ;// CONCATENATED MODULE: external "lodash/flatten"
2308
- const flatten_namespaceObject = require("lodash/flatten");
2309
- var flatten_default = /*#__PURE__*/__webpack_require__.n(flatten_namespaceObject);
2310
- ;// CONCATENATED MODULE: external "lodash/indexOf"
2311
- const indexOf_namespaceObject = require("lodash/indexOf");
2312
- var indexOf_default = /*#__PURE__*/__webpack_require__.n(indexOf_namespaceObject);
2313
- ;// CONCATENATED MODULE: external "lodash/repeat"
2314
- const repeat_namespaceObject = require("lodash/repeat");
2315
- var repeat_default = /*#__PURE__*/__webpack_require__.n(repeat_namespaceObject);
2316
- ;// CONCATENATED MODULE: external "lodash/times"
2317
- const times_namespaceObject = require("lodash/times");
2318
- var times_default = /*#__PURE__*/__webpack_require__.n(times_namespaceObject);
2319
- // EXTERNAL MODULE: ./src/Code/prism/prism.empty
2320
- var prism_empty = __webpack_require__(74);
2321
- var prism_empty_default = /*#__PURE__*/__webpack_require__.n(prism_empty);
2322
- ;// CONCATENATED MODULE: external "styled-components"
2323
- const external_styled_components_namespaceObject = require("styled-components");
2324
- var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_namespaceObject);
2325
- ;// CONCATENATED MODULE: external "@splunk/themes"
2326
- const themes_namespaceObject = require("@splunk/themes");
2327
- ;// CONCATENATED MODULE: ./src/Code/CodeStyles.ts
2328
-
2329
-
2330
- var Styled = external_styled_components_default().pre.withConfig({
2331
- displayName: "CodeStyles__Styled",
2332
- componentId: "sc-1eq4k68-0"
2333
- })(["", ";", " line-height:", ";text-align:left;tab-size:4;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;hyphens:none;overflow-x:auto;margin-bottom:1.3em;&:focus-visible{outline:solid ", ";}"], themes_namespaceObject.mixins.reset('block'), (0,themes_namespaceObject.pick)({
2334
- enterprise: {
2335
- dark: (0,external_styled_components_namespaceObject.css)(["color:", ";"], themes_namespaceObject.variables.gray92)
2336
- }
2337
- }), (0,themes_namespaceObject.pick)({
2338
- enterprise: '17px',
2339
- prisma: themes_namespaceObject.variables.lineHeight
2340
- }), themes_namespaceObject.variables.focusColor);
2341
- var StyledCode = external_styled_components_default().code.withConfig({
2342
- displayName: "CodeStyles__StyledCode",
2343
- componentId: "sc-1eq4k68-1"
2344
- })(["font-family:", ";"], themes_namespaceObject.variables.monoFontFamily);
2345
- var StyledIndent = external_styled_components_default().span.withConfig({
2346
- displayName: "CodeStyles__StyledIndent",
2347
- componentId: "sc-1eq4k68-2"
2348
- })(["&:not(:last-child){background-image:linear-gradient( to left,rgba(0,0,0,0.15) 1px,transparent 1px,transparent );}"]);
2349
- var gray = (0,themes_namespaceObject.pick)({
2350
- prisma: themes_namespaceObject.variables.syntaxGray,
2351
- enterprise: {
2352
- dark: themes_namespaceObject.variables.gray60,
2353
- light: themes_namespaceObject.variables.syntaxGray
2354
- }
2355
- });
2356
- var purple = (0,themes_namespaceObject.pick)({
2357
- prisma: themes_namespaceObject.variables.syntaxPurple,
2358
- enterprise: {
2359
- dark: themes_namespaceObject.variables.syntaxPurpleLight,
2360
- light: themes_namespaceObject.variables.syntaxPurple
2361
- }
2362
- });
2363
- var green = (0,themes_namespaceObject.pick)({
2364
- prisma: themes_namespaceObject.variables.syntaxGreen,
2365
- enterprise: {
2366
- dark: themes_namespaceObject.variables.syntaxGreenLight,
2367
- light: themes_namespaceObject.variables.syntaxGreen
2368
- }
2369
- });
2370
- var blue = (0,themes_namespaceObject.pick)({
2371
- prisma: themes_namespaceObject.variables.syntaxBlue,
2372
- enterprise: {
2373
- dark: themes_namespaceObject.variables.syntaxBlueLight,
2374
- light: themes_namespaceObject.variables.syntaxBlue
2375
- }
2376
- });
2377
- var red = (0,themes_namespaceObject.pick)({
2378
- prisma: themes_namespaceObject.variables.syntaxRed,
2379
- enterprise: {
2380
- dark: themes_namespaceObject.variables.syntaxRedLight,
2381
- light: themes_namespaceObject.variables.syntaxRed
2382
- }
2383
- });
2384
- var TokenColors = {
2385
- comment: gray,
2386
- prolog: gray,
2387
- doctype: gray,
2388
- cdata: gray,
2389
- punctuation: gray,
2390
- property: purple,
2391
- tag: purple,
2392
- "boolean": purple,
2393
- number: purple,
2394
- constant: purple,
2395
- symbol: purple,
2396
- deleted: purple,
2397
- key: purple,
2398
- selector: green,
2399
- 'attr-name': green,
2400
- string: green,
2401
- "char": green,
2402
- builtin: green,
2403
- inserted: green,
2404
- operator: themes_namespaceObject.variables.syntaxBrown,
2405
- entity: themes_namespaceObject.variables.syntaxBrown,
2406
- url: themes_namespaceObject.variables.syntaxBrown,
2407
- atrule: blue,
2408
- 'attr-value': blue,
2409
- keyword: blue,
2410
- "function": red,
2411
- regex: themes_namespaceObject.variables.syntaxOrange,
2412
- important: themes_namespaceObject.variables.syntaxOrange,
2413
- variable: themes_namespaceObject.variables.syntaxOrange
2414
- };
2415
- var StyledToken = external_styled_components_default().span.withConfig({
2416
- displayName: "CodeStyles__StyledToken",
2417
- componentId: "sc-1eq4k68-3"
2418
- })(["color:", ";cursor:", ";opacity:", ";font-style:", ";font-weight:", ";"], function (_ref) {
2419
- var partType = _ref.partType;
2420
- return TokenColors[partType];
2421
- }, function (_ref2) {
2422
- var partType = _ref2.partType;
2423
- return partType === 'entity' ? 'help' : null;
2424
- }, function (_ref3) {
2425
- var partType = _ref3.partType;
2426
- return partType === 'namespace' ? 0.7 : null;
2427
- }, function (_ref4) {
2428
- var partType = _ref4.partType;
2429
- return partType === 'italic' ? 'italic' : null;
2430
- }, function (_ref5) {
2431
- var partType = _ref5.partType;
2432
- return partType === 'important' || partType === 'bold' ? 'bold' : null;
2433
- });
2434
-
2435
- ;// CONCATENATED MODULE: ./src/Code/Code.tsx
2436
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2437
-
2438
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
2439
-
2440
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2441
-
2442
-
2443
-
2444
-
2445
-
2446
-
2447
-
2448
- // Prism requires special handling to work around issues related to global scope and
2449
- // auto formatting. The import below points to an empty file which is replaced at build
2450
- // time, see ./prism/build-isolated-prism.js for details.
2451
-
2452
- // typed as 'prismjs'
2453
-
2454
-
2455
- var supportedLanguages = ['bash', 'clike', 'css', 'html', 'json', 'javascript', 'js', 'jsx', 'typescript', 'ts', 'tsx', 'markup', 'mathml', 'splunk-spl', 'svg', 'xml', 'yaml', 'yml'];
2456
-
2457
- function tokenize(text, language) {
2458
- return prism_empty_default().tokenize(text, (prism_empty_default()).languages[language]);
2459
- }
2460
-
2461
- var propTypes = {
2462
- elementRef: external_prop_types_default().oneOfType([(external_prop_types_default()).func, (external_prop_types_default()).object]),
2463
- indentChars: (external_prop_types_default()).number,
2464
- language: external_prop_types_default().oneOf(supportedLanguages),
2465
- languageFallback: external_prop_types_default().oneOf(supportedLanguages),
2466
- showIndentGuide: (external_prop_types_default()).bool,
2467
- value: (external_prop_types_default()).string
2468
- };
2469
-
2470
- function Code(_ref) {
2471
- var elementRef = _ref.elementRef,
2472
- _ref$indentChars = _ref.indentChars,
2473
- indentChars = _ref$indentChars === void 0 ? 4 : _ref$indentChars,
2474
- language = _ref.language,
2475
- _ref$languageFallback = _ref.languageFallback,
2476
- languageFallback = _ref$languageFallback === void 0 ? 'javascript' : _ref$languageFallback,
2477
- _ref$showIndentGuide = _ref.showIndentGuide,
2478
- showIndentGuide = _ref$showIndentGuide === void 0 ? true : _ref$showIndentGuide,
2479
- _ref$value = _ref.value,
2480
- value = _ref$value === void 0 ? '' : _ref$value,
2481
- otherProps = _objectWithoutProperties(_ref, ["elementRef", "indentChars", "language", "languageFallback", "showIndentGuide", "value"]);
2482
-
2483
- // @docs-props-type CodePropsBase
2484
- var indentBlock = repeat_default()(' ', indentChars);
2485
-
2486
- var makeIndentGuide = function makeIndentGuide(spaces) {
2487
- var level = Math.floor(spaces / indentChars);
2488
- var rest = spaces % indentChars;
2489
- var spans = times_default()(level, function (idx) {
2490
- return /*#__PURE__*/external_react_default().createElement(StyledIndent, {
2491
- key: idx.toString()
2492
- }, indentBlock);
2493
- });
2494
-
2495
- if (rest) {
2496
- spans.push(repeat_default()(' ', rest));
2497
- }
2498
-
2499
- return spans;
2500
- }; // a fix for SUI-5425, where the Markdown component doesn't pass a valid language in some circumstances
2501
-
2502
-
2503
- var isSupportedLanguage = indexOf_default()(supportedLanguages, language) > -1;
2504
-
2505
- if (false) {}
2506
-
2507
- var languageUsed = isSupportedLanguage && language ? language : languageFallback;
2508
- var tokens = tokenize(value, languageUsed);
2509
-
2510
- var render = function render(tks) {
2511
- return castArray_default()(tks).map(function (part, idx) {
2512
- if (typeof part === 'string') {
2513
- if (!showIndentGuide) {
2514
- return part;
2001
+ /******/
2002
+ /******/ /* webpack/runtime/make namespace object */
2003
+ /******/ (() => {
2004
+ /******/ // define __esModule on exports
2005
+ /******/ a.r = e => {
2006
+ /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
2007
+ /******/ Object.defineProperty(e, Symbol.toStringTag, {
2008
+ value: "Module"
2009
+ });
2010
+ /******/ }
2011
+ /******/ Object.defineProperty(e, "__esModule", {
2012
+ value: true
2013
+ });
2014
+ /******/ };
2015
+ /******/ })();
2016
+ /******/
2017
+ /************************************************************************/ var n = {};
2018
+ // This entry need to be wrapped in an IIFE because it need to be in strict mode.
2019
+ (() => {
2020
+ "use strict";
2021
+ // ESM COMPAT FLAG
2022
+ a.r(n);
2023
+ // EXPORTS
2024
+ a.d(n, {
2025
+ default: () => /* reexport */ L
2026
+ });
2027
+ // CONCATENATED MODULE: external "react"
2028
+ const e = require("react");
2029
+ var t = a.n(e);
2030
+ // CONCATENATED MODULE: external "prop-types"
2031
+ const r = require("prop-types");
2032
+ var s = a.n(r);
2033
+ // CONCATENATED MODULE: external "lodash/castArray"
2034
+ const i = require("lodash/castArray");
2035
+ var o = a.n(i);
2036
+ // CONCATENATED MODULE: external "lodash/flatten"
2037
+ const l = require("lodash/flatten");
2038
+ var u = a.n(l);
2039
+ // CONCATENATED MODULE: external "lodash/indexOf"
2040
+ const c = require("lodash/indexOf");
2041
+ var p = a.n(c);
2042
+ // CONCATENATED MODULE: external "lodash/repeat"
2043
+ const d = require("lodash/repeat");
2044
+ var g = a.n(d);
2045
+ // CONCATENATED MODULE: external "lodash/times"
2046
+ const f = require("lodash/times");
2047
+ var m = a.n(f);
2048
+ // EXTERNAL MODULE: ./src/Code/prism/prism.empty
2049
+ var h = a(74);
2050
+ var v = a.n(h);
2051
+ // CONCATENATED MODULE: external "styled-components"
2052
+ const b = require("styled-components");
2053
+ var y = a.n(b);
2054
+ // CONCATENATED MODULE: external "@splunk/themes"
2055
+ const k = require("@splunk/themes");
2056
+ // CONCATENATED MODULE: ./src/Code/CodeStyles.ts
2057
+ var x = y().pre.withConfig({
2058
+ displayName: "CodeStyles__Styled",
2059
+ componentId: "sc-1eq4k68-0"
2060
+ })([ "", ";", " line-height:", ";text-align:left;tab-size:4;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;hyphens:none;overflow-x:auto;margin-bottom:1.3em;&:focus-visible{outline:solid ", ";}" ], k.mixins.reset("block"), (0,
2061
+ k.pick)({
2062
+ enterprise: {
2063
+ dark: (0, b.css)([ "color:", ";" ], k.variables.gray92)
2064
+ }
2065
+ }), (0, k.pick)({
2066
+ enterprise: "17px",
2067
+ prisma: k.variables.lineHeight
2068
+ }), k.variables.focusColor);
2069
+ var S = y().code.withConfig({
2070
+ displayName: "CodeStyles__StyledCode",
2071
+ componentId: "sc-1eq4k68-1"
2072
+ })([ "font-family:", ";" ], k.variables.monoFontFamily);
2073
+ var A = y().span.withConfig({
2074
+ displayName: "CodeStyles__StyledIndent",
2075
+ componentId: "sc-1eq4k68-2"
2076
+ })([ "&:not(:last-child){background-image:linear-gradient( to left,rgba(0,0,0,0.15) 1px,transparent 1px,transparent );}" ]);
2077
+ var F = (0, k.pick)({
2078
+ prisma: k.variables.syntaxGray,
2079
+ enterprise: {
2080
+ dark: k.variables.gray60,
2081
+ light: k.variables.syntaxGray
2082
+ }
2083
+ });
2084
+ var w = (0, k.pick)({
2085
+ prisma: k.variables.syntaxPurple,
2086
+ enterprise: {
2087
+ dark: k.variables.syntaxPurpleLight,
2088
+ light: k.variables.syntaxPurple
2089
+ }
2090
+ });
2091
+ var E = (0, k.pick)({
2092
+ prisma: k.variables.syntaxGreen,
2093
+ enterprise: {
2094
+ dark: k.variables.syntaxGreenLight,
2095
+ light: k.variables.syntaxGreen
2096
+ }
2097
+ });
2098
+ var _ = (0, k.pick)({
2099
+ prisma: k.variables.syntaxBlue,
2100
+ enterprise: {
2101
+ dark: k.variables.syntaxBlueLight,
2102
+ light: k.variables.syntaxBlue
2103
+ }
2104
+ });
2105
+ var O = (0, k.pick)({
2106
+ prisma: k.variables.syntaxRed,
2107
+ enterprise: {
2108
+ dark: k.variables.syntaxRedLight,
2109
+ light: k.variables.syntaxRed
2110
+ }
2111
+ });
2112
+ var T = {
2113
+ comment: F,
2114
+ prolog: F,
2115
+ doctype: F,
2116
+ cdata: F,
2117
+ punctuation: F,
2118
+ property: w,
2119
+ tag: w,
2120
+ boolean: w,
2121
+ number: w,
2122
+ constant: w,
2123
+ symbol: w,
2124
+ deleted: w,
2125
+ key: w,
2126
+ selector: E,
2127
+ "attr-name": E,
2128
+ string: E,
2129
+ char: E,
2130
+ builtin: E,
2131
+ inserted: E,
2132
+ operator: k.variables.syntaxBrown,
2133
+ entity: k.variables.syntaxBrown,
2134
+ url: k.variables.syntaxBrown,
2135
+ atrule: _,
2136
+ "attr-value": _,
2137
+ keyword: _,
2138
+ function: O,
2139
+ regex: k.variables.syntaxOrange,
2140
+ important: k.variables.syntaxOrange,
2141
+ variable: k.variables.syntaxOrange
2142
+ };
2143
+ var I = y().span.withConfig({
2144
+ displayName: "CodeStyles__StyledToken",
2145
+ componentId: "sc-1eq4k68-3"
2146
+ })([ "color:", ";cursor:", ";opacity:", ";font-style:", ";font-weight:", ";" ], (function(e) {
2147
+ var t = e.partType;
2148
+ return T[t];
2149
+ }), (function(e) {
2150
+ var t = e.partType;
2151
+ return t === "entity" ? "help" : null;
2152
+ }), (function(e) {
2153
+ var t = e.partType;
2154
+ return t === "namespace" ? .7 : null;
2155
+ }), (function(e) {
2156
+ var t = e.partType;
2157
+ return t === "italic" ? "italic" : null;
2158
+ }), (function(e) {
2159
+ var t = e.partType;
2160
+ return t === "important" || t === "bold" ? "bold" : null;
2161
+ }));
2162
+ // CONCATENATED MODULE: ./src/Code/Code.tsx
2163
+ function $() {
2164
+ $ = Object.assign || function(e) {
2165
+ for (var t = 1; t < arguments.length; t++) {
2166
+ var a = arguments[t];
2167
+ for (var n in a) {
2168
+ if (Object.prototype.hasOwnProperty.call(a, n)) {
2169
+ e[n] = a[n];
2170
+ }
2171
+ }
2172
+ }
2173
+ return e;
2174
+ };
2175
+ return $.apply(this, arguments);
2515
2176
  }
2516
-
2517
- var lines = part.split('\n');
2518
-
2519
- if (lines.length === 1) {
2520
- return part;
2177
+ function N(e, t) {
2178
+ if (e == null) return {};
2179
+ var a = P(e, t);
2180
+ var n, r;
2181
+ if (Object.getOwnPropertySymbols) {
2182
+ var s = Object.getOwnPropertySymbols(e);
2183
+ for (r = 0; r < s.length; r++) {
2184
+ n = s[r];
2185
+ if (t.indexOf(n) >= 0) continue;
2186
+ if (!Object.prototype.propertyIsEnumerable.call(e, n)) continue;
2187
+ a[n] = e[n];
2188
+ }
2189
+ }
2190
+ return a;
2521
2191
  }
2522
-
2523
- return flatten_default()(lines.map(function (line, lineNo) {
2524
- var res = lineNo === 0 ? [] : ['\n'];
2525
- var indentMatch = line.match(/^(\s+)(.*)/);
2526
-
2527
- if (!indentMatch) {
2528
- res.push(line);
2529
- } else {
2530
- res.push( /*#__PURE__*/external_react_default().createElement("span", {
2531
- key: "".concat(idx.toString(), ":").concat(lineNo.toString())
2532
- }, makeIndentGuide(indentMatch[1].length)), indentMatch[2]);
2533
- }
2534
-
2535
- return res;
2536
- }));
2537
- }
2538
-
2539
- var content = typeof part.content === 'string' ? part.content : render(part.content);
2540
- return /*#__PURE__*/external_react_default().createElement(StyledToken, {
2541
- "data-part-type": part.type,
2542
- partType: part.type,
2543
- key: idx.toString()
2544
- }, content);
2545
- });
2546
- };
2547
-
2548
- var codeContent = render(tokens);
2549
- return /*#__PURE__*/external_react_default().createElement(Styled, _extends({
2550
- "data-test": "code",
2551
- ref: elementRef,
2552
- tabIndex: 0
2553
- }, otherProps), /*#__PURE__*/external_react_default().createElement(StyledCode, {
2554
- className: "language-".concat(languageUsed)
2555
- }, codeContent));
2556
- }
2557
-
2558
- Code.propTypes = propTypes;
2559
- /* harmony default export */ const Code_Code = (Code);
2560
- ;// CONCATENATED MODULE: ./src/Code/index.ts
2561
-
2562
- })();
2563
-
2564
- module.exports = __webpack_exports__;
2565
- /******/ })()
2566
- ;
2192
+ function P(e, t) {
2193
+ if (e == null) return {};
2194
+ var a = {};
2195
+ var n = Object.keys(e);
2196
+ var r, s;
2197
+ for (s = 0; s < n.length; s++) {
2198
+ r = n[s];
2199
+ if (t.indexOf(r) >= 0) continue;
2200
+ a[r] = e[r];
2201
+ }
2202
+ return a;
2203
+ }
2204
+ // Prism requires special handling to work around issues related to global scope and
2205
+ // auto formatting. The import below points to an empty file which is replaced at build
2206
+ // time, see ./prism/build-isolated-prism.js for details.
2207
+ // typed as 'prismjs'
2208
+ var R = [ "bash", "clike", "css", "html", "json", "javascript", "js", "jsx", "typescript", "ts", "tsx", "markup", "mathml", "splunk-spl", "svg", "xml", "yaml", "yml" ];
2209
+ function C(e, t) {
2210
+ return v().tokenize(e, v().languages[t]);
2211
+ }
2212
+ var D = {
2213
+ elementRef: s().oneOfType([ s().func, s().object ]),
2214
+ indentChars: s().number,
2215
+ language: s().oneOf(R),
2216
+ languageFallback: s().oneOf(R),
2217
+ showIndentGuide: s().bool,
2218
+ value: s().string
2219
+ };
2220
+ function j(e) {
2221
+ var a = e.elementRef, n = e.indentChars, r = n === void 0 ? 4 : n, s = e.language, i = e.languageFallback, l = i === void 0 ? "javascript" : i, c = e.showIndentGuide, d = c === void 0 ? true : c, f = e.value, h = f === void 0 ? "" : f, v = N(e, [ "elementRef", "indentChars", "language", "languageFallback", "showIndentGuide", "value" ]);
2222
+ // @docs-props-type CodePropsBase
2223
+ var b = g()(" ", r);
2224
+ var y = function e(a) {
2225
+ var n = Math.floor(a / r);
2226
+ var s = a % r;
2227
+ var i = m()(n, (function(e) {
2228
+
2229
+ return t().createElement(A, {
2230
+ key: e.toString()
2231
+ }, b);
2232
+ }));
2233
+ if (s) {
2234
+ i.push(g()(" ", s));
2235
+ }
2236
+ return i;
2237
+ };
2238
+ // a fix for SUI-5425, where the Markdown component doesn't pass a valid language in some circumstances
2239
+ var k = p()(R, s) > -1;
2240
+ if (false) {}
2241
+ var F = k && s ? s : l;
2242
+ var w = C(h, F);
2243
+ var E = function e(a) {
2244
+ return o()(a).map((function(a, n) {
2245
+ if (typeof a === "string") {
2246
+ if (!d) {
2247
+ return a;
2248
+ }
2249
+ var r = a.split("\n");
2250
+ if (r.length === 1) {
2251
+ return a;
2252
+ }
2253
+ return u()(r.map((function(e, a) {
2254
+ var r = a === 0 ? [] : [ "\n" ];
2255
+ var s = e.match(/^(\s+)(.*)/);
2256
+ if (!s) {
2257
+ r.push(e);
2258
+ } else {
2259
+ r.push( t().createElement("span", {
2260
+ key: "".concat(n.toString(), ":").concat(a.toString())
2261
+ }, y(s[1].length)), s[2]);
2262
+ }
2263
+ return r;
2264
+ })));
2265
+ }
2266
+ var s = typeof a.content === "string" ? a.content : e(a.content);
2267
+
2268
+ return t().createElement(I, {
2269
+ "data-part-type": a.type,
2270
+ partType: a.type,
2271
+ key: n.toString()
2272
+ }, s);
2273
+ }));
2274
+ };
2275
+ var _ = E(w);
2276
+
2277
+ return t().createElement(x, $({
2278
+ "data-test": "code",
2279
+ ref: a,
2280
+ tabIndex: 0
2281
+ }, v), t().createElement(S, {
2282
+ className: "language-".concat(F)
2283
+ }, _));
2284
+ }
2285
+ j.propTypes = D;
2286
+ /* harmony default export */ const L = j;
2287
+ }) // CONCATENATED MODULE: ./src/Code/index.ts
2288
+ ();
2289
+ module.exports = n;
2290
+ /******/})();