@chocolatey-software/ccm 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3255 @@
1
+ (() => {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // src/scripts/lib/prism.js
29
+ var require_prism = __commonJS({
30
+ "src/scripts/lib/prism.js"(exports, module) {
31
+ var _self = typeof window !== "undefined" ? window : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
32
+ var Prism = (function(_self2) {
33
+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
34
+ var uniqueId = 0;
35
+ var plainTextGrammar = {};
36
+ var _ = {
37
+ /**
38
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
39
+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
40
+ * additional languages or plugins yourself.
41
+ *
42
+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
43
+ *
44
+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
45
+ * empty Prism object into the global scope before loading the Prism script like this:
46
+ *
47
+ * ```js
48
+ * window.Prism = window.Prism || {};
49
+ * Prism.manual = true;
50
+ * // add a new <script> to load Prism's script
51
+ * ```
52
+ *
53
+ * @default false
54
+ * @type {boolean}
55
+ * @memberof Prism
56
+ * @public
57
+ */
58
+ manual: _self2.Prism && _self2.Prism.manual,
59
+ /**
60
+ * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
61
+ * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
62
+ * own worker, you don't want it to do this.
63
+ *
64
+ * By setting this value to `true`, Prism will not add its own listeners to the worker.
65
+ *
66
+ * You obviously have to change this value before Prism executes. To do this, you can add an
67
+ * empty Prism object into the global scope before loading the Prism script like this:
68
+ *
69
+ * ```js
70
+ * window.Prism = window.Prism || {};
71
+ * Prism.disableWorkerMessageHandler = true;
72
+ * // Load Prism's script
73
+ * ```
74
+ *
75
+ * @default false
76
+ * @type {boolean}
77
+ * @memberof Prism
78
+ * @public
79
+ */
80
+ disableWorkerMessageHandler: _self2.Prism && _self2.Prism.disableWorkerMessageHandler,
81
+ /**
82
+ * A namespace for utility methods.
83
+ *
84
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
85
+ * change or disappear at any time.
86
+ *
87
+ * @namespace
88
+ * @memberof Prism
89
+ */
90
+ util: {
91
+ encode: function encode(tokens) {
92
+ if (tokens instanceof Token) {
93
+ return new Token(tokens.type, encode(tokens.content), tokens.alias);
94
+ } else if (Array.isArray(tokens)) {
95
+ return tokens.map(encode);
96
+ } else {
97
+ return tokens.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\u00a0/g, " ");
98
+ }
99
+ },
100
+ /**
101
+ * Returns the name of the type of the given value.
102
+ *
103
+ * @param {any} o
104
+ * @returns {string}
105
+ * @example
106
+ * type(null) === 'Null'
107
+ * type(undefined) === 'Undefined'
108
+ * type(123) === 'Number'
109
+ * type('foo') === 'String'
110
+ * type(true) === 'Boolean'
111
+ * type([1, 2]) === 'Array'
112
+ * type({}) === 'Object'
113
+ * type(String) === 'Function'
114
+ * type(/abc+/) === 'RegExp'
115
+ */
116
+ type: function(o) {
117
+ return Object.prototype.toString.call(o).slice(8, -1);
118
+ },
119
+ /**
120
+ * Returns a unique number for the given object. Later calls will still return the same number.
121
+ *
122
+ * @param {Object} obj
123
+ * @returns {number}
124
+ */
125
+ objId: function(obj) {
126
+ if (!obj["__id"]) {
127
+ Object.defineProperty(obj, "__id", { value: ++uniqueId });
128
+ }
129
+ return obj["__id"];
130
+ },
131
+ /**
132
+ * Creates a deep clone of the given object.
133
+ *
134
+ * The main intended use of this function is to clone language definitions.
135
+ *
136
+ * @param {T} o
137
+ * @param {Record<number, any>} [visited]
138
+ * @returns {T}
139
+ * @template T
140
+ */
141
+ clone: function deepClone(o, visited) {
142
+ visited = visited || {};
143
+ var clone;
144
+ var id;
145
+ switch (_.util.type(o)) {
146
+ case "Object":
147
+ id = _.util.objId(o);
148
+ if (visited[id]) {
149
+ return visited[id];
150
+ }
151
+ clone = /** @type {Record<string, any>} */
152
+ {};
153
+ visited[id] = clone;
154
+ for (var key in o) {
155
+ if (o.hasOwnProperty(key)) {
156
+ clone[key] = deepClone(o[key], visited);
157
+ }
158
+ }
159
+ return (
160
+ /** @type {any} */
161
+ clone
162
+ );
163
+ case "Array":
164
+ id = _.util.objId(o);
165
+ if (visited[id]) {
166
+ return visited[id];
167
+ }
168
+ clone = [];
169
+ visited[id] = clone;
170
+ /** @type {Array} */
171
+ /** @type {any} */
172
+ o.forEach(function(v, i) {
173
+ clone[i] = deepClone(v, visited);
174
+ });
175
+ return (
176
+ /** @type {any} */
177
+ clone
178
+ );
179
+ default:
180
+ return o;
181
+ }
182
+ },
183
+ /**
184
+ * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
185
+ *
186
+ * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
187
+ *
188
+ * @param {Element} element
189
+ * @returns {string}
190
+ */
191
+ getLanguage: function(element) {
192
+ while (element) {
193
+ var m = lang.exec(element.className);
194
+ if (m) {
195
+ return m[1].toLowerCase();
196
+ }
197
+ element = element.parentElement;
198
+ }
199
+ return "none";
200
+ },
201
+ /**
202
+ * Sets the Prism `language-xxxx` class of the given element.
203
+ *
204
+ * @param {Element} element
205
+ * @param {string} language
206
+ * @returns {void}
207
+ */
208
+ setLanguage: function(element, language) {
209
+ element.className = element.className.replace(RegExp(lang, "gi"), "");
210
+ element.classList.add("language-" + language);
211
+ },
212
+ /**
213
+ * Returns the script element that is currently executing.
214
+ *
215
+ * This does __not__ work for line script element.
216
+ *
217
+ * @returns {HTMLScriptElement | null}
218
+ */
219
+ currentScript: function() {
220
+ if (typeof document === "undefined") {
221
+ return null;
222
+ }
223
+ if (document.currentScript && document.currentScript.tagName === "SCRIPT" && 1 < 2) {
224
+ return (
225
+ /** @type {any} */
226
+ document.currentScript
227
+ );
228
+ }
229
+ try {
230
+ throw new Error();
231
+ } catch (err) {
232
+ var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
233
+ if (src) {
234
+ var scripts = document.getElementsByTagName("script");
235
+ for (var i in scripts) {
236
+ if (scripts[i].src == src) {
237
+ return scripts[i];
238
+ }
239
+ }
240
+ }
241
+ return null;
242
+ }
243
+ },
244
+ /**
245
+ * Returns whether a given class is active for `element`.
246
+ *
247
+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
248
+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
249
+ * given class is just the given class with a `no-` prefix.
250
+ *
251
+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
252
+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
253
+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
254
+ *
255
+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
256
+ * version of it, the class is considered active.
257
+ *
258
+ * @param {Element} element
259
+ * @param {string} className
260
+ * @param {boolean} [defaultActivation=false]
261
+ * @returns {boolean}
262
+ */
263
+ isActive: function(element, className, defaultActivation) {
264
+ var no = "no-" + className;
265
+ while (element) {
266
+ var classList = element.classList;
267
+ if (classList.contains(className)) {
268
+ return true;
269
+ }
270
+ if (classList.contains(no)) {
271
+ return false;
272
+ }
273
+ element = element.parentElement;
274
+ }
275
+ return !!defaultActivation;
276
+ }
277
+ },
278
+ /**
279
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
280
+ *
281
+ * @namespace
282
+ * @memberof Prism
283
+ * @public
284
+ */
285
+ languages: {
286
+ /**
287
+ * The grammar for plain, unformatted text.
288
+ */
289
+ plain: plainTextGrammar,
290
+ plaintext: plainTextGrammar,
291
+ text: plainTextGrammar,
292
+ txt: plainTextGrammar,
293
+ /**
294
+ * Creates a deep copy of the language with the given id and appends the given tokens.
295
+ *
296
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
297
+ * will be overwritten at its original position.
298
+ *
299
+ * ## Best practices
300
+ *
301
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
302
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
303
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
304
+ *
305
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
306
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
307
+ *
308
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
309
+ * @param {Grammar} redef The new tokens to append.
310
+ * @returns {Grammar} The new language created.
311
+ * @public
312
+ * @example
313
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
314
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
315
+ * // at its original position
316
+ * 'comment': { ... },
317
+ * // CSS doesn't have a 'color' token, so this token will be appended
318
+ * 'color': /\b(?:red|green|blue)\b/
319
+ * });
320
+ */
321
+ extend: function(id, redef) {
322
+ var lang2 = _.util.clone(_.languages[id]);
323
+ for (var key in redef) {
324
+ lang2[key] = redef[key];
325
+ }
326
+ return lang2;
327
+ },
328
+ /**
329
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
330
+ *
331
+ * ## Usage
332
+ *
333
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
334
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
335
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
336
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
337
+ * this:
338
+ *
339
+ * ```js
340
+ * Prism.languages.markup.style = {
341
+ * // token
342
+ * };
343
+ * ```
344
+ *
345
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
346
+ * before existing tokens. For the CSS example above, you would use it like this:
347
+ *
348
+ * ```js
349
+ * Prism.languages.insertBefore('markup', 'cdata', {
350
+ * 'style': {
351
+ * // token
352
+ * }
353
+ * });
354
+ * ```
355
+ *
356
+ * ## Special cases
357
+ *
358
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
359
+ * will be ignored.
360
+ *
361
+ * This behavior can be used to insert tokens after `before`:
362
+ *
363
+ * ```js
364
+ * Prism.languages.insertBefore('markup', 'comment', {
365
+ * 'comment': Prism.languages.markup.comment,
366
+ * // tokens after 'comment'
367
+ * });
368
+ * ```
369
+ *
370
+ * ## Limitations
371
+ *
372
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
373
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
374
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
375
+ * deleting properties which is necessary to insert at arbitrary positions.
376
+ *
377
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
378
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
379
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
380
+ *
381
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
382
+ * you hold the target object in a variable, then the value of the variable will not change.
383
+ *
384
+ * ```js
385
+ * var oldMarkup = Prism.languages.markup;
386
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
387
+ *
388
+ * assert(oldMarkup !== Prism.languages.markup);
389
+ * assert(newMarkup === Prism.languages.markup);
390
+ * ```
391
+ *
392
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
393
+ * object to be modified.
394
+ * @param {string} before The key to insert before.
395
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
396
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
397
+ * object to be modified.
398
+ *
399
+ * Defaults to `Prism.languages`.
400
+ * @returns {Grammar} The new grammar object.
401
+ * @public
402
+ */
403
+ insertBefore: function(inside, before, insert, root) {
404
+ root = root || /** @type {any} */
405
+ _.languages;
406
+ var grammar = root[inside];
407
+ var ret = {};
408
+ for (var token in grammar) {
409
+ if (grammar.hasOwnProperty(token)) {
410
+ if (token == before) {
411
+ for (var newToken in insert) {
412
+ if (insert.hasOwnProperty(newToken)) {
413
+ ret[newToken] = insert[newToken];
414
+ }
415
+ }
416
+ }
417
+ if (!insert.hasOwnProperty(token)) {
418
+ ret[token] = grammar[token];
419
+ }
420
+ }
421
+ }
422
+ var old = root[inside];
423
+ root[inside] = ret;
424
+ _.languages.DFS(_.languages, function(key, value) {
425
+ if (value === old && key != inside) {
426
+ this[key] = ret;
427
+ }
428
+ });
429
+ return ret;
430
+ },
431
+ // Traverse a language definition with Depth First Search
432
+ DFS: function DFS(o, callback, type, visited) {
433
+ visited = visited || {};
434
+ var objId = _.util.objId;
435
+ for (var i in o) {
436
+ if (o.hasOwnProperty(i)) {
437
+ callback.call(o, i, o[i], type || i);
438
+ var property = o[i];
439
+ var propertyType = _.util.type(property);
440
+ if (propertyType === "Object" && !visited[objId(property)]) {
441
+ visited[objId(property)] = true;
442
+ DFS(property, callback, null, visited);
443
+ } else if (propertyType === "Array" && !visited[objId(property)]) {
444
+ visited[objId(property)] = true;
445
+ DFS(property, callback, i, visited);
446
+ }
447
+ }
448
+ }
449
+ }
450
+ },
451
+ plugins: {},
452
+ /**
453
+ * This is the most high-level function in Prism’s API.
454
+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
455
+ * each one of them.
456
+ *
457
+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
458
+ *
459
+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
460
+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
461
+ * @memberof Prism
462
+ * @public
463
+ */
464
+ highlightAll: function(async, callback) {
465
+ _.highlightAllUnder(document, async, callback);
466
+ },
467
+ /**
468
+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
469
+ * {@link Prism.highlightElement} on each one of them.
470
+ *
471
+ * The following hooks will be run:
472
+ * 1. `before-highlightall`
473
+ * 2. `before-all-elements-highlight`
474
+ * 3. All hooks of {@link Prism.highlightElement} for each element.
475
+ *
476
+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
477
+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
478
+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
479
+ * @memberof Prism
480
+ * @public
481
+ */
482
+ highlightAllUnder: function(container, async, callback) {
483
+ var env = {
484
+ callback,
485
+ container,
486
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
487
+ };
488
+ _.hooks.run("before-highlightall", env);
489
+ env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
490
+ _.hooks.run("before-all-elements-highlight", env);
491
+ for (var i = 0, element; element = env.elements[i++]; ) {
492
+ _.highlightElement(element, async === true, env.callback);
493
+ }
494
+ },
495
+ /**
496
+ * Highlights the code inside a single element.
497
+ *
498
+ * The following hooks will be run:
499
+ * 1. `before-sanity-check`
500
+ * 2. `before-highlight`
501
+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
502
+ * 4. `before-insert`
503
+ * 5. `after-highlight`
504
+ * 6. `complete`
505
+ *
506
+ * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
507
+ * the element's language.
508
+ *
509
+ * @param {Element} element The element containing the code.
510
+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
511
+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
512
+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
513
+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
514
+ *
515
+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
516
+ * asynchronous highlighting to work. You can build your own bundle on the
517
+ * [Download page](https://prismjs.com/download.html).
518
+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
519
+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
520
+ * @memberof Prism
521
+ * @public
522
+ */
523
+ highlightElement: function(element, async, callback) {
524
+ var language = _.util.getLanguage(element);
525
+ var grammar = _.languages[language];
526
+ _.util.setLanguage(element, language);
527
+ var parent = element.parentElement;
528
+ if (parent && parent.nodeName.toLowerCase() === "pre") {
529
+ _.util.setLanguage(parent, language);
530
+ }
531
+ var code = element.textContent;
532
+ var env = {
533
+ element,
534
+ language,
535
+ grammar,
536
+ code
537
+ };
538
+ function insertHighlightedCode(highlightedCode) {
539
+ env.highlightedCode = highlightedCode;
540
+ _.hooks.run("before-insert", env);
541
+ env.element.innerHTML = env.highlightedCode;
542
+ _.hooks.run("after-highlight", env);
543
+ _.hooks.run("complete", env);
544
+ callback && callback.call(env.element);
545
+ }
546
+ _.hooks.run("before-sanity-check", env);
547
+ parent = env.element.parentElement;
548
+ if (parent && parent.nodeName.toLowerCase() === "pre" && !parent.hasAttribute("tabindex")) {
549
+ parent.setAttribute("tabindex", "0");
550
+ }
551
+ if (!env.code) {
552
+ _.hooks.run("complete", env);
553
+ callback && callback.call(env.element);
554
+ return;
555
+ }
556
+ _.hooks.run("before-highlight", env);
557
+ if (!env.grammar) {
558
+ insertHighlightedCode(_.util.encode(env.code));
559
+ return;
560
+ }
561
+ if (async && _self2.Worker) {
562
+ var worker = new Worker(_.filename);
563
+ worker.onmessage = function(evt) {
564
+ insertHighlightedCode(evt.data);
565
+ };
566
+ worker.postMessage(JSON.stringify({
567
+ language: env.language,
568
+ code: env.code,
569
+ immediateClose: true
570
+ }));
571
+ } else {
572
+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
573
+ }
574
+ },
575
+ /**
576
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
577
+ * and the language definitions to use, and returns a string with the HTML produced.
578
+ *
579
+ * The following hooks will be run:
580
+ * 1. `before-tokenize`
581
+ * 2. `after-tokenize`
582
+ * 3. `wrap`: On each {@link Token}.
583
+ *
584
+ * @param {string} text A string with the code to be highlighted.
585
+ * @param {Grammar} grammar An object containing the tokens to use.
586
+ *
587
+ * Usually a language definition like `Prism.languages.markup`.
588
+ * @param {string} language The name of the language definition passed to `grammar`.
589
+ * @returns {string} The highlighted HTML.
590
+ * @memberof Prism
591
+ * @public
592
+ * @example
593
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
594
+ */
595
+ highlight: function(text, grammar, language) {
596
+ var env = {
597
+ code: text,
598
+ grammar,
599
+ language
600
+ };
601
+ _.hooks.run("before-tokenize", env);
602
+ if (!env.grammar) {
603
+ throw new Error('The language "' + env.language + '" has no grammar.');
604
+ }
605
+ env.tokens = _.tokenize(env.code, env.grammar);
606
+ _.hooks.run("after-tokenize", env);
607
+ return Token.stringify(_.util.encode(env.tokens), env.language);
608
+ },
609
+ /**
610
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
611
+ * and the language definitions to use, and returns an array with the tokenized code.
612
+ *
613
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
614
+ *
615
+ * This method could be useful in other contexts as well, as a very crude parser.
616
+ *
617
+ * @param {string} text A string with the code to be highlighted.
618
+ * @param {Grammar} grammar An object containing the tokens to use.
619
+ *
620
+ * Usually a language definition like `Prism.languages.markup`.
621
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
622
+ * @memberof Prism
623
+ * @public
624
+ * @example
625
+ * let code = `var foo = 0;`;
626
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
627
+ * tokens.forEach(token => {
628
+ * if (token instanceof Prism.Token && token.type === 'number') {
629
+ * console.log(`Found numeric literal: ${token.content}`);
630
+ * }
631
+ * });
632
+ */
633
+ tokenize: function(text, grammar) {
634
+ var rest = grammar.rest;
635
+ if (rest) {
636
+ for (var token in rest) {
637
+ grammar[token] = rest[token];
638
+ }
639
+ delete grammar.rest;
640
+ }
641
+ var tokenList = new LinkedList();
642
+ addAfter(tokenList, tokenList.head, text);
643
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0);
644
+ return toArray(tokenList);
645
+ },
646
+ /**
647
+ * @namespace
648
+ * @memberof Prism
649
+ * @public
650
+ */
651
+ hooks: {
652
+ all: {},
653
+ /**
654
+ * Adds the given callback to the list of callbacks for the given hook.
655
+ *
656
+ * The callback will be invoked when the hook it is registered for is run.
657
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
658
+ *
659
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
660
+ *
661
+ * @param {string} name The name of the hook.
662
+ * @param {HookCallback} callback The callback function which is given environment variables.
663
+ * @public
664
+ */
665
+ add: function(name, callback) {
666
+ var hooks = _.hooks.all;
667
+ hooks[name] = hooks[name] || [];
668
+ hooks[name].push(callback);
669
+ },
670
+ /**
671
+ * Runs a hook invoking all registered callbacks with the given environment variables.
672
+ *
673
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
674
+ *
675
+ * @param {string} name The name of the hook.
676
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
677
+ * @public
678
+ */
679
+ run: function(name, env) {
680
+ var callbacks = _.hooks.all[name];
681
+ if (!callbacks || !callbacks.length) {
682
+ return;
683
+ }
684
+ for (var i = 0, callback; callback = callbacks[i++]; ) {
685
+ callback(env);
686
+ }
687
+ }
688
+ },
689
+ Token
690
+ };
691
+ _self2.Prism = _;
692
+ function Token(type, content, alias, matchedStr) {
693
+ this.type = type;
694
+ this.content = content;
695
+ this.alias = alias;
696
+ this.length = (matchedStr || "").length | 0;
697
+ }
698
+ Token.stringify = function stringify(o, language) {
699
+ if (typeof o == "string") {
700
+ return o;
701
+ }
702
+ if (Array.isArray(o)) {
703
+ var s = "";
704
+ o.forEach(function(e) {
705
+ s += stringify(e, language);
706
+ });
707
+ return s;
708
+ }
709
+ var env = {
710
+ type: o.type,
711
+ content: stringify(o.content, language),
712
+ tag: "span",
713
+ classes: ["token", o.type],
714
+ attributes: {},
715
+ language
716
+ };
717
+ var aliases = o.alias;
718
+ if (aliases) {
719
+ if (Array.isArray(aliases)) {
720
+ Array.prototype.push.apply(env.classes, aliases);
721
+ } else {
722
+ env.classes.push(aliases);
723
+ }
724
+ }
725
+ _.hooks.run("wrap", env);
726
+ var attributes = "";
727
+ for (var name in env.attributes) {
728
+ attributes += " " + name + '="' + (env.attributes[name] || "").replace(/"/g, "&quot;") + '"';
729
+ }
730
+ return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + attributes + ">" + env.content + "</" + env.tag + ">";
731
+ };
732
+ function matchPattern(pattern, pos, text, lookbehind) {
733
+ pattern.lastIndex = pos;
734
+ var match = pattern.exec(text);
735
+ if (match && lookbehind && match[1]) {
736
+ var lookbehindLength = match[1].length;
737
+ match.index += lookbehindLength;
738
+ match[0] = match[0].slice(lookbehindLength);
739
+ }
740
+ return match;
741
+ }
742
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
743
+ for (var token in grammar) {
744
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
745
+ continue;
746
+ }
747
+ var patterns = grammar[token];
748
+ patterns = Array.isArray(patterns) ? patterns : [patterns];
749
+ for (var j = 0; j < patterns.length; ++j) {
750
+ if (rematch && rematch.cause == token + "," + j) {
751
+ return;
752
+ }
753
+ var patternObj = patterns[j];
754
+ var inside = patternObj.inside;
755
+ var lookbehind = !!patternObj.lookbehind;
756
+ var greedy = !!patternObj.greedy;
757
+ var alias = patternObj.alias;
758
+ if (greedy && !patternObj.pattern.global) {
759
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
760
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
761
+ }
762
+ var pattern = patternObj.pattern || patternObj;
763
+ for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
764
+ if (rematch && pos >= rematch.reach) {
765
+ break;
766
+ }
767
+ var str = currentNode.value;
768
+ if (tokenList.length > text.length) {
769
+ return;
770
+ }
771
+ if (str instanceof Token) {
772
+ continue;
773
+ }
774
+ var removeCount = 1;
775
+ var match;
776
+ if (greedy) {
777
+ match = matchPattern(pattern, pos, text, lookbehind);
778
+ if (!match || match.index >= text.length) {
779
+ break;
780
+ }
781
+ var from = match.index;
782
+ var to = match.index + match[0].length;
783
+ var p = pos;
784
+ p += currentNode.value.length;
785
+ while (from >= p) {
786
+ currentNode = currentNode.next;
787
+ p += currentNode.value.length;
788
+ }
789
+ p -= currentNode.value.length;
790
+ pos = p;
791
+ if (currentNode.value instanceof Token) {
792
+ continue;
793
+ }
794
+ for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
795
+ removeCount++;
796
+ p += k.value.length;
797
+ }
798
+ removeCount--;
799
+ str = text.slice(pos, p);
800
+ match.index -= pos;
801
+ } else {
802
+ match = matchPattern(pattern, 0, str, lookbehind);
803
+ if (!match) {
804
+ continue;
805
+ }
806
+ }
807
+ var from = match.index;
808
+ var matchStr = match[0];
809
+ var before = str.slice(0, from);
810
+ var after = str.slice(from + matchStr.length);
811
+ var reach = pos + str.length;
812
+ if (rematch && reach > rematch.reach) {
813
+ rematch.reach = reach;
814
+ }
815
+ var removeFrom = currentNode.prev;
816
+ if (before) {
817
+ removeFrom = addAfter(tokenList, removeFrom, before);
818
+ pos += before.length;
819
+ }
820
+ removeRange(tokenList, removeFrom, removeCount);
821
+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
822
+ currentNode = addAfter(tokenList, removeFrom, wrapped);
823
+ if (after) {
824
+ addAfter(tokenList, currentNode, after);
825
+ }
826
+ if (removeCount > 1) {
827
+ var nestedRematch = {
828
+ cause: token + "," + j,
829
+ reach
830
+ };
831
+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
832
+ if (rematch && nestedRematch.reach > rematch.reach) {
833
+ rematch.reach = nestedRematch.reach;
834
+ }
835
+ }
836
+ }
837
+ }
838
+ }
839
+ }
840
+ function LinkedList() {
841
+ var head = { value: null, prev: null, next: null };
842
+ var tail = { value: null, prev: head, next: null };
843
+ head.next = tail;
844
+ this.head = head;
845
+ this.tail = tail;
846
+ this.length = 0;
847
+ }
848
+ function addAfter(list, node, value) {
849
+ var next = node.next;
850
+ var newNode = { value, prev: node, next };
851
+ node.next = newNode;
852
+ next.prev = newNode;
853
+ list.length++;
854
+ return newNode;
855
+ }
856
+ function removeRange(list, node, count) {
857
+ var next = node.next;
858
+ for (var i = 0; i < count && next !== list.tail; i++) {
859
+ next = next.next;
860
+ }
861
+ node.next = next;
862
+ next.prev = node;
863
+ list.length -= i;
864
+ }
865
+ function toArray(list) {
866
+ var array = [];
867
+ var node = list.head.next;
868
+ while (node !== list.tail) {
869
+ array.push(node.value);
870
+ node = node.next;
871
+ }
872
+ return array;
873
+ }
874
+ if (!_self2.document) {
875
+ if (!_self2.addEventListener) {
876
+ return _;
877
+ }
878
+ if (!_.disableWorkerMessageHandler) {
879
+ _self2.addEventListener("message", function(evt) {
880
+ var message = JSON.parse(evt.data);
881
+ var lang2 = message.language;
882
+ var code = message.code;
883
+ var immediateClose = message.immediateClose;
884
+ _self2.postMessage(_.highlight(code, _.languages[lang2], lang2));
885
+ if (immediateClose) {
886
+ _self2.close();
887
+ }
888
+ }, false);
889
+ }
890
+ return _;
891
+ }
892
+ var script = _.util.currentScript();
893
+ if (script) {
894
+ _.filename = script.src;
895
+ if (script.hasAttribute("data-manual")) {
896
+ _.manual = true;
897
+ }
898
+ }
899
+ function highlightAutomaticallyCallback() {
900
+ if (!_.manual) {
901
+ _.highlightAll();
902
+ }
903
+ }
904
+ if (!_.manual) {
905
+ var readyState = document.readyState;
906
+ if (readyState === "loading" || readyState === "interactive" && script && script.defer) {
907
+ document.addEventListener("DOMContentLoaded", highlightAutomaticallyCallback);
908
+ } else {
909
+ if (window.requestAnimationFrame) {
910
+ window.requestAnimationFrame(highlightAutomaticallyCallback);
911
+ } else {
912
+ window.setTimeout(highlightAutomaticallyCallback, 16);
913
+ }
914
+ }
915
+ }
916
+ return _;
917
+ })(_self);
918
+ if (typeof module !== "undefined" && module.exports) {
919
+ module.exports = Prism;
920
+ }
921
+ if (typeof global !== "undefined") {
922
+ global.Prism = Prism;
923
+ }
924
+ Prism.languages.markup = {
925
+ "comment": {
926
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
927
+ greedy: true
928
+ },
929
+ "prolog": {
930
+ pattern: /<\?[\s\S]+?\?>/,
931
+ greedy: true
932
+ },
933
+ "doctype": {
934
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
935
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
936
+ greedy: true,
937
+ inside: {
938
+ "internal-subset": {
939
+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
940
+ lookbehind: true,
941
+ greedy: true,
942
+ inside: null
943
+ // see below
944
+ },
945
+ "string": {
946
+ pattern: /"[^"]*"|'[^']*'/,
947
+ greedy: true
948
+ },
949
+ "punctuation": /^<!|>$|[[\]]/,
950
+ "doctype-tag": /^DOCTYPE/i,
951
+ "name": /[^\s<>'"]+/
952
+ }
953
+ },
954
+ "cdata": {
955
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
956
+ greedy: true
957
+ },
958
+ "tag": {
959
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
960
+ greedy: true,
961
+ inside: {
962
+ "tag": {
963
+ pattern: /^<\/?[^\s>\/]+/,
964
+ inside: {
965
+ "punctuation": /^<\/?/,
966
+ "namespace": /^[^\s>\/:]+:/
967
+ }
968
+ },
969
+ "special-attr": [],
970
+ "attr-value": {
971
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
972
+ inside: {
973
+ "punctuation": [
974
+ {
975
+ pattern: /^=/,
976
+ alias: "attr-equals"
977
+ },
978
+ {
979
+ pattern: /^(\s*)["']|["']$/,
980
+ lookbehind: true
981
+ }
982
+ ]
983
+ }
984
+ },
985
+ "punctuation": /\/?>/,
986
+ "attr-name": {
987
+ pattern: /[^\s>\/]+/,
988
+ inside: {
989
+ "namespace": /^[^\s>\/:]+:/
990
+ }
991
+ }
992
+ }
993
+ },
994
+ "entity": [
995
+ {
996
+ pattern: /&[\da-z]{1,8};/i,
997
+ alias: "named-entity"
998
+ },
999
+ /&#x?[\da-f]{1,8};/i
1000
+ ]
1001
+ };
1002
+ Prism.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism.languages.markup["entity"];
1003
+ Prism.languages.markup["doctype"].inside["internal-subset"].inside = Prism.languages.markup;
1004
+ Prism.hooks.add("wrap", function(env) {
1005
+ if (env.type === "entity") {
1006
+ env.attributes["title"] = env.content.replace(/&amp;/, "&");
1007
+ }
1008
+ });
1009
+ Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
1010
+ /**
1011
+ * Adds an inlined language to markup.
1012
+ *
1013
+ * An example of an inlined language is CSS with `<style>` tags.
1014
+ *
1015
+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1016
+ * case insensitive.
1017
+ * @param {string} lang The language key.
1018
+ * @example
1019
+ * addInlined('style', 'css');
1020
+ */
1021
+ value: function addInlined(tagName, lang) {
1022
+ var includedCdataInside = {};
1023
+ includedCdataInside["language-" + lang] = {
1024
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1025
+ lookbehind: true,
1026
+ inside: Prism.languages[lang]
1027
+ };
1028
+ includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
1029
+ var inside = {
1030
+ "included-cdata": {
1031
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1032
+ inside: includedCdataInside
1033
+ }
1034
+ };
1035
+ inside["language-" + lang] = {
1036
+ pattern: /[\s\S]+/,
1037
+ inside: Prism.languages[lang]
1038
+ };
1039
+ var def = {};
1040
+ def[tagName] = {
1041
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
1042
+ return tagName;
1043
+ }), "i"),
1044
+ lookbehind: true,
1045
+ greedy: true,
1046
+ inside
1047
+ };
1048
+ Prism.languages.insertBefore("markup", "cdata", def);
1049
+ }
1050
+ });
1051
+ Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
1052
+ /**
1053
+ * Adds an pattern to highlight languages embedded in HTML attributes.
1054
+ *
1055
+ * An example of an inlined language is CSS with `style` attributes.
1056
+ *
1057
+ * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1058
+ * case insensitive.
1059
+ * @param {string} lang The language key.
1060
+ * @example
1061
+ * addAttribute('style', 'css');
1062
+ */
1063
+ value: function(attrName, lang) {
1064
+ Prism.languages.markup.tag.inside["special-attr"].push({
1065
+ pattern: RegExp(
1066
+ /(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1067
+ "i"
1068
+ ),
1069
+ lookbehind: true,
1070
+ inside: {
1071
+ "attr-name": /^[^\s=]+/,
1072
+ "attr-value": {
1073
+ pattern: /=[\s\S]+/,
1074
+ inside: {
1075
+ "value": {
1076
+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1077
+ lookbehind: true,
1078
+ alias: [lang, "language-" + lang],
1079
+ inside: Prism.languages[lang]
1080
+ },
1081
+ "punctuation": [
1082
+ {
1083
+ pattern: /^=/,
1084
+ alias: "attr-equals"
1085
+ },
1086
+ /"|'/
1087
+ ]
1088
+ }
1089
+ }
1090
+ }
1091
+ });
1092
+ }
1093
+ });
1094
+ Prism.languages.html = Prism.languages.markup;
1095
+ Prism.languages.mathml = Prism.languages.markup;
1096
+ Prism.languages.svg = Prism.languages.markup;
1097
+ Prism.languages.xml = Prism.languages.extend("markup", {});
1098
+ Prism.languages.ssml = Prism.languages.xml;
1099
+ Prism.languages.atom = Prism.languages.xml;
1100
+ Prism.languages.rss = Prism.languages.xml;
1101
+ (function(Prism2) {
1102
+ var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1103
+ Prism2.languages.css = {
1104
+ "comment": /\/\*[\s\S]*?\*\//,
1105
+ "atrule": {
1106
+ pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + string.source + ")*?" + /(?:;|(?=\s*\{))/.source),
1107
+ inside: {
1108
+ "rule": /^@[\w-]+/,
1109
+ "selector-function-argument": {
1110
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1111
+ lookbehind: true,
1112
+ alias: "selector"
1113
+ },
1114
+ "keyword": {
1115
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1116
+ lookbehind: true
1117
+ }
1118
+ // See rest below
1119
+ }
1120
+ },
1121
+ "url": {
1122
+ // https://drafts.csswg.org/css-values-3/#urls
1123
+ pattern: RegExp("\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
1124
+ greedy: true,
1125
+ inside: {
1126
+ "function": /^url/i,
1127
+ "punctuation": /^\(|\)$/,
1128
+ "string": {
1129
+ pattern: RegExp("^" + string.source + "$"),
1130
+ alias: "url"
1131
+ }
1132
+ }
1133
+ },
1134
+ "selector": {
1135
+ pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"),
1136
+ lookbehind: true
1137
+ },
1138
+ "string": {
1139
+ pattern: string,
1140
+ greedy: true
1141
+ },
1142
+ "property": {
1143
+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1144
+ lookbehind: true
1145
+ },
1146
+ "important": /!important\b/i,
1147
+ "function": {
1148
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1149
+ lookbehind: true
1150
+ },
1151
+ "punctuation": /[(){};:,]/
1152
+ };
1153
+ Prism2.languages.css["atrule"].inside.rest = Prism2.languages.css;
1154
+ var markup = Prism2.languages.markup;
1155
+ if (markup) {
1156
+ markup.tag.addInlined("style", "css");
1157
+ markup.tag.addAttribute("style", "css");
1158
+ }
1159
+ })(Prism);
1160
+ Prism.languages.clike = {
1161
+ "comment": [
1162
+ {
1163
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1164
+ lookbehind: true,
1165
+ greedy: true
1166
+ },
1167
+ {
1168
+ pattern: /(^|[^\\:])\/\/.*/,
1169
+ lookbehind: true,
1170
+ greedy: true
1171
+ }
1172
+ ],
1173
+ "string": {
1174
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1175
+ greedy: true
1176
+ },
1177
+ "class-name": {
1178
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1179
+ lookbehind: true,
1180
+ inside: {
1181
+ "punctuation": /[.\\]/
1182
+ }
1183
+ },
1184
+ "keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1185
+ "boolean": /\b(?:false|true)\b/,
1186
+ "function": /\b\w+(?=\()/,
1187
+ "number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1188
+ "operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1189
+ "punctuation": /[{}[\];(),.:]/
1190
+ };
1191
+ Prism.languages.javascript = Prism.languages.extend("clike", {
1192
+ "class-name": [
1193
+ Prism.languages.clike["class-name"],
1194
+ {
1195
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1196
+ lookbehind: true
1197
+ }
1198
+ ],
1199
+ "keyword": [
1200
+ {
1201
+ pattern: /((?:^|\})\s*)catch\b/,
1202
+ lookbehind: true
1203
+ },
1204
+ {
1205
+ 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/,
1206
+ lookbehind: true
1207
+ }
1208
+ ],
1209
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1210
+ "function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1211
+ "number": {
1212
+ pattern: RegExp(
1213
+ /(^|[^\w$])/.source + "(?:" + // constant
1214
+ (/NaN|Infinity/.source + "|" + // binary integer
1215
+ /0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
1216
+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
1217
+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
1218
+ /\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
1219
+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
1220
+ ),
1221
+ lookbehind: true
1222
+ },
1223
+ "operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1224
+ });
1225
+ Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1226
+ Prism.languages.insertBefore("javascript", "keyword", {
1227
+ "regex": {
1228
+ pattern: RegExp(
1229
+ // lookbehind
1230
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
1231
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
1232
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1233
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1234
+ // with the only syntax, so we have to define 2 different regex patterns.
1235
+ /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
1236
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
1237
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
1238
+ ),
1239
+ lookbehind: true,
1240
+ greedy: true,
1241
+ inside: {
1242
+ "regex-source": {
1243
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1244
+ lookbehind: true,
1245
+ alias: "language-regex",
1246
+ inside: Prism.languages.regex
1247
+ },
1248
+ "regex-delimiter": /^\/|\/$/,
1249
+ "regex-flags": /^[a-z]+$/
1250
+ }
1251
+ },
1252
+ // This must be declared before keyword because we use "function" inside the look-forward
1253
+ "function-variable": {
1254
+ 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*=>))/,
1255
+ alias: "function"
1256
+ },
1257
+ "parameter": [
1258
+ {
1259
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1260
+ lookbehind: true,
1261
+ inside: Prism.languages.javascript
1262
+ },
1263
+ {
1264
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1265
+ lookbehind: true,
1266
+ inside: Prism.languages.javascript
1267
+ },
1268
+ {
1269
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1270
+ lookbehind: true,
1271
+ inside: Prism.languages.javascript
1272
+ },
1273
+ {
1274
+ 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*\{)/,
1275
+ lookbehind: true,
1276
+ inside: Prism.languages.javascript
1277
+ }
1278
+ ],
1279
+ "constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1280
+ });
1281
+ Prism.languages.insertBefore("javascript", "string", {
1282
+ "hashbang": {
1283
+ pattern: /^#!.*/,
1284
+ greedy: true,
1285
+ alias: "comment"
1286
+ },
1287
+ "template-string": {
1288
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1289
+ greedy: true,
1290
+ inside: {
1291
+ "template-punctuation": {
1292
+ pattern: /^`|`$/,
1293
+ alias: "string"
1294
+ },
1295
+ "interpolation": {
1296
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1297
+ lookbehind: true,
1298
+ inside: {
1299
+ "interpolation-punctuation": {
1300
+ pattern: /^\$\{|\}$/,
1301
+ alias: "punctuation"
1302
+ },
1303
+ rest: Prism.languages.javascript
1304
+ }
1305
+ },
1306
+ "string": /[\s\S]+/
1307
+ }
1308
+ },
1309
+ "string-property": {
1310
+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1311
+ lookbehind: true,
1312
+ greedy: true,
1313
+ alias: "property"
1314
+ }
1315
+ });
1316
+ Prism.languages.insertBefore("javascript", "operator", {
1317
+ "literal-property": {
1318
+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1319
+ lookbehind: true,
1320
+ alias: "property"
1321
+ }
1322
+ });
1323
+ if (Prism.languages.markup) {
1324
+ Prism.languages.markup.tag.addInlined("script", "javascript");
1325
+ Prism.languages.markup.tag.addAttribute(
1326
+ /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,
1327
+ "javascript"
1328
+ );
1329
+ }
1330
+ Prism.languages.js = Prism.languages.javascript;
1331
+ (function(Prism2) {
1332
+ 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";
1333
+ var commandAfterHeredoc = {
1334
+ pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
1335
+ lookbehind: true,
1336
+ alias: "punctuation",
1337
+ // this looks reasonably well in all themes
1338
+ inside: null
1339
+ // see below
1340
+ };
1341
+ var insideString = {
1342
+ "bash": commandAfterHeredoc,
1343
+ "environment": {
1344
+ pattern: RegExp("\\$" + envVars),
1345
+ alias: "constant"
1346
+ },
1347
+ "variable": [
1348
+ // [0]: Arithmetic Environment
1349
+ {
1350
+ pattern: /\$?\(\([\s\S]+?\)\)/,
1351
+ greedy: true,
1352
+ inside: {
1353
+ // If there is a $ sign at the beginning highlight $(( and )) as variable
1354
+ "variable": [
1355
+ {
1356
+ pattern: /(^\$\(\([\s\S]+)\)\)/,
1357
+ lookbehind: true
1358
+ },
1359
+ /^\$\(\(/
1360
+ ],
1361
+ "number": /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
1362
+ // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
1363
+ "operator": /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
1364
+ // If there is no $ sign at the beginning highlight (( and )) as punctuation
1365
+ "punctuation": /\(\(?|\)\)?|,|;/
1366
+ }
1367
+ },
1368
+ // [1]: Command Substitution
1369
+ {
1370
+ pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
1371
+ greedy: true,
1372
+ inside: {
1373
+ "variable": /^\$\(|^`|\)$|`$/
1374
+ }
1375
+ },
1376
+ // [2]: Brace expansion
1377
+ {
1378
+ pattern: /\$\{[^}]+\}/,
1379
+ greedy: true,
1380
+ inside: {
1381
+ "operator": /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
1382
+ "punctuation": /[\[\]]/,
1383
+ "environment": {
1384
+ pattern: RegExp("(\\{)" + envVars),
1385
+ lookbehind: true,
1386
+ alias: "constant"
1387
+ }
1388
+ }
1389
+ },
1390
+ /\$(?:\w+|[#?*!@$])/
1391
+ ],
1392
+ // Escape sequences from echo and printf's manuals, and escaped quotes.
1393
+ "entity": /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
1394
+ };
1395
+ Prism2.languages.bash = {
1396
+ "shebang": {
1397
+ pattern: /^#!\s*\/.*/,
1398
+ alias: "important"
1399
+ },
1400
+ "comment": {
1401
+ pattern: /(^|[^"{\\$])#.*/,
1402
+ lookbehind: true
1403
+ },
1404
+ "function-name": [
1405
+ // a) function foo {
1406
+ // b) foo() {
1407
+ // c) function foo() {
1408
+ // but not “foo {”
1409
+ {
1410
+ // a) and c)
1411
+ pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
1412
+ lookbehind: true,
1413
+ alias: "function"
1414
+ },
1415
+ {
1416
+ // b)
1417
+ pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
1418
+ alias: "function"
1419
+ }
1420
+ ],
1421
+ // Highlight variable names as variables in for and select beginnings.
1422
+ "for-or-select": {
1423
+ pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
1424
+ alias: "variable",
1425
+ lookbehind: true
1426
+ },
1427
+ // Highlight variable names as variables in the left-hand part
1428
+ // of assignments (“=” and “+=”).
1429
+ "assign-left": {
1430
+ pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
1431
+ inside: {
1432
+ "environment": {
1433
+ pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
1434
+ lookbehind: true,
1435
+ alias: "constant"
1436
+ }
1437
+ },
1438
+ alias: "variable",
1439
+ lookbehind: true
1440
+ },
1441
+ // Highlight parameter names as variables
1442
+ "parameter": {
1443
+ pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
1444
+ alias: "variable",
1445
+ lookbehind: true
1446
+ },
1447
+ "string": [
1448
+ // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
1449
+ {
1450
+ pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
1451
+ lookbehind: true,
1452
+ greedy: true,
1453
+ inside: insideString
1454
+ },
1455
+ // Here-document with quotes around the tag
1456
+ // → No expansion (so no “inside”).
1457
+ {
1458
+ pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
1459
+ lookbehind: true,
1460
+ greedy: true,
1461
+ inside: {
1462
+ "bash": commandAfterHeredoc
1463
+ }
1464
+ },
1465
+ // “Normal” string
1466
+ {
1467
+ // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
1468
+ pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
1469
+ lookbehind: true,
1470
+ greedy: true,
1471
+ inside: insideString
1472
+ },
1473
+ {
1474
+ // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
1475
+ pattern: /(^|[^$\\])'[^']*'/,
1476
+ lookbehind: true,
1477
+ greedy: true
1478
+ },
1479
+ {
1480
+ // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
1481
+ pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
1482
+ greedy: true,
1483
+ inside: {
1484
+ "entity": insideString.entity
1485
+ }
1486
+ }
1487
+ ],
1488
+ "environment": {
1489
+ pattern: RegExp("\\$?" + envVars),
1490
+ alias: "constant"
1491
+ },
1492
+ "variable": insideString.variable,
1493
+ "function": {
1494
+ pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1495
+ lookbehind: true
1496
+ },
1497
+ "keyword": {
1498
+ pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
1499
+ lookbehind: true
1500
+ },
1501
+ // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
1502
+ "builtin": {
1503
+ pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
1504
+ lookbehind: true,
1505
+ // Alias added to make those easier to distinguish from strings.
1506
+ alias: "class-name"
1507
+ },
1508
+ "boolean": {
1509
+ pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
1510
+ lookbehind: true
1511
+ },
1512
+ "file-descriptor": {
1513
+ pattern: /\B&\d\b/,
1514
+ alias: "important"
1515
+ },
1516
+ "operator": {
1517
+ // Lots of redirections here, but not just that.
1518
+ pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
1519
+ inside: {
1520
+ "file-descriptor": {
1521
+ pattern: /^\d/,
1522
+ alias: "important"
1523
+ }
1524
+ }
1525
+ },
1526
+ "punctuation": /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
1527
+ "number": {
1528
+ pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
1529
+ lookbehind: true
1530
+ }
1531
+ };
1532
+ commandAfterHeredoc.inside = Prism2.languages.bash;
1533
+ var toBeCopied = [
1534
+ "comment",
1535
+ "function-name",
1536
+ "for-or-select",
1537
+ "assign-left",
1538
+ "parameter",
1539
+ "string",
1540
+ "environment",
1541
+ "function",
1542
+ "keyword",
1543
+ "builtin",
1544
+ "boolean",
1545
+ "file-descriptor",
1546
+ "operator",
1547
+ "punctuation",
1548
+ "number"
1549
+ ];
1550
+ var inside = insideString.variable[1].inside;
1551
+ for (var i = 0; i < toBeCopied.length; i++) {
1552
+ inside[toBeCopied[i]] = Prism2.languages.bash[toBeCopied[i]];
1553
+ }
1554
+ Prism2.languages.sh = Prism2.languages.bash;
1555
+ Prism2.languages.shell = Prism2.languages.bash;
1556
+ })(Prism);
1557
+ (function(Prism2) {
1558
+ function replace(pattern, replacements) {
1559
+ return pattern.replace(/<<(\d+)>>/g, function(m, index) {
1560
+ return "(?:" + replacements[+index] + ")";
1561
+ });
1562
+ }
1563
+ function re(pattern, replacements, flags) {
1564
+ return RegExp(replace(pattern, replacements), flags || "");
1565
+ }
1566
+ function nested(pattern, depthLog2) {
1567
+ for (var i = 0; i < depthLog2; i++) {
1568
+ pattern = pattern.replace(/<<self>>/g, function() {
1569
+ return "(?:" + pattern + ")";
1570
+ });
1571
+ }
1572
+ return pattern.replace(/<<self>>/g, "[^\\s\\S]");
1573
+ }
1574
+ var keywordKinds = {
1575
+ // keywords which represent a return or variable type
1576
+ type: "bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void",
1577
+ // keywords which are used to declare a type
1578
+ typeDeclaration: "class enum interface record struct",
1579
+ // contextual keywords
1580
+ // ("var" and "dynamic" are missing because they are used like types)
1581
+ contextual: "add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)",
1582
+ // all other keywords
1583
+ other: "abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield"
1584
+ };
1585
+ function keywordsToPattern(words) {
1586
+ return "\\b(?:" + words.trim().replace(/ /g, "|") + ")\\b";
1587
+ }
1588
+ var typeDeclarationKeywords = keywordsToPattern(keywordKinds.typeDeclaration);
1589
+ var keywords = RegExp(keywordsToPattern(keywordKinds.type + " " + keywordKinds.typeDeclaration + " " + keywordKinds.contextual + " " + keywordKinds.other));
1590
+ var nonTypeKeywords = keywordsToPattern(keywordKinds.typeDeclaration + " " + keywordKinds.contextual + " " + keywordKinds.other);
1591
+ var nonContextualKeywords = keywordsToPattern(keywordKinds.type + " " + keywordKinds.typeDeclaration + " " + keywordKinds.other);
1592
+ var generic = nested(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source, 2);
1593
+ var nestedRound = nested(/\((?:[^()]|<<self>>)*\)/.source, 2);
1594
+ var name = /@?\b[A-Za-z_]\w*\b/.source;
1595
+ var genericName = replace(/<<0>>(?:\s*<<1>>)?/.source, [name, generic]);
1596
+ var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [nonTypeKeywords, genericName]);
1597
+ var array = /\[\s*(?:,\s*)*\]/.source;
1598
+ var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [identifier, array]);
1599
+ var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [generic, nestedRound, array]);
1600
+ var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
1601
+ var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [tuple, identifier, array]);
1602
+ var typeInside = {
1603
+ "keyword": keywords,
1604
+ "punctuation": /[<>()?,.:[\]]/
1605
+ };
1606
+ var character = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source;
1607
+ var regularString = /"(?:\\.|[^\\"\r\n])*"/.source;
1608
+ var verbatimString = /@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;
1609
+ Prism2.languages.csharp = Prism2.languages.extend("clike", {
1610
+ "string": [
1611
+ {
1612
+ pattern: re(/(^|[^$\\])<<0>>/.source, [verbatimString]),
1613
+ lookbehind: true,
1614
+ greedy: true
1615
+ },
1616
+ {
1617
+ pattern: re(/(^|[^@$\\])<<0>>/.source, [regularString]),
1618
+ lookbehind: true,
1619
+ greedy: true
1620
+ }
1621
+ ],
1622
+ "class-name": [
1623
+ {
1624
+ // Using static
1625
+ // using static System.Math;
1626
+ pattern: re(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [identifier]),
1627
+ lookbehind: true,
1628
+ inside: typeInside
1629
+ },
1630
+ {
1631
+ // Using alias (type)
1632
+ // using Project = PC.MyCompany.Project;
1633
+ pattern: re(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [name, typeExpression]),
1634
+ lookbehind: true,
1635
+ inside: typeInside
1636
+ },
1637
+ {
1638
+ // Using alias (alias)
1639
+ // using Project = PC.MyCompany.Project;
1640
+ pattern: re(/(\busing\s+)<<0>>(?=\s*=)/.source, [name]),
1641
+ lookbehind: true
1642
+ },
1643
+ {
1644
+ // Type declarations
1645
+ // class Foo<A, B>
1646
+ // interface Foo<out A, B>
1647
+ pattern: re(/(\b<<0>>\s+)<<1>>/.source, [typeDeclarationKeywords, genericName]),
1648
+ lookbehind: true,
1649
+ inside: typeInside
1650
+ },
1651
+ {
1652
+ // Single catch exception declaration
1653
+ // catch(Foo)
1654
+ // (things like catch(Foo e) is covered by variable declaration)
1655
+ pattern: re(/(\bcatch\s*\(\s*)<<0>>/.source, [identifier]),
1656
+ lookbehind: true,
1657
+ inside: typeInside
1658
+ },
1659
+ {
1660
+ // Name of the type parameter of generic constraints
1661
+ // where Foo : class
1662
+ pattern: re(/(\bwhere\s+)<<0>>/.source, [name]),
1663
+ lookbehind: true
1664
+ },
1665
+ {
1666
+ // Casts and checks via as and is.
1667
+ // as Foo<A>, is Bar<B>
1668
+ // (things like if(a is Foo b) is covered by variable declaration)
1669
+ pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [typeExpressionWithoutTuple]),
1670
+ lookbehind: true,
1671
+ inside: typeInside
1672
+ },
1673
+ {
1674
+ // Variable, field and parameter declaration
1675
+ // (Foo bar, Bar baz, Foo[,,] bay, Foo<Bar, FooBar<Bar>> bax)
1676
+ pattern: re(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [typeExpression, nonContextualKeywords, name]),
1677
+ inside: typeInside
1678
+ }
1679
+ ],
1680
+ "keyword": keywords,
1681
+ // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#literals
1682
+ "number": /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,
1683
+ "operator": />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
1684
+ "punctuation": /\?\.?|::|[{}[\];(),.:]/
1685
+ });
1686
+ Prism2.languages.insertBefore("csharp", "number", {
1687
+ "range": {
1688
+ pattern: /\.\./,
1689
+ alias: "operator"
1690
+ }
1691
+ });
1692
+ Prism2.languages.insertBefore("csharp", "punctuation", {
1693
+ "named-parameter": {
1694
+ pattern: re(/([(,]\s*)<<0>>(?=\s*:)/.source, [name]),
1695
+ lookbehind: true,
1696
+ alias: "punctuation"
1697
+ }
1698
+ });
1699
+ Prism2.languages.insertBefore("csharp", "class-name", {
1700
+ "namespace": {
1701
+ // namespace Foo.Bar {}
1702
+ // using Foo.Bar;
1703
+ pattern: re(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source, [name]),
1704
+ lookbehind: true,
1705
+ inside: {
1706
+ "punctuation": /\./
1707
+ }
1708
+ },
1709
+ "type-expression": {
1710
+ // default(Foo), typeof(Foo<Bar>), sizeof(int)
1711
+ pattern: re(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source, [nestedRound]),
1712
+ lookbehind: true,
1713
+ alias: "class-name",
1714
+ inside: typeInside
1715
+ },
1716
+ "return-type": {
1717
+ // Foo<Bar> ForBar(); Foo IFoo.Bar() => 0
1718
+ // int this[int index] => 0; T IReadOnlyList<T>.this[int index] => this[index];
1719
+ // int Foo => 0; int Foo { get; set } = 0;
1720
+ pattern: re(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source, [typeExpression, identifier]),
1721
+ inside: typeInside,
1722
+ alias: "class-name"
1723
+ },
1724
+ "constructor-invocation": {
1725
+ // new List<Foo<Bar[]>> { }
1726
+ pattern: re(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [typeExpression]),
1727
+ lookbehind: true,
1728
+ inside: typeInside,
1729
+ alias: "class-name"
1730
+ },
1731
+ /*'explicit-implementation': {
1732
+ // int IFoo<Foo>.Bar => 0; void IFoo<Foo<Foo>>.Foo<T>();
1733
+ pattern: replace(/\b<<0>>(?=\.<<1>>)/, className, methodOrPropertyDeclaration),
1734
+ inside: classNameInside,
1735
+ alias: 'class-name'
1736
+ },*/
1737
+ "generic-method": {
1738
+ // foo<Bar>()
1739
+ pattern: re(/<<0>>\s*<<1>>(?=\s*\()/.source, [name, generic]),
1740
+ inside: {
1741
+ "function": re(/^<<0>>/.source, [name]),
1742
+ "generic": {
1743
+ pattern: RegExp(generic),
1744
+ alias: "class-name",
1745
+ inside: typeInside
1746
+ }
1747
+ }
1748
+ },
1749
+ "type-list": {
1750
+ // The list of types inherited or of generic constraints
1751
+ // class Foo<F> : Bar, IList<FooBar>
1752
+ // where F : Bar, IList<int>
1753
+ pattern: re(
1754
+ /\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source,
1755
+ [typeDeclarationKeywords, genericName, name, typeExpression, keywords.source, nestedRound, /\bnew\s*\(\s*\)/.source]
1756
+ ),
1757
+ lookbehind: true,
1758
+ inside: {
1759
+ "record-arguments": {
1760
+ pattern: re(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source, [genericName, nestedRound]),
1761
+ lookbehind: true,
1762
+ greedy: true,
1763
+ inside: Prism2.languages.csharp
1764
+ },
1765
+ "keyword": keywords,
1766
+ "class-name": {
1767
+ pattern: RegExp(typeExpression),
1768
+ greedy: true,
1769
+ inside: typeInside
1770
+ },
1771
+ "punctuation": /[,()]/
1772
+ }
1773
+ },
1774
+ "preprocessor": {
1775
+ pattern: /(^[\t ]*)#.*/m,
1776
+ lookbehind: true,
1777
+ alias: "property",
1778
+ inside: {
1779
+ // highlight preprocessor directives as keywords
1780
+ "directive": {
1781
+ pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
1782
+ lookbehind: true,
1783
+ alias: "keyword"
1784
+ }
1785
+ }
1786
+ }
1787
+ });
1788
+ var regularStringOrCharacter = regularString + "|" + character;
1789
+ var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [regularStringOrCharacter]);
1790
+ var roundExpression = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
1791
+ var attrTarget = /\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source;
1792
+ var attr = replace(/<<0>>(?:\s*\(<<1>>*\))?/.source, [identifier, roundExpression]);
1793
+ Prism2.languages.insertBefore("csharp", "class-name", {
1794
+ "attribute": {
1795
+ // Attributes
1796
+ // [Foo], [Foo(1), Bar(2, Prop = "foo")], [return: Foo(1), Bar(2)], [assembly: Foo(Bar)]
1797
+ pattern: re(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source, [attrTarget, attr]),
1798
+ lookbehind: true,
1799
+ greedy: true,
1800
+ inside: {
1801
+ "target": {
1802
+ pattern: re(/^<<0>>(?=\s*:)/.source, [attrTarget]),
1803
+ alias: "keyword"
1804
+ },
1805
+ "attribute-arguments": {
1806
+ pattern: re(/\(<<0>>*\)/.source, [roundExpression]),
1807
+ inside: Prism2.languages.csharp
1808
+ },
1809
+ "class-name": {
1810
+ pattern: RegExp(identifier),
1811
+ inside: {
1812
+ "punctuation": /\./
1813
+ }
1814
+ },
1815
+ "punctuation": /[:,]/
1816
+ }
1817
+ }
1818
+ });
1819
+ var formatString = /:[^}\r\n]+/.source;
1820
+ var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
1821
+ var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [mInterpolationRound, formatString]);
1822
+ var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2);
1823
+ var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [sInterpolationRound, formatString]);
1824
+ function createInterpolationInside(interpolation, interpolationRound) {
1825
+ return {
1826
+ "interpolation": {
1827
+ pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
1828
+ lookbehind: true,
1829
+ inside: {
1830
+ "format-string": {
1831
+ pattern: re(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source, [interpolationRound, formatString]),
1832
+ lookbehind: true,
1833
+ inside: {
1834
+ "punctuation": /^:/
1835
+ }
1836
+ },
1837
+ "punctuation": /^\{|\}$/,
1838
+ "expression": {
1839
+ pattern: /[\s\S]+/,
1840
+ alias: "language-csharp",
1841
+ inside: Prism2.languages.csharp
1842
+ }
1843
+ }
1844
+ },
1845
+ "string": /[\s\S]+/
1846
+ };
1847
+ }
1848
+ Prism2.languages.insertBefore("csharp", "string", {
1849
+ "interpolation-string": [
1850
+ {
1851
+ pattern: re(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source, [mInterpolation]),
1852
+ lookbehind: true,
1853
+ greedy: true,
1854
+ inside: createInterpolationInside(mInterpolation, mInterpolationRound)
1855
+ },
1856
+ {
1857
+ pattern: re(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source, [sInterpolation]),
1858
+ lookbehind: true,
1859
+ greedy: true,
1860
+ inside: createInterpolationInside(sInterpolation, sInterpolationRound)
1861
+ }
1862
+ ],
1863
+ "char": {
1864
+ pattern: RegExp(character),
1865
+ greedy: true
1866
+ }
1867
+ });
1868
+ Prism2.languages.dotnet = Prism2.languages.cs = Prism2.languages.csharp;
1869
+ })(Prism);
1870
+ (function(Prism2) {
1871
+ Prism2.languages.diff = {
1872
+ "coord": [
1873
+ // Match all kinds of coord lines (prefixed by "+++", "---" or "***").
1874
+ /^(?:\*{3}|-{3}|\+{3}).*$/m,
1875
+ // Match "@@ ... @@" coord lines in unified diff.
1876
+ /^@@.*@@$/m,
1877
+ // Match coord lines in normal diff (starts with a number).
1878
+ /^\d.*$/m
1879
+ ]
1880
+ // deleted, inserted, unchanged, diff
1881
+ };
1882
+ var PREFIXES = {
1883
+ "deleted-sign": "-",
1884
+ "deleted-arrow": "<",
1885
+ "inserted-sign": "+",
1886
+ "inserted-arrow": ">",
1887
+ "unchanged": " ",
1888
+ "diff": "!"
1889
+ };
1890
+ Object.keys(PREFIXES).forEach(function(name) {
1891
+ var prefix = PREFIXES[name];
1892
+ var alias = [];
1893
+ if (!/^\w+$/.test(name)) {
1894
+ alias.push(/\w+/.exec(name)[0]);
1895
+ }
1896
+ if (name === "diff") {
1897
+ alias.push("bold");
1898
+ }
1899
+ Prism2.languages.diff[name] = {
1900
+ pattern: RegExp("^(?:[" + prefix + "].*(?:\r\n?|\n|(?![\\s\\S])))+", "m"),
1901
+ alias,
1902
+ inside: {
1903
+ "line": {
1904
+ pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/,
1905
+ lookbehind: true
1906
+ },
1907
+ "prefix": {
1908
+ pattern: /[\s\S]/,
1909
+ alias: /\w+/.exec(name)[0]
1910
+ }
1911
+ }
1912
+ };
1913
+ });
1914
+ Object.defineProperty(Prism2.languages.diff, "PREFIXES", {
1915
+ value: PREFIXES
1916
+ });
1917
+ })(Prism);
1918
+ Prism.languages.json = {
1919
+ "property": {
1920
+ pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
1921
+ lookbehind: true,
1922
+ greedy: true
1923
+ },
1924
+ "string": {
1925
+ pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1926
+ lookbehind: true,
1927
+ greedy: true
1928
+ },
1929
+ "comment": {
1930
+ pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
1931
+ greedy: true
1932
+ },
1933
+ "number": /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
1934
+ "punctuation": /[{}[\],]/,
1935
+ "operator": /:/,
1936
+ "boolean": /\b(?:false|true)\b/,
1937
+ "null": {
1938
+ pattern: /\bnull\b/,
1939
+ alias: "keyword"
1940
+ }
1941
+ };
1942
+ Prism.languages.webmanifest = Prism.languages.json;
1943
+ (function(Prism2) {
1944
+ var powershell = Prism2.languages.powershell = {
1945
+ "sensitive-variable": {
1946
+ pattern: /(\[\[.*?\]\])/i,
1947
+ greedy: true
1948
+ },
1949
+ "comment": [
1950
+ {
1951
+ pattern: /(^|[^`])<#[\s\S]*?#>/,
1952
+ lookbehind: true
1953
+ },
1954
+ {
1955
+ pattern: /(^|[^`])#.*/,
1956
+ lookbehind: true
1957
+ }
1958
+ ],
1959
+ "string": [
1960
+ {
1961
+ pattern: /"(?:`[\s\S]|[^`"])*"/,
1962
+ greedy: true,
1963
+ inside: {
1964
+ "function": {
1965
+ // Allow for one level of nesting
1966
+ pattern: /(^|[^`])\$\((?:\$\(.*?\)|(?!\$\()[^\r\n)])*\)/,
1967
+ lookbehind: true,
1968
+ // Populated at end of file
1969
+ inside: {}
1970
+ },
1971
+ "sensitive-variable": {
1972
+ pattern: /(\[\[.*?\]\])/i,
1973
+ greedy: true
1974
+ }
1975
+ }
1976
+ },
1977
+ {
1978
+ pattern: /'(?:[^']|'')*'/,
1979
+ greedy: true
1980
+ }
1981
+ ],
1982
+ // Matches name spaces as well as casts, attribute decorators. Force starting with letter to avoid matching array indices
1983
+ // Supports two levels of nested brackets (e.g. `[OutputType([System.Collections.Generic.List[int]])]`)
1984
+ "namespace": /\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,
1985
+ "boolean": /\$(?:false|true)\b/i,
1986
+ "variable": /\$\w+\b/,
1987
+ // Cmdlets and aliases. Aliases should come last, otherwise "write" gets preferred over "write-host" for example
1988
+ // Get-Command | ?{ $_.ModuleName -match "Microsoft.PowerShell.(Util|Core|Management)" }
1989
+ // Get-Alias | ?{ $_.ReferencedCommand.Module.Name -match "Microsoft.PowerShell.(Util|Core|Management)" }
1990
+ "function": [
1991
+ /\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,
1992
+ /\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i
1993
+ ],
1994
+ // per http://technet.microsoft.com/en-us/library/hh847744.aspx
1995
+ "keyword": /\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,
1996
+ "operator": {
1997
+ pattern: /(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,
1998
+ lookbehind: true
1999
+ },
2000
+ "punctuation": /[|{}[\];(),.]/
2001
+ };
2002
+ powershell.string[0].inside = {
2003
+ "function": {
2004
+ // Allow for one level of nesting
2005
+ pattern: /(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,
2006
+ lookbehind: true,
2007
+ inside: powershell
2008
+ },
2009
+ "boolean": powershell.boolean,
2010
+ "variable": powershell.variable
2011
+ };
2012
+ })(Prism);
2013
+ (function(Prism2) {
2014
+ Prism2.languages.puppet = {
2015
+ "heredoc": [
2016
+ // Matches the content of a quoted heredoc string (subject to interpolation)
2017
+ {
2018
+ pattern: /(@\("([^"\r\n\/):]+)"(?:\/[nrts$uL]*)?\).*(?:\r?\n|\r))(?:.*(?:\r?\n|\r(?!\n)))*?[ \t]*(?:\|[ \t]*)?(?:-[ \t]*)?\2/,
2019
+ lookbehind: true,
2020
+ alias: "string",
2021
+ inside: {
2022
+ // Matches the end tag
2023
+ "punctuation": /(?=\S).*\S(?= *$)/
2024
+ // See interpolation below
2025
+ }
2026
+ },
2027
+ // Matches the content of an unquoted heredoc string (no interpolation)
2028
+ {
2029
+ pattern: /(@\(([^"\r\n\/):]+)(?:\/[nrts$uL]*)?\).*(?:\r?\n|\r))(?:.*(?:\r?\n|\r(?!\n)))*?[ \t]*(?:\|[ \t]*)?(?:-[ \t]*)?\2/,
2030
+ lookbehind: true,
2031
+ greedy: true,
2032
+ alias: "string",
2033
+ inside: {
2034
+ // Matches the end tag
2035
+ "punctuation": /(?=\S).*\S(?= *$)/
2036
+ }
2037
+ },
2038
+ // Matches the start tag of heredoc strings
2039
+ {
2040
+ pattern: /@\("?(?:[^"\r\n\/):]+)"?(?:\/[nrts$uL]*)?\)/,
2041
+ alias: "string",
2042
+ inside: {
2043
+ "punctuation": {
2044
+ pattern: /(\().+?(?=\))/,
2045
+ lookbehind: true
2046
+ }
2047
+ }
2048
+ }
2049
+ ],
2050
+ "multiline-comment": {
2051
+ pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
2052
+ lookbehind: true,
2053
+ greedy: true,
2054
+ alias: "comment"
2055
+ },
2056
+ "regex": {
2057
+ // Must be prefixed with the keyword "node" or a non-word char
2058
+ pattern: /((?:\bnode\s+|[~=\(\[\{,]\s*|[=+]>\s*|^\s*))\/(?:[^\/\\]|\\[\s\S])+\/(?:[imx]+\b|\B)/,
2059
+ lookbehind: true,
2060
+ greedy: true,
2061
+ inside: {
2062
+ // Extended regexes must have the x flag. They can contain single-line comments.
2063
+ "extended-regex": {
2064
+ pattern: /^\/(?:[^\/\\]|\\[\s\S])+\/[im]*x[im]*$/,
2065
+ inside: {
2066
+ "comment": /#.*/
2067
+ }
2068
+ }
2069
+ }
2070
+ },
2071
+ "comment": {
2072
+ pattern: /(^|[^\\])#.*/,
2073
+ lookbehind: true,
2074
+ greedy: true
2075
+ },
2076
+ "string": {
2077
+ // Allow for one nested level of double quotes inside interpolation
2078
+ pattern: /(["'])(?:\$\{(?:[^'"}]|(["'])(?:(?!\2)[^\\]|\\[\s\S])*\2)+\}|\$(?!\{)|(?!\1)[^\\$]|\\[\s\S])*\1/,
2079
+ greedy: true,
2080
+ inside: {
2081
+ "double-quoted": {
2082
+ pattern: /^"[\s\S]*"$/,
2083
+ inside: {
2084
+ // See interpolation below
2085
+ }
2086
+ }
2087
+ }
2088
+ },
2089
+ "variable": {
2090
+ pattern: /\$(?:::)?\w+(?:::\w+)*/,
2091
+ inside: {
2092
+ "punctuation": /::/
2093
+ }
2094
+ },
2095
+ "attr-name": /(?:\b\w+|\*)(?=\s*=>)/,
2096
+ "function": [
2097
+ {
2098
+ pattern: /(\.)(?!\d)\w+/,
2099
+ lookbehind: true
2100
+ },
2101
+ /\b(?:contain|debug|err|fail|include|info|notice|realize|require|tag|warning)\b|\b(?!\d)\w+(?=\()/
2102
+ ],
2103
+ "number": /\b(?:0x[a-f\d]+|\d+(?:\.\d+)?(?:e-?\d+)?)\b/i,
2104
+ "boolean": /\b(?:false|true)\b/,
2105
+ // Includes words reserved for future use
2106
+ "keyword": /\b(?:application|attr|case|class|consumes|default|define|else|elsif|function|if|import|inherits|node|private|produces|type|undef|unless)\b/,
2107
+ "datatype": {
2108
+ pattern: /\b(?:Any|Array|Boolean|Callable|Catalogentry|Class|Collection|Data|Default|Enum|Float|Hash|Integer|NotUndef|Numeric|Optional|Pattern|Regexp|Resource|Runtime|Scalar|String|Struct|Tuple|Type|Undef|Variant)\b/,
2109
+ alias: "symbol"
2110
+ },
2111
+ "operator": /=[=~>]?|![=~]?|<(?:<\|?|[=~|-])?|>[>=]?|->?|~>|\|>?>?|[*\/%+?]|\b(?:and|in|or)\b/,
2112
+ "punctuation": /[\[\]{}().,;]|:+/
2113
+ };
2114
+ var interpolation = [
2115
+ {
2116
+ // Allow for one nested level of braces inside interpolation
2117
+ pattern: /(^|[^\\])\$\{(?:[^'"{}]|\{[^}]*\}|(["'])(?:(?!\2)[^\\]|\\[\s\S])*\2)+\}/,
2118
+ lookbehind: true,
2119
+ inside: {
2120
+ "short-variable": {
2121
+ // Negative look-ahead prevent wrong highlighting of functions
2122
+ pattern: /(^\$\{)(?!\w+\()(?:::)?\w+(?:::\w+)*/,
2123
+ lookbehind: true,
2124
+ alias: "variable",
2125
+ inside: {
2126
+ "punctuation": /::/
2127
+ }
2128
+ },
2129
+ "delimiter": {
2130
+ pattern: /^\$/,
2131
+ alias: "variable"
2132
+ },
2133
+ rest: Prism2.languages.puppet
2134
+ }
2135
+ },
2136
+ {
2137
+ pattern: /(^|[^\\])\$(?:::)?\w+(?:::\w+)*/,
2138
+ lookbehind: true,
2139
+ alias: "variable",
2140
+ inside: {
2141
+ "punctuation": /::/
2142
+ }
2143
+ }
2144
+ ];
2145
+ Prism2.languages.puppet["heredoc"][0].inside.interpolation = interpolation;
2146
+ Prism2.languages.puppet["string"].inside["double-quoted"].inside.interpolation = interpolation;
2147
+ })(Prism);
2148
+ Prism.languages.python = {
2149
+ "comment": {
2150
+ pattern: /(^|[^\\])#.*/,
2151
+ lookbehind: true,
2152
+ greedy: true
2153
+ },
2154
+ "string-interpolation": {
2155
+ pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
2156
+ greedy: true,
2157
+ inside: {
2158
+ "interpolation": {
2159
+ // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
2160
+ pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
2161
+ lookbehind: true,
2162
+ inside: {
2163
+ "format-spec": {
2164
+ pattern: /(:)[^:(){}]+(?=\}$)/,
2165
+ lookbehind: true
2166
+ },
2167
+ "conversion-option": {
2168
+ pattern: /![sra](?=[:}]$)/,
2169
+ alias: "punctuation"
2170
+ },
2171
+ rest: null
2172
+ }
2173
+ },
2174
+ "string": /[\s\S]+/
2175
+ }
2176
+ },
2177
+ "triple-quoted-string": {
2178
+ pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
2179
+ greedy: true,
2180
+ alias: "string"
2181
+ },
2182
+ "string": {
2183
+ pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
2184
+ greedy: true
2185
+ },
2186
+ "function": {
2187
+ pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
2188
+ lookbehind: true
2189
+ },
2190
+ "class-name": {
2191
+ pattern: /(\bclass\s+)\w+/i,
2192
+ lookbehind: true
2193
+ },
2194
+ "decorator": {
2195
+ pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
2196
+ lookbehind: true,
2197
+ alias: ["annotation", "punctuation"],
2198
+ inside: {
2199
+ "punctuation": /\./
2200
+ }
2201
+ },
2202
+ "keyword": /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
2203
+ "builtin": /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
2204
+ "boolean": /\b(?:False|None|True)\b/,
2205
+ "number": /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
2206
+ "operator": /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2207
+ "punctuation": /[{}[\];(),.:]/
2208
+ };
2209
+ Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
2210
+ Prism.languages.py = Prism.languages.python;
2211
+ (function(Prism2) {
2212
+ Prism2.languages.ruby = Prism2.languages.extend("clike", {
2213
+ "comment": {
2214
+ pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
2215
+ greedy: true
2216
+ },
2217
+ "class-name": {
2218
+ pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
2219
+ lookbehind: true,
2220
+ inside: {
2221
+ "punctuation": /[.\\]/
2222
+ }
2223
+ },
2224
+ "keyword": /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
2225
+ "operator": /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
2226
+ "punctuation": /[(){}[\].,;]/
2227
+ });
2228
+ Prism2.languages.insertBefore("ruby", "operator", {
2229
+ "double-colon": {
2230
+ pattern: /::/,
2231
+ alias: "punctuation"
2232
+ }
2233
+ });
2234
+ var interpolation = {
2235
+ pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
2236
+ lookbehind: true,
2237
+ inside: {
2238
+ "content": {
2239
+ pattern: /^(#\{)[\s\S]+(?=\}$)/,
2240
+ lookbehind: true,
2241
+ inside: Prism2.languages.ruby
2242
+ },
2243
+ "delimiter": {
2244
+ pattern: /^#\{|\}$/,
2245
+ alias: "punctuation"
2246
+ }
2247
+ }
2248
+ };
2249
+ delete Prism2.languages.ruby.function;
2250
+ var percentExpression = "(?:" + [
2251
+ /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
2252
+ /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
2253
+ /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
2254
+ /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
2255
+ /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
2256
+ ].join("|") + ")";
2257
+ var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
2258
+ Prism2.languages.insertBefore("ruby", "keyword", {
2259
+ "regex-literal": [
2260
+ {
2261
+ pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
2262
+ greedy: true,
2263
+ inside: {
2264
+ "interpolation": interpolation,
2265
+ "regex": /[\s\S]+/
2266
+ }
2267
+ },
2268
+ {
2269
+ pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
2270
+ lookbehind: true,
2271
+ greedy: true,
2272
+ inside: {
2273
+ "interpolation": interpolation,
2274
+ "regex": /[\s\S]+/
2275
+ }
2276
+ }
2277
+ ],
2278
+ "variable": /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
2279
+ "symbol": [
2280
+ {
2281
+ pattern: RegExp(/(^|[^:]):/.source + symbolName),
2282
+ lookbehind: true,
2283
+ greedy: true
2284
+ },
2285
+ {
2286
+ pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
2287
+ lookbehind: true,
2288
+ greedy: true
2289
+ }
2290
+ ],
2291
+ "method-definition": {
2292
+ pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
2293
+ lookbehind: true,
2294
+ inside: {
2295
+ "function": /\b\w+$/,
2296
+ "keyword": /^self\b/,
2297
+ "class-name": /^\w+/,
2298
+ "punctuation": /\./
2299
+ }
2300
+ }
2301
+ });
2302
+ Prism2.languages.insertBefore("ruby", "string", {
2303
+ "string-literal": [
2304
+ {
2305
+ pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
2306
+ greedy: true,
2307
+ inside: {
2308
+ "interpolation": interpolation,
2309
+ "string": /[\s\S]+/
2310
+ }
2311
+ },
2312
+ {
2313
+ pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
2314
+ greedy: true,
2315
+ inside: {
2316
+ "interpolation": interpolation,
2317
+ "string": /[\s\S]+/
2318
+ }
2319
+ },
2320
+ {
2321
+ pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2322
+ alias: "heredoc-string",
2323
+ greedy: true,
2324
+ inside: {
2325
+ "delimiter": {
2326
+ pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
2327
+ inside: {
2328
+ "symbol": /\b\w+/,
2329
+ "punctuation": /^<<[-~]?/
2330
+ }
2331
+ },
2332
+ "interpolation": interpolation,
2333
+ "string": /[\s\S]+/
2334
+ }
2335
+ },
2336
+ {
2337
+ pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2338
+ alias: "heredoc-string",
2339
+ greedy: true,
2340
+ inside: {
2341
+ "delimiter": {
2342
+ pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
2343
+ inside: {
2344
+ "symbol": /\b\w+/,
2345
+ "punctuation": /^<<[-~]?'|'$/
2346
+ }
2347
+ },
2348
+ "string": /[\s\S]+/
2349
+ }
2350
+ }
2351
+ ],
2352
+ "command-literal": [
2353
+ {
2354
+ pattern: RegExp(/%x/.source + percentExpression),
2355
+ greedy: true,
2356
+ inside: {
2357
+ "interpolation": interpolation,
2358
+ "command": {
2359
+ pattern: /[\s\S]+/,
2360
+ alias: "string"
2361
+ }
2362
+ }
2363
+ },
2364
+ {
2365
+ pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
2366
+ greedy: true,
2367
+ inside: {
2368
+ "interpolation": interpolation,
2369
+ "command": {
2370
+ pattern: /[\s\S]+/,
2371
+ alias: "string"
2372
+ }
2373
+ }
2374
+ }
2375
+ ]
2376
+ });
2377
+ delete Prism2.languages.ruby.string;
2378
+ Prism2.languages.insertBefore("ruby", "number", {
2379
+ "builtin": /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
2380
+ "constant": /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
2381
+ });
2382
+ Prism2.languages.rb = Prism2.languages.ruby;
2383
+ })(Prism);
2384
+ Prism.languages.scss = Prism.languages.extend("css", {
2385
+ "comment": {
2386
+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
2387
+ lookbehind: true
2388
+ },
2389
+ "atrule": {
2390
+ pattern: /@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,
2391
+ inside: {
2392
+ "rule": /@[\w-]+/
2393
+ // See rest below
2394
+ }
2395
+ },
2396
+ // url, compassified
2397
+ "url": /(?:[-a-z]+-)?url(?=\()/i,
2398
+ // CSS selector regex is not appropriate for Sass
2399
+ // since there can be lot more things (var, @ directive, nesting..)
2400
+ // a selector must start at the end of a property or after a brace (end of other rules or nesting)
2401
+ // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
2402
+ // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
2403
+ // can "pass" as a selector- e.g: proper#{$erty})
2404
+ // this one was hard to do, so please be careful if you edit this one :)
2405
+ "selector": {
2406
+ // Initial look-ahead is used to prevent matching of blank selectors
2407
+ pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,
2408
+ inside: {
2409
+ "parent": {
2410
+ pattern: /&/,
2411
+ alias: "important"
2412
+ },
2413
+ "placeholder": /%[-\w]+/,
2414
+ "variable": /\$[-\w]+|#\{\$[-\w]+\}/
2415
+ }
2416
+ },
2417
+ "property": {
2418
+ pattern: /(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,
2419
+ inside: {
2420
+ "variable": /\$[-\w]+|#\{\$[-\w]+\}/
2421
+ }
2422
+ }
2423
+ });
2424
+ Prism.languages.insertBefore("scss", "atrule", {
2425
+ "keyword": [
2426
+ /@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,
2427
+ {
2428
+ pattern: /( )(?:from|through)(?= )/,
2429
+ lookbehind: true
2430
+ }
2431
+ ]
2432
+ });
2433
+ Prism.languages.insertBefore("scss", "important", {
2434
+ // var and interpolated vars
2435
+ "variable": /\$[-\w]+|#\{\$[-\w]+\}/
2436
+ });
2437
+ Prism.languages.insertBefore("scss", "function", {
2438
+ "module-modifier": {
2439
+ pattern: /\b(?:as|hide|show|with)\b/i,
2440
+ alias: "keyword"
2441
+ },
2442
+ "placeholder": {
2443
+ pattern: /%[-\w]+/,
2444
+ alias: "selector"
2445
+ },
2446
+ "statement": {
2447
+ pattern: /\B!(?:default|optional)\b/i,
2448
+ alias: "keyword"
2449
+ },
2450
+ "boolean": /\b(?:false|true)\b/,
2451
+ "null": {
2452
+ pattern: /\bnull\b/,
2453
+ alias: "keyword"
2454
+ },
2455
+ "operator": {
2456
+ pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,
2457
+ lookbehind: true
2458
+ }
2459
+ });
2460
+ Prism.languages.scss["atrule"].inside.rest = Prism.languages.scss;
2461
+ (function(Prism2) {
2462
+ var strings = [
2463
+ // normal string
2464
+ /"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/.source,
2465
+ /'[^']*'/.source,
2466
+ /\$'(?:[^'\\]|\\[\s\S])*'/.source,
2467
+ // here doc
2468
+ // 2 capturing groups
2469
+ /<<-?\s*(["']?)(\w+)\1\s[\s\S]*?[\r\n]\2/.source
2470
+ ].join("|");
2471
+ Prism2.languages["shell-session"] = {
2472
+ "command": {
2473
+ pattern: RegExp(
2474
+ // user info
2475
+ /^/.source + "(?:" + // <user> ":" ( <path> )?
2476
+ (/[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+(?::[^\0-\x1F$#%*?"<>:;|]+)?/.source + "|" + // <path>
2477
+ // Since the path pattern is quite general, we will require it to start with a special character to
2478
+ // prevent false positives.
2479
+ /[/~.][^\0-\x1F$#%*?"<>@:;|]*/.source) + ")?" + // shell symbol
2480
+ /[$#%](?=\s)/.source + // bash command
2481
+ /(?:[^\\\r\n \t'"<$]|[ \t](?:(?!#)|#.*$)|\\(?:[^\r]|\r\n?)|\$(?!')|<(?!<)|<<str>>)+/.source.replace(/<<str>>/g, function() {
2482
+ return strings;
2483
+ }),
2484
+ "m"
2485
+ ),
2486
+ greedy: true,
2487
+ inside: {
2488
+ "info": {
2489
+ // foo@bar:~/files$ exit
2490
+ // foo@bar$ exit
2491
+ // ~/files$ exit
2492
+ pattern: /^[^#$%]+/,
2493
+ alias: "punctuation",
2494
+ inside: {
2495
+ "user": /^[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+/,
2496
+ "punctuation": /:/,
2497
+ "path": /[\s\S]+/
2498
+ }
2499
+ },
2500
+ "bash": {
2501
+ pattern: /(^[$#%]\s*)\S[\s\S]*/,
2502
+ lookbehind: true,
2503
+ alias: "language-bash",
2504
+ inside: Prism2.languages.bash
2505
+ },
2506
+ "shell-symbol": {
2507
+ pattern: /^[$#%]/,
2508
+ alias: "important"
2509
+ }
2510
+ }
2511
+ },
2512
+ "output": /.(?:.*(?:[\r\n]|.$))*/
2513
+ };
2514
+ Prism2.languages["sh-session"] = Prism2.languages["shellsession"] = Prism2.languages["shell-session"];
2515
+ })(Prism);
2516
+ (function(Prism2) {
2517
+ function insertDocComment(lang, docComment) {
2518
+ if (Prism2.languages[lang]) {
2519
+ Prism2.languages.insertBefore(lang, "comment", {
2520
+ "doc-comment": docComment
2521
+ });
2522
+ }
2523
+ }
2524
+ var tag = Prism2.languages.markup.tag;
2525
+ var slashDocComment = {
2526
+ pattern: /\/\/\/.*/,
2527
+ greedy: true,
2528
+ alias: "comment",
2529
+ inside: {
2530
+ "tag": tag
2531
+ }
2532
+ };
2533
+ var tickDocComment = {
2534
+ pattern: /'''.*/,
2535
+ greedy: true,
2536
+ alias: "comment",
2537
+ inside: {
2538
+ "tag": tag
2539
+ }
2540
+ };
2541
+ insertDocComment("csharp", slashDocComment);
2542
+ insertDocComment("fsharp", slashDocComment);
2543
+ insertDocComment("vbnet", tickDocComment);
2544
+ })(Prism);
2545
+ (function(Prism2) {
2546
+ var anchorOrAlias = /[*&][^\s[\]{},]+/;
2547
+ var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
2548
+ var properties = "(?:" + tag.source + "(?:[ ]+" + anchorOrAlias.source + ")?|" + anchorOrAlias.source + "(?:[ ]+" + tag.source + ")?)";
2549
+ var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, function() {
2550
+ return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
2551
+ });
2552
+ var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
2553
+ function createValuePattern(value, flags) {
2554
+ flags = (flags || "").replace(/m/g, "") + "m";
2555
+ var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, function() {
2556
+ return properties;
2557
+ }).replace(/<<value>>/g, function() {
2558
+ return value;
2559
+ });
2560
+ return RegExp(pattern, flags);
2561
+ }
2562
+ Prism2.languages.yaml = {
2563
+ "scalar": {
2564
+ pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, function() {
2565
+ return properties;
2566
+ })),
2567
+ lookbehind: true,
2568
+ alias: "string"
2569
+ },
2570
+ "comment": /#.*/,
2571
+ "key": {
2572
+ pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, function() {
2573
+ return properties;
2574
+ }).replace(/<<key>>/g, function() {
2575
+ return "(?:" + plainKey + "|" + string + ")";
2576
+ })),
2577
+ lookbehind: true,
2578
+ greedy: true,
2579
+ alias: "atrule"
2580
+ },
2581
+ "directive": {
2582
+ pattern: /(^[ \t]*)%.+/m,
2583
+ lookbehind: true,
2584
+ alias: "important"
2585
+ },
2586
+ "datetime": {
2587
+ 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),
2588
+ lookbehind: true,
2589
+ alias: "number"
2590
+ },
2591
+ "boolean": {
2592
+ pattern: createValuePattern(/false|true/.source, "i"),
2593
+ lookbehind: true,
2594
+ alias: "important"
2595
+ },
2596
+ "null": {
2597
+ pattern: createValuePattern(/null|~/.source, "i"),
2598
+ lookbehind: true,
2599
+ alias: "important"
2600
+ },
2601
+ "string": {
2602
+ pattern: createValuePattern(string),
2603
+ lookbehind: true,
2604
+ greedy: true
2605
+ },
2606
+ "number": {
2607
+ pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, "i"),
2608
+ lookbehind: true
2609
+ },
2610
+ "tag": tag,
2611
+ "important": anchorOrAlias,
2612
+ "punctuation": /---|[:[\]{}\-,|>?]|\.\.\./
2613
+ };
2614
+ Prism2.languages.yml = Prism2.languages.yaml;
2615
+ })(Prism);
2616
+ (function(Prism2) {
2617
+ var guid = {
2618
+ // https://en.wikipedia.org/wiki/Universally_unique_identifier#Format
2619
+ pattern: /[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}/i,
2620
+ alias: "constant"
2621
+ };
2622
+ Prism2.languages["log-file"] = {
2623
+ "sensitive-variable": {
2624
+ pattern: /(\[\[.*?\]\])/i,
2625
+ greedy: true
2626
+ },
2627
+ "verbose": [
2628
+ {
2629
+ pattern: /\b(Trace)\b:/i,
2630
+ greedy: true
2631
+ },
2632
+ {
2633
+ pattern: /\[(verbose|verb|vrb|vb|v)\]/i,
2634
+ greedy: true
2635
+ }
2636
+ ],
2637
+ "debug": [
2638
+ {
2639
+ pattern: /\b(DEBUG|Debug)\b|\b(debug)\:/i,
2640
+ greedy: true
2641
+ },
2642
+ {
2643
+ pattern: /\[(debug|dbug|dbg|de|d)\]/i,
2644
+ greedy: true
2645
+ }
2646
+ ],
2647
+ "info": [
2648
+ {
2649
+ pattern: /\b(HINT|INFO|INFORMATION|Info|NOTICE|II)\b | \b(^[^\.\.]+$)\b | \b(info|information)\:/,
2650
+ greedy: true
2651
+ },
2652
+ {
2653
+ pattern: /\[(information|info|inf|in|i)\]/i,
2654
+ greedy: true
2655
+ }
2656
+ ],
2657
+ "warning": [
2658
+ {
2659
+ pattern: /\b(WARNING|WARN|Warn|WW)\b|\b(warning)\:/i,
2660
+ greedy: true
2661
+ },
2662
+ {
2663
+ pattern: /\[(warning|warn|wrn|wn|w)\]/i,
2664
+ greedy: true
2665
+ }
2666
+ ],
2667
+ "error": [
2668
+ {
2669
+ pattern: /\b(ALERT|CRITICAL|EMERGENCY|ERROR|FAILURE|FAIL|Fatal|FATAL|Error|EE)\b|\b(error)\:/i,
2670
+ greedy: true
2671
+ },
2672
+ {
2673
+ pattern: /\[(error|eror|err|er|e|fatal|fatl|ftl|fa|f)\]/i,
2674
+ greedy: true
2675
+ }
2676
+ ],
2677
+ "date": [
2678
+ {
2679
+ pattern: /\b\d{4}-\d{2}-\d{2}(T|\b)/i,
2680
+ greedy: true
2681
+ },
2682
+ {
2683
+ pattern: /\b\d{2}[^\w\s]\d{2}[^\w\s]\d{4}\b/i,
2684
+ greedy: true
2685
+ },
2686
+ {
2687
+ pattern: /\d{1,2}:\d{2}(:\d{2}([.,]\d{1,})?)?(Z| ?[+-]\d{1,2}:\d{2})?\b/i,
2688
+ greedy: true
2689
+ }
2690
+ ],
2691
+ // Add Git Commit Hash possibly
2692
+ "guid": guid,
2693
+ "text-string": [
2694
+ {
2695
+ pattern: /[a-zA-Z]'[a-zA-Z]/i,
2696
+ greedy: true
2697
+ },
2698
+ {
2699
+ pattern: /[a-zA-Z]\('[a-zA-Z]/i,
2700
+ greedy: true
2701
+ }
2702
+ ],
2703
+ "string": [
2704
+ {
2705
+ pattern: /"[^"]*"/i,
2706
+ greedy: true,
2707
+ inside: {
2708
+ "sensitive-variable": {
2709
+ pattern: /(\[\[.*?\]\])/i,
2710
+ greedy: true
2711
+ }
2712
+ }
2713
+ },
2714
+ {
2715
+ pattern: /'[^']*'/i,
2716
+ greedy: true
2717
+ }
2718
+ ],
2719
+ "exceptiontype": {
2720
+ pattern: /\b([a-zA-Z.]*Exception)\b/i,
2721
+ greedy: true
2722
+ },
2723
+ // Add Exception Call Stacks possibly
2724
+ "text-constant": {
2725
+ pattern: /(\\[\w-]+.\w+)/i,
2726
+ greedy: true
2727
+ },
2728
+ "constant": [
2729
+ {
2730
+ pattern: /\b([0-9]+|true|false|null)\b/i,
2731
+ // bools and numbers
2732
+ greedy: true
2733
+ },
2734
+ {
2735
+ pattern: /\b(http|https|ftp|file):\/\S+\b\/?/i,
2736
+ greedy: true
2737
+ },
2738
+ {
2739
+ pattern: /([\w-]+\.)+([\w-])+(?![\w/\\])/i,
2740
+ // Match character and . sequences (such as namespaces) as well as file names and extensions (e.g. bar.txt)
2741
+ greedy: true
2742
+ }
2743
+ ]
2744
+ };
2745
+ Prism2.languages["log"] = Prism2.languages["log-file"];
2746
+ })(Prism);
2747
+ (function() {
2748
+ if (typeof Prism === "undefined" || typeof document === "undefined") {
2749
+ return;
2750
+ }
2751
+ var PLUGIN_NAME = "line-numbers";
2752
+ var NEW_LINE_EXP = /\n(?!$)/g;
2753
+ var config = Prism.plugins.lineNumbers = {
2754
+ /**
2755
+ * Get node for provided line number
2756
+ *
2757
+ * @param {Element} element pre element
2758
+ * @param {number} number line number
2759
+ * @returns {Element|undefined}
2760
+ */
2761
+ getLine: function(element, number) {
2762
+ if (element.tagName !== "PRE" || !element.classList.contains(PLUGIN_NAME)) {
2763
+ return;
2764
+ }
2765
+ var lineNumberRows = element.querySelector(".line-numbers-rows");
2766
+ if (!lineNumberRows) {
2767
+ return;
2768
+ }
2769
+ var lineNumberStart = parseInt(element.getAttribute("data-start"), 10) || 1;
2770
+ var lineNumberEnd = lineNumberStart + (lineNumberRows.children.length - 1);
2771
+ if (number < lineNumberStart) {
2772
+ number = lineNumberStart;
2773
+ }
2774
+ if (number > lineNumberEnd) {
2775
+ number = lineNumberEnd;
2776
+ }
2777
+ var lineIndex = number - lineNumberStart;
2778
+ return lineNumberRows.children[lineIndex];
2779
+ },
2780
+ /**
2781
+ * Resizes the line numbers of the given element.
2782
+ *
2783
+ * This function will not add line numbers. It will only resize existing ones.
2784
+ *
2785
+ * @param {HTMLElement} element A `<pre>` element with line numbers.
2786
+ * @returns {void}
2787
+ */
2788
+ resize: function(element) {
2789
+ resizeElements([element]);
2790
+ },
2791
+ /**
2792
+ * Whether the plugin can assume that the units font sizes and margins are not depended on the size of
2793
+ * the current viewport.
2794
+ *
2795
+ * Setting this to `true` will allow the plugin to do certain optimizations for better performance.
2796
+ *
2797
+ * Set this to `false` if you use any of the following CSS units: `vh`, `vw`, `vmin`, `vmax`.
2798
+ *
2799
+ * @type {boolean}
2800
+ */
2801
+ assumeViewportIndependence: true
2802
+ };
2803
+ function resizeElements(elements) {
2804
+ elements = elements.filter(function(e) {
2805
+ var codeStyles = getStyles(e);
2806
+ var whiteSpace = codeStyles["white-space"];
2807
+ return whiteSpace === "pre-wrap" || whiteSpace === "pre-line";
2808
+ });
2809
+ if (elements.length == 0) {
2810
+ return;
2811
+ }
2812
+ var infos = elements.map(function(element) {
2813
+ var codeElement = element.querySelector("code");
2814
+ var lineNumbersWrapper = element.querySelector(".line-numbers-rows");
2815
+ if (!codeElement || !lineNumbersWrapper) {
2816
+ return void 0;
2817
+ }
2818
+ var lineNumberSizer = element.querySelector(".line-numbers-sizer");
2819
+ var codeLines = codeElement.textContent.split(NEW_LINE_EXP);
2820
+ if (!lineNumberSizer) {
2821
+ lineNumberSizer = document.createElement("span");
2822
+ lineNumberSizer.className = "line-numbers-sizer";
2823
+ codeElement.appendChild(lineNumberSizer);
2824
+ }
2825
+ lineNumberSizer.innerHTML = "0";
2826
+ lineNumberSizer.style.display = "block";
2827
+ var oneLinerHeight = lineNumberSizer.getBoundingClientRect().height;
2828
+ lineNumberSizer.innerHTML = "";
2829
+ return {
2830
+ element,
2831
+ lines: codeLines,
2832
+ lineHeights: [],
2833
+ oneLinerHeight,
2834
+ sizer: lineNumberSizer
2835
+ };
2836
+ }).filter(Boolean);
2837
+ infos.forEach(function(info) {
2838
+ var lineNumberSizer = info.sizer;
2839
+ var lines = info.lines;
2840
+ var lineHeights = info.lineHeights;
2841
+ var oneLinerHeight = info.oneLinerHeight;
2842
+ lineHeights[lines.length - 1] = void 0;
2843
+ lines.forEach(function(line, index) {
2844
+ if (line && line.length > 1) {
2845
+ var e = lineNumberSizer.appendChild(document.createElement("span"));
2846
+ e.style.display = "block";
2847
+ e.textContent = line;
2848
+ } else {
2849
+ lineHeights[index] = oneLinerHeight;
2850
+ }
2851
+ });
2852
+ });
2853
+ infos.forEach(function(info) {
2854
+ var lineNumberSizer = info.sizer;
2855
+ var lineHeights = info.lineHeights;
2856
+ var childIndex = 0;
2857
+ for (var i = 0; i < lineHeights.length; i++) {
2858
+ if (lineHeights[i] === void 0) {
2859
+ lineHeights[i] = lineNumberSizer.children[childIndex++].getBoundingClientRect().height;
2860
+ }
2861
+ }
2862
+ });
2863
+ infos.forEach(function(info) {
2864
+ var lineNumberSizer = info.sizer;
2865
+ var wrapper = info.element.querySelector(".line-numbers-rows");
2866
+ lineNumberSizer.style.display = "none";
2867
+ lineNumberSizer.innerHTML = "";
2868
+ info.lineHeights.forEach(function(height, lineNumber) {
2869
+ wrapper.children[lineNumber].style.height = height + "px";
2870
+ });
2871
+ });
2872
+ }
2873
+ function getStyles(element) {
2874
+ if (!element) {
2875
+ return null;
2876
+ }
2877
+ return window.getComputedStyle ? getComputedStyle(element) : element.currentStyle || null;
2878
+ }
2879
+ var lastWidth = void 0;
2880
+ window.addEventListener("resize", function() {
2881
+ if (config.assumeViewportIndependence && lastWidth === window.innerWidth) {
2882
+ return;
2883
+ }
2884
+ lastWidth = window.innerWidth;
2885
+ resizeElements(Array.prototype.slice.call(document.querySelectorAll("pre." + PLUGIN_NAME)));
2886
+ });
2887
+ Prism.hooks.add("complete", function(env) {
2888
+ if (!env.code) {
2889
+ return;
2890
+ }
2891
+ var code = (
2892
+ /** @type {Element} */
2893
+ env.element
2894
+ );
2895
+ var pre = (
2896
+ /** @type {HTMLElement} */
2897
+ code.parentNode
2898
+ );
2899
+ if (!pre || !/pre/i.test(pre.nodeName)) {
2900
+ return;
2901
+ }
2902
+ if (code.querySelector(".line-numbers-rows")) {
2903
+ return;
2904
+ }
2905
+ if (!Prism.util.isActive(code, PLUGIN_NAME)) {
2906
+ return;
2907
+ }
2908
+ code.classList.remove(PLUGIN_NAME);
2909
+ pre.classList.add(PLUGIN_NAME);
2910
+ var match = env.code.match(NEW_LINE_EXP);
2911
+ var linesNum = match ? match.length + 1 : 1;
2912
+ var lineNumbersWrapper;
2913
+ var lines = new Array(linesNum + 1).join("<span></span>");
2914
+ lineNumbersWrapper = document.createElement("span");
2915
+ lineNumbersWrapper.setAttribute("aria-hidden", "true");
2916
+ lineNumbersWrapper.className = "line-numbers-rows";
2917
+ lineNumbersWrapper.innerHTML = lines;
2918
+ if (pre.hasAttribute("data-start")) {
2919
+ pre.style.counterReset = "linenumber " + (parseInt(pre.getAttribute("data-start"), 10) - 1);
2920
+ }
2921
+ env.element.appendChild(lineNumbersWrapper);
2922
+ resizeElements([pre]);
2923
+ Prism.hooks.run("line-numbers", env);
2924
+ });
2925
+ Prism.hooks.add("line-numbers", function(env) {
2926
+ env.plugins = env.plugins || {};
2927
+ env.plugins.lineNumbers = true;
2928
+ });
2929
+ })();
2930
+ (function() {
2931
+ if (typeof Prism === "undefined" || typeof document === "undefined") {
2932
+ return;
2933
+ }
2934
+ var callbacks = [];
2935
+ var map = {};
2936
+ var noop = function() {
2937
+ };
2938
+ Prism.plugins.toolbar = {};
2939
+ var registerButton = Prism.plugins.toolbar.registerButton = function(key, opts) {
2940
+ var callback;
2941
+ if (typeof opts === "function") {
2942
+ callback = opts;
2943
+ } else {
2944
+ callback = function(env) {
2945
+ var element;
2946
+ if (typeof opts.onClick === "function") {
2947
+ element = document.createElement("button");
2948
+ element.type = "button";
2949
+ element.addEventListener("click", function() {
2950
+ opts.onClick.call(this, env);
2951
+ });
2952
+ } else if (typeof opts.url === "string") {
2953
+ element = document.createElement("a");
2954
+ element.href = opts.url;
2955
+ } else {
2956
+ element = document.createElement("span");
2957
+ }
2958
+ if (opts.className) {
2959
+ element.classList.add(opts.className);
2960
+ }
2961
+ element.textContent = opts.text;
2962
+ return element;
2963
+ };
2964
+ }
2965
+ if (key in map) {
2966
+ console.warn('There is a button with the key "' + key + '" registered already.');
2967
+ return;
2968
+ }
2969
+ callbacks.push(map[key] = callback);
2970
+ };
2971
+ function getOrder(element) {
2972
+ while (element) {
2973
+ var order = element.getAttribute("data-toolbar-order");
2974
+ if (order != null) {
2975
+ order = order.trim();
2976
+ if (order.length) {
2977
+ return order.split(/\s*,\s*/g);
2978
+ } else {
2979
+ return [];
2980
+ }
2981
+ }
2982
+ element = element.parentElement;
2983
+ }
2984
+ }
2985
+ var hook = Prism.plugins.toolbar.hook = function(env) {
2986
+ var pre = env.element.parentNode;
2987
+ if (!pre || !/pre/i.test(pre.nodeName)) {
2988
+ return;
2989
+ }
2990
+ if (pre.parentNode.classList.contains("code-toolbar")) {
2991
+ return;
2992
+ }
2993
+ var wrapper = document.createElement("div");
2994
+ wrapper.classList.add("code-toolbar");
2995
+ pre.parentNode.insertBefore(wrapper, pre);
2996
+ wrapper.appendChild(pre);
2997
+ var toolbar = document.createElement("div");
2998
+ toolbar.classList.add("toolbar");
2999
+ var elementCallbacks = callbacks;
3000
+ var order = getOrder(env.element);
3001
+ if (order) {
3002
+ elementCallbacks = order.map(function(key) {
3003
+ return map[key] || noop;
3004
+ });
3005
+ }
3006
+ elementCallbacks.forEach(function(callback) {
3007
+ var element = callback(env);
3008
+ if (!element) {
3009
+ return;
3010
+ }
3011
+ var item = document.createElement("div");
3012
+ item.classList.add("toolbar-item");
3013
+ item.appendChild(element);
3014
+ toolbar.appendChild(item);
3015
+ });
3016
+ wrapper.appendChild(toolbar);
3017
+ };
3018
+ registerButton("label", function(env) {
3019
+ var pre = env.element.parentNode;
3020
+ if (!pre || !/pre/i.test(pre.nodeName)) {
3021
+ return;
3022
+ }
3023
+ if (!pre.hasAttribute("data-label")) {
3024
+ return;
3025
+ }
3026
+ var element;
3027
+ var template;
3028
+ var text = pre.getAttribute("data-label");
3029
+ try {
3030
+ template = document.querySelector("template#" + text);
3031
+ } catch (e) {
3032
+ }
3033
+ if (template) {
3034
+ element = template.content;
3035
+ } else {
3036
+ if (pre.hasAttribute("data-url")) {
3037
+ element = document.createElement("a");
3038
+ element.href = pre.getAttribute("data-url");
3039
+ } else {
3040
+ element = document.createElement("span");
3041
+ }
3042
+ element.textContent = text;
3043
+ }
3044
+ return element;
3045
+ });
3046
+ Prism.hooks.add("complete", hook);
3047
+ })();
3048
+ (function() {
3049
+ if (typeof Prism === "undefined" || typeof document === "undefined") {
3050
+ return;
3051
+ }
3052
+ if (!Prism.plugins.toolbar) {
3053
+ console.warn("Copy to Clipboard plugin loaded before Toolbar plugin.");
3054
+ return;
3055
+ }
3056
+ function registerClipboard(element, copyInfo) {
3057
+ element.addEventListener("click", function() {
3058
+ copyTextToClipboard(copyInfo);
3059
+ });
3060
+ }
3061
+ function fallbackCopyTextToClipboard(copyInfo) {
3062
+ var textArea = document.createElement("textarea");
3063
+ textArea.value = copyInfo.getText();
3064
+ textArea.style.top = "0";
3065
+ textArea.style.left = "0";
3066
+ textArea.style.position = "fixed";
3067
+ document.body.appendChild(textArea);
3068
+ textArea.focus();
3069
+ textArea.select();
3070
+ try {
3071
+ var successful = document.execCommand("copy");
3072
+ setTimeout(function() {
3073
+ if (successful) {
3074
+ copyInfo.success();
3075
+ } else {
3076
+ copyInfo.error();
3077
+ }
3078
+ }, 1);
3079
+ } catch (err) {
3080
+ setTimeout(function() {
3081
+ copyInfo.error(err);
3082
+ }, 1);
3083
+ }
3084
+ document.body.removeChild(textArea);
3085
+ }
3086
+ function copyTextToClipboard(copyInfo) {
3087
+ if (navigator.clipboard) {
3088
+ navigator.clipboard.writeText(copyInfo.getText()).then(copyInfo.success, function() {
3089
+ fallbackCopyTextToClipboard(copyInfo);
3090
+ });
3091
+ } else {
3092
+ fallbackCopyTextToClipboard(copyInfo);
3093
+ }
3094
+ }
3095
+ function selectElementText(element) {
3096
+ window.getSelection().selectAllChildren(element);
3097
+ }
3098
+ function getSettings(startElement) {
3099
+ var settings = {
3100
+ "copy": "Copy",
3101
+ "copy-error": "Press Ctrl+C to copy",
3102
+ "copy-success": "Copied!",
3103
+ "copy-timeout": 5e3
3104
+ };
3105
+ var prefix = "data-prismjs-";
3106
+ for (var key in settings) {
3107
+ var attr = prefix + key;
3108
+ var element = startElement;
3109
+ while (element && !element.hasAttribute(attr)) {
3110
+ element = element.parentElement;
3111
+ }
3112
+ if (element) {
3113
+ settings[key] = element.getAttribute(attr);
3114
+ }
3115
+ }
3116
+ return settings;
3117
+ }
3118
+ Prism.plugins.toolbar.registerButton("copy-to-clipboard", function(env) {
3119
+ var element = env.element;
3120
+ var settings = getSettings(element);
3121
+ var linkCopy = document.createElement("button");
3122
+ linkCopy.className = "copy-to-clipboard-button";
3123
+ linkCopy.setAttribute("type", "button");
3124
+ var linkSpan = document.createElement("span");
3125
+ linkCopy.appendChild(linkSpan);
3126
+ setState("copy");
3127
+ registerClipboard(linkCopy, {
3128
+ getText: function() {
3129
+ return element.textContent;
3130
+ },
3131
+ success: function() {
3132
+ setState("copy-success");
3133
+ resetText();
3134
+ },
3135
+ error: function() {
3136
+ setState("copy-error");
3137
+ setTimeout(function() {
3138
+ selectElementText(element);
3139
+ }, 1);
3140
+ resetText();
3141
+ }
3142
+ });
3143
+ return linkCopy;
3144
+ function resetText() {
3145
+ setTimeout(function() {
3146
+ setState("copy");
3147
+ }, settings["copy-timeout"]);
3148
+ }
3149
+ function setState(state) {
3150
+ linkSpan.textContent = settings[state];
3151
+ linkCopy.setAttribute("data-copy-state", state);
3152
+ }
3153
+ });
3154
+ })();
3155
+ (function() {
3156
+ if (typeof Prism === "undefined") {
3157
+ return;
3158
+ }
3159
+ var LANGUAGE_REGEX = /^diff-([\w-]+)/i;
3160
+ var HTML_TAG = /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/g;
3161
+ var HTML_LINE = RegExp(/(?:__|[^\r\n<])*(?:\r\n?|\n|(?:__|[^\r\n<])(?![^\r\n]))/.source.replace(/__/g, function() {
3162
+ return HTML_TAG.source;
3163
+ }), "gi");
3164
+ var warningLogged = false;
3165
+ Prism.hooks.add("before-sanity-check", function(env) {
3166
+ var lang = env.language;
3167
+ if (LANGUAGE_REGEX.test(lang) && !env.grammar) {
3168
+ env.grammar = Prism.languages[lang] = Prism.languages.diff;
3169
+ }
3170
+ });
3171
+ Prism.hooks.add("before-tokenize", function(env) {
3172
+ if (!warningLogged && !Prism.languages.diff && !Prism.plugins.autoloader) {
3173
+ warningLogged = true;
3174
+ console.warn("Prism's Diff Highlight plugin requires the Diff language definition (prism-diff.js).Make sure the language definition is loaded or use Prism's Autoloader plugin.");
3175
+ }
3176
+ var lang = env.language;
3177
+ if (LANGUAGE_REGEX.test(lang) && !Prism.languages[lang]) {
3178
+ Prism.languages[lang] = Prism.languages.diff;
3179
+ }
3180
+ });
3181
+ Prism.hooks.add("wrap", function(env) {
3182
+ var diffLanguage;
3183
+ var diffGrammar;
3184
+ if (env.language !== "diff") {
3185
+ var langMatch = LANGUAGE_REGEX.exec(env.language);
3186
+ if (!langMatch) {
3187
+ return;
3188
+ }
3189
+ diffLanguage = langMatch[1];
3190
+ diffGrammar = Prism.languages[diffLanguage];
3191
+ }
3192
+ var PREFIXES = Prism.languages.diff && Prism.languages.diff.PREFIXES;
3193
+ if (PREFIXES && env.type in PREFIXES) {
3194
+ var content = env.content.replace(HTML_TAG, "");
3195
+ var decoded = content.replace(/&lt;/g, "<").replace(/&amp;/g, "&");
3196
+ var code = decoded.replace(/(^|[\r\n])./g, "$1");
3197
+ var highlighted;
3198
+ if (diffGrammar) {
3199
+ highlighted = Prism.highlight(code, diffGrammar, diffLanguage);
3200
+ } else {
3201
+ highlighted = Prism.util.encode(code);
3202
+ }
3203
+ var prefixToken = new Prism.Token("prefix", PREFIXES[env.type], [/\w+/.exec(env.type)[0]]);
3204
+ var prefix = Prism.Token.stringify(prefixToken, env.language);
3205
+ var lines = [];
3206
+ var m;
3207
+ HTML_LINE.lastIndex = 0;
3208
+ while (m = HTML_LINE.exec(highlighted)) {
3209
+ lines.push(prefix + m[0]);
3210
+ }
3211
+ if (/(?:^|[\r\n]).$/.test(decoded)) {
3212
+ lines.push(prefix);
3213
+ }
3214
+ env.content = lines.join("");
3215
+ if (diffGrammar) {
3216
+ env.classes.push("language-" + diffLanguage);
3217
+ }
3218
+ }
3219
+ });
3220
+ })();
3221
+ }
3222
+ });
3223
+
3224
+ // src/scripts/packages/ccm/ccm.js
3225
+ var import_prism = __toESM(require_prism());
3226
+
3227
+ // packages/core/src/scripts/util/outer-height-true.js
3228
+ var outerHeightTrue = (el) => {
3229
+ const rect = el.getBoundingClientRect();
3230
+ return rect.height;
3231
+ };
3232
+
3233
+ // src/scripts/get-window-height.js
3234
+ var getWindowHeight = () => {
3235
+ const vh = window.innerHeight * 0.01;
3236
+ document.querySelector("html").setAttribute("style", `--vh:${vh}px;`);
3237
+ const header = document.querySelector("header");
3238
+ const footer = document.querySelector("footer");
3239
+ if (!header || !footer) {
3240
+ return;
3241
+ }
3242
+ const mh = window.innerHeight - outerHeightTrue(header) - outerHeightTrue(footer);
3243
+ document.querySelector("main").setAttribute("style", `--mh:${mh}px;`);
3244
+ };
3245
+ getWindowHeight();
3246
+ window.onresize = getWindowHeight;
3247
+ })();
3248
+ /**
3249
+ * Prism: Lightweight, robust, elegant syntax highlighting
3250
+ *
3251
+ * @license MIT <https://opensource.org/licenses/MIT>
3252
+ * @author Lea Verou <https://lea.verou.me>
3253
+ * @namespace
3254
+ * @public
3255
+ */