Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
const prismjs = function(global, module, exports) {
2
// preserve the global if it has already been loaded
3
const oldprism = window.Prism;
4
window.Prism = { manual: true };
5
/// <reference lib="WebWorker"/>
6
 
7
var _self = (typeof window !== 'undefined')
8
    ? window   // if in browser
9
    : (
10
        (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
11
            ? self // if in worker
12
            : {}   // if in node js
13
    );
14
 
15
/**
16
 * Prism: Lightweight, robust, elegant syntax highlighting
17
 *
18
 * @license MIT <https://opensource.org/licenses/MIT>
19
 * @author Lea Verou <https://lea.verou.me>
20
 * @namespace
21
 * @public
22
 */
23
var Prism = (function (_self) {
24
 
25
    // Private helper vars
26
    var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
27
    var uniqueId = 0;
28
 
29
    // The grammar object for plaintext
30
    var plainTextGrammar = {};
31
 
32
 
33
    var _ = {
34
        /**
35
         * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
36
         * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
37
         * additional languages or plugins yourself.
38
         *
39
         * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
40
         *
41
         * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
42
         * empty Prism object into the global scope before loading the Prism script like this:
43
         *
44
         * ```js
45
         * window.Prism = window.Prism || {};
46
         * Prism.manual = true;
47
         * // add a new <script> to load Prism's script
48
         * ```
49
         *
50
         * @default false
51
         * @type {boolean}
52
         * @memberof Prism
53
         * @public
54
         */
55
        manual: _self.Prism && _self.Prism.manual,
56
        /**
57
         * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
58
         * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
59
         * own worker, you don't want it to do this.
60
         *
61
         * By setting this value to `true`, Prism will not add its own listeners to the worker.
62
         *
63
         * You obviously have to change this value before Prism executes. To do this, you can add an
64
         * empty Prism object into the global scope before loading the Prism script like this:
65
         *
66
         * ```js
67
         * window.Prism = window.Prism || {};
68
         * Prism.disableWorkerMessageHandler = true;
69
         * // Load Prism's script
70
         * ```
71
         *
72
         * @default false
73
         * @type {boolean}
74
         * @memberof Prism
75
         * @public
76
         */
77
        disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
78
 
79
        /**
80
         * A namespace for utility methods.
81
         *
82
         * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
83
         * change or disappear at any time.
84
         *
85
         * @namespace
86
         * @memberof Prism
87
         */
88
        util: {
89
            encode: function encode(tokens) {
90
                if (tokens instanceof Token) {
91
                    return new Token(tokens.type, encode(tokens.content), tokens.alias);
92
                } else if (Array.isArray(tokens)) {
93
                    return tokens.map(encode);
94
                } else {
95
                    return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
96
                }
97
            },
98
 
99
            /**
100
             * Returns the name of the type of the given value.
101
             *
102
             * @param {any} o
103
             * @returns {string}
104
             * @example
105
             * type(null)      === 'Null'
106
             * type(undefined) === 'Undefined'
107
             * type(123)       === 'Number'
108
             * type('foo')     === 'String'
109
             * type(true)      === 'Boolean'
110
             * type([1, 2])    === 'Array'
111
             * type({})        === 'Object'
112
             * type(String)    === 'Function'
113
             * type(/abc+/)    === 'RegExp'
114
             */
115
            type: function (o) {
116
                return Object.prototype.toString.call(o).slice(8, -1);
117
            },
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
            /**
133
             * Creates a deep clone of the given object.
134
             *
135
             * The main intended use of this function is to clone language definitions.
136
             *
137
             * @param {T} o
138
             * @param {Record<number, any>} [visited]
139
             * @returns {T}
140
             * @template T
141
             */
142
            clone: function deepClone(o, visited) {
143
                visited = visited || {};
144
 
145
                var clone; var id;
146
                switch (_.util.type(o)) {
147
                    case 'Object':
148
                        id = _.util.objId(o);
149
                        if (visited[id]) {
150
                            return visited[id];
151
                        }
152
                        clone = /** @type {Record<string, any>} */ ({});
153
                        visited[id] = clone;
154
 
155
                        for (var key in o) {
156
                            if (o.hasOwnProperty(key)) {
157
                                clone[key] = deepClone(o[key], visited);
158
                            }
159
                        }
160
 
161
                        return /** @type {any} */ (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
 
171
                        (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
172
                            clone[i] = deepClone(v, visited);
173
                        });
174
 
175
                        return /** @type {any} */ (clone);
176
 
177
                    default:
178
                        return o;
179
                }
180
            },
181
 
182
            /**
183
             * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
184
             *
185
             * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
186
             *
187
             * @param {Element} element
188
             * @returns {string}
189
             */
190
            getLanguage: function (element) {
191
                while (element) {
192
                    var m = lang.exec(element.className);
193
                    if (m) {
194
                        return m[1].toLowerCase();
195
                    }
196
                    element = element.parentElement;
197
                }
198
                return 'none';
199
            },
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
                // remove all `language-xxxx` classes
210
                // (this might leave behind a leading space)
211
                element.className = element.className.replace(RegExp(lang, 'gi'), '');
212
 
213
                // add the new `language-xxxx` class
214
                // (using `classList` will automatically clean up spaces for us)
215
                element.classList.add('language-' + language);
216
            },
217
 
218
            /**
219
             * Returns the script element that is currently executing.
220
             *
221
             * This does __not__ work for line script element.
222
             *
223
             * @returns {HTMLScriptElement | null}
224
             */
225
            currentScript: function () {
226
                if (typeof document === 'undefined') {
227
                    return null;
228
                }
229
                if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
230
                    return /** @type {any} */ (document.currentScript);
231
                }
232
 
233
                // IE11 workaround
234
                // we'll get the src of the current script by parsing IE11's error stack trace
235
                // this will not work for inline scripts
236
 
237
                try {
238
                    throw new Error();
239
                } catch (err) {
240
                    // Get file src url from stack. Specifically works with the format of stack traces in IE.
241
                    // A stack will look like this:
242
                    //
243
                    // Error
244
                    //    at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
245
                    //    at Global code (http://localhost/components/prism-core.js:606:1)
246
 
247
                    var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
248
                    if (src) {
249
                        var scripts = document.getElementsByTagName('script');
250
                        for (var i in scripts) {
251
                            if (scripts[i].src == src) {
252
                                return scripts[i];
253
                            }
254
                        }
255
                    }
256
                    return null;
257
                }
258
            },
259
 
260
            /**
261
             * Returns whether a given class is active for `element`.
262
             *
263
             * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
264
             * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
265
             * given class is just the given class with a `no-` prefix.
266
             *
267
             * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
268
             * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
269
             * ancestors have the given class or the negated version of it, then the default activation will be returned.
270
             *
271
             * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
272
             * version of it, the class is considered active.
273
             *
274
             * @param {Element} element
275
             * @param {string} className
276
             * @param {boolean} [defaultActivation=false]
277
             * @returns {boolean}
278
             */
279
            isActive: function (element, className, defaultActivation) {
280
                var no = 'no-' + className;
281
 
282
                while (element) {
283
                    var classList = element.classList;
284
                    if (classList.contains(className)) {
285
                        return true;
286
                    }
287
                    if (classList.contains(no)) {
288
                        return false;
289
                    }
290
                    element = element.parentElement;
291
                }
292
                return !!defaultActivation;
293
            }
294
        },
295
 
296
        /**
297
         * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
298
         *
299
         * @namespace
300
         * @memberof Prism
301
         * @public
302
         */
303
        languages: {
304
            /**
305
             * The grammar for plain, unformatted text.
306
             */
307
            plain: plainTextGrammar,
308
            plaintext: plainTextGrammar,
309
            text: plainTextGrammar,
310
            txt: plainTextGrammar,
311
 
312
            /**
313
             * Creates a deep copy of the language with the given id and appends the given tokens.
314
             *
315
             * If a token in `redef` also appears in the copied language, then the existing token in the copied language
316
             * will be overwritten at its original position.
317
             *
318
             * ## Best practices
319
             *
320
             * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
321
             * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
322
             * understand the language definition because, normally, the order of tokens matters in Prism grammars.
323
             *
324
             * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
325
             * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
326
             *
327
             * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
328
             * @param {Grammar} redef The new tokens to append.
329
             * @returns {Grammar} The new language created.
330
             * @public
331
             * @example
332
             * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
333
             *     // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
334
             *     // at its original position
335
             *     'comment': { ... },
336
             *     // CSS doesn't have a 'color' token, so this token will be appended
337
             *     'color': /\b(?:red|green|blue)\b/
338
             * });
339
             */
340
            extend: function (id, redef) {
341
                var lang = _.util.clone(_.languages[id]);
342
 
343
                for (var key in redef) {
344
                    lang[key] = redef[key];
345
                }
346
 
347
                return lang;
348
            },
349
 
350
            /**
351
             * Inserts tokens _before_ another token in a language definition or any other grammar.
352
             *
353
             * ## Usage
354
             *
355
             * This helper method makes it easy to modify existing languages. For example, the CSS language definition
356
             * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
357
             * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
358
             * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
359
             * this:
360
             *
361
             * ```js
362
             * Prism.languages.markup.style = {
363
             *     // token
364
             * };
365
             * ```
366
             *
367
             * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
368
             * before existing tokens. For the CSS example above, you would use it like this:
369
             *
370
             * ```js
371
             * Prism.languages.insertBefore('markup', 'cdata', {
372
             *     'style': {
373
             *         // token
374
             *     }
375
             * });
376
             * ```
377
             *
378
             * ## Special cases
379
             *
380
             * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
381
             * will be ignored.
382
             *
383
             * This behavior can be used to insert tokens after `before`:
384
             *
385
             * ```js
386
             * Prism.languages.insertBefore('markup', 'comment', {
387
             *     'comment': Prism.languages.markup.comment,
388
             *     // tokens after 'comment'
389
             * });
390
             * ```
391
             *
392
             * ## Limitations
393
             *
394
             * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
395
             * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
396
             * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
397
             * deleting properties which is necessary to insert at arbitrary positions.
398
             *
399
             * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
400
             * Instead, it will create a new object and replace all references to the target object with the new one. This
401
             * can be done without temporarily deleting properties, so the iteration order is well-defined.
402
             *
403
             * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
404
             * you hold the target object in a variable, then the value of the variable will not change.
405
             *
406
             * ```js
407
             * var oldMarkup = Prism.languages.markup;
408
             * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
409
             *
410
             * assert(oldMarkup !== Prism.languages.markup);
411
             * assert(newMarkup === Prism.languages.markup);
412
             * ```
413
             *
414
             * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
415
             * object to be modified.
416
             * @param {string} before The key to insert before.
417
             * @param {Grammar} insert An object containing the key-value pairs to be inserted.
418
             * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
419
             * object to be modified.
420
             *
421
             * Defaults to `Prism.languages`.
422
             * @returns {Grammar} The new grammar object.
423
             * @public
424
             */
425
            insertBefore: function (inside, before, insert, root) {
426
                root = root || /** @type {any} */ (_.languages);
427
                var grammar = root[inside];
428
                /** @type {Grammar} */
429
                var ret = {};
430
 
431
                for (var token in grammar) {
432
                    if (grammar.hasOwnProperty(token)) {
433
 
434
                        if (token == before) {
435
                            for (var newToken in insert) {
436
                                if (insert.hasOwnProperty(newToken)) {
437
                                    ret[newToken] = insert[newToken];
438
                                }
439
                            }
440
                        }
441
 
442
                        // Do not insert token which also occur in insert. See #1525
443
                        if (!insert.hasOwnProperty(token)) {
444
                            ret[token] = grammar[token];
445
                        }
446
                    }
447
                }
448
 
449
                var old = root[inside];
450
                root[inside] = ret;
451
 
452
                // Update references in other language definitions
453
                _.languages.DFS(_.languages, function (key, value) {
454
                    if (value === old && key != inside) {
455
                        this[key] = ret;
456
                    }
457
                });
458
 
459
                return ret;
460
            },
461
 
462
            // Traverse a language definition with Depth First Search
463
            DFS: function DFS(o, callback, type, visited) {
464
                visited = visited || {};
465
 
466
                var objId = _.util.objId;
467
 
468
                for (var i in o) {
469
                    if (o.hasOwnProperty(i)) {
470
                        callback.call(o, i, o[i], type || i);
471
 
472
                        var property = o[i];
473
                        var propertyType = _.util.type(property);
474
 
475
                        if (propertyType === 'Object' && !visited[objId(property)]) {
476
                            visited[objId(property)] = true;
477
                            DFS(property, callback, null, visited);
478
                        } else if (propertyType === 'Array' && !visited[objId(property)]) {
479
                            visited[objId(property)] = true;
480
                            DFS(property, callback, i, visited);
481
                        }
482
                    }
483
                }
484
            }
485
        },
486
 
487
        plugins: {},
488
 
489
        /**
490
         * This is the most high-level function in Prism’s API.
491
         * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
492
         * each one of them.
493
         *
494
         * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
495
         *
496
         * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
497
         * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
498
         * @memberof Prism
499
         * @public
500
         */
501
        highlightAll: function (async, callback) {
502
            _.highlightAllUnder(document, async, callback);
503
        },
504
 
505
        /**
506
         * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
507
         * {@link Prism.highlightElement} on each one of them.
508
         *
509
         * The following hooks will be run:
510
         * 1. `before-highlightall`
511
         * 2. `before-all-elements-highlight`
512
         * 3. All hooks of {@link Prism.highlightElement} for each element.
513
         *
514
         * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
515
         * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
516
         * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
517
         * @memberof Prism
518
         * @public
519
         */
520
        highlightAllUnder: function (container, async, callback) {
521
            var env = {
522
                callback: callback,
523
                container: container,
524
                selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
525
            };
526
 
527
            _.hooks.run('before-highlightall', env);
528
 
529
            env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
530
 
531
            _.hooks.run('before-all-elements-highlight', env);
532
 
533
            for (var i = 0, element; (element = env.elements[i++]);) {
534
                _.highlightElement(element, async === true, env.callback);
535
            }
536
        },
537
 
538
        /**
539
         * Highlights the code inside a single element.
540
         *
541
         * The following hooks will be run:
542
         * 1. `before-sanity-check`
543
         * 2. `before-highlight`
544
         * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
545
         * 4. `before-insert`
546
         * 5. `after-highlight`
547
         * 6. `complete`
548
         *
549
         * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
550
         * the element's language.
551
         *
552
         * @param {Element} element The element containing the code.
553
         * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
554
         * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
555
         * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
556
         * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
557
         *
558
         * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
559
         * asynchronous highlighting to work. You can build your own bundle on the
560
         * [Download page](https://prismjs.com/download.html).
561
         * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
562
         * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
563
         * @memberof Prism
564
         * @public
565
         */
566
        highlightElement: function (element, async, callback) {
567
            // Find language
568
            var language = _.util.getLanguage(element);
569
            var grammar = _.languages[language];
570
 
571
            // Set language on the element, if not present
572
            _.util.setLanguage(element, language);
573
 
574
            // Set language on the parent, for styling
575
            var parent = element.parentElement;
576
            if (parent && parent.nodeName.toLowerCase() === 'pre') {
577
                _.util.setLanguage(parent, language);
578
            }
579
 
580
            var code = element.textContent;
581
 
582
            var env = {
583
                element: element,
584
                language: language,
585
                grammar: grammar,
586
                code: code
587
            };
588
 
589
            function insertHighlightedCode(highlightedCode) {
590
                env.highlightedCode = highlightedCode;
591
 
592
                _.hooks.run('before-insert', env);
593
 
594
                env.element.innerHTML = env.highlightedCode;
595
 
596
                _.hooks.run('after-highlight', env);
597
                _.hooks.run('complete', env);
598
                callback && callback.call(env.element);
599
            }
600
 
601
            _.hooks.run('before-sanity-check', env);
602
 
603
            // plugins may change/add the parent/element
604
            parent = env.element.parentElement;
605
            if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
606
                parent.setAttribute('tabindex', '0');
607
            }
608
 
609
            if (!env.code) {
610
                _.hooks.run('complete', env);
611
                callback && callback.call(env.element);
612
                return;
613
            }
614
 
615
            _.hooks.run('before-highlight', env);
616
 
617
            if (!env.grammar) {
618
                insertHighlightedCode(_.util.encode(env.code));
619
                return;
620
            }
621
 
622
            if (async && _self.Worker) {
623
                var worker = new Worker(_.filename);
624
 
625
                worker.onmessage = function (evt) {
626
                    insertHighlightedCode(evt.data);
627
                };
628
 
629
                worker.postMessage(JSON.stringify({
630
                    language: env.language,
631
                    code: env.code,
632
                    immediateClose: true
633
                }));
634
            } else {
635
                insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
636
            }
637
        },
638
 
639
        /**
640
         * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
641
         * and the language definitions to use, and returns a string with the HTML produced.
642
         *
643
         * The following hooks will be run:
644
         * 1. `before-tokenize`
645
         * 2. `after-tokenize`
646
         * 3. `wrap`: On each {@link Token}.
647
         *
648
         * @param {string} text A string with the code to be highlighted.
649
         * @param {Grammar} grammar An object containing the tokens to use.
650
         *
651
         * Usually a language definition like `Prism.languages.markup`.
652
         * @param {string} language The name of the language definition passed to `grammar`.
653
         * @returns {string} The highlighted HTML.
654
         * @memberof Prism
655
         * @public
656
         * @example
657
         * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
658
         */
659
        highlight: function (text, grammar, language) {
660
            var env = {
661
                code: text,
662
                grammar: grammar,
663
                language: language
664
            };
665
            _.hooks.run('before-tokenize', env);
666
            if (!env.grammar) {
667
                throw new Error('The language "' + env.language + '" has no grammar.');
668
            }
669
            env.tokens = _.tokenize(env.code, env.grammar);
670
            _.hooks.run('after-tokenize', env);
671
            return Token.stringify(_.util.encode(env.tokens), env.language);
672
        },
673
 
674
        /**
675
         * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
676
         * and the language definitions to use, and returns an array with the tokenized code.
677
         *
678
         * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
679
         *
680
         * This method could be useful in other contexts as well, as a very crude parser.
681
         *
682
         * @param {string} text A string with the code to be highlighted.
683
         * @param {Grammar} grammar An object containing the tokens to use.
684
         *
685
         * Usually a language definition like `Prism.languages.markup`.
686
         * @returns {TokenStream} An array of strings and tokens, a token stream.
687
         * @memberof Prism
688
         * @public
689
         * @example
690
         * let code = `var foo = 0;`;
691
         * let tokens = Prism.tokenize(code, Prism.languages.javascript);
692
         * tokens.forEach(token => {
693
         *     if (token instanceof Prism.Token && token.type === 'number') {
694
         *         console.log(`Found numeric literal: ${token.content}`);
695
         *     }
696
         * });
697
         */
698
        tokenize: function (text, grammar) {
699
            var rest = grammar.rest;
700
            if (rest) {
701
                for (var token in rest) {
702
                    grammar[token] = rest[token];
703
                }
704
 
705
                delete grammar.rest;
706
            }
707
 
708
            var tokenList = new LinkedList();
709
            addAfter(tokenList, tokenList.head, text);
710
 
711
            matchGrammar(text, tokenList, grammar, tokenList.head, 0);
712
 
713
            return toArray(tokenList);
714
        },
715
 
716
        /**
717
         * @namespace
718
         * @memberof Prism
719
         * @public
720
         */
721
        hooks: {
722
            all: {},
723
 
724
            /**
725
             * Adds the given callback to the list of callbacks for the given hook.
726
             *
727
             * The callback will be invoked when the hook it is registered for is run.
728
             * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
729
             *
730
             * One callback function can be registered to multiple hooks and the same hook multiple times.
731
             *
732
             * @param {string} name The name of the hook.
733
             * @param {HookCallback} callback The callback function which is given environment variables.
734
             * @public
735
             */
736
            add: function (name, callback) {
737
                var hooks = _.hooks.all;
738
 
739
                hooks[name] = hooks[name] || [];
740
 
741
                hooks[name].push(callback);
742
            },
743
 
744
            /**
745
             * Runs a hook invoking all registered callbacks with the given environment variables.
746
             *
747
             * Callbacks will be invoked synchronously and in the order in which they were registered.
748
             *
749
             * @param {string} name The name of the hook.
750
             * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
751
             * @public
752
             */
753
            run: function (name, env) {
754
                var callbacks = _.hooks.all[name];
755
 
756
                if (!callbacks || !callbacks.length) {
757
                    return;
758
                }
759
 
760
                for (var i = 0, callback; (callback = callbacks[i++]);) {
761
                    callback(env);
762
                }
763
            }
764
        },
765
 
766
        Token: Token
767
    };
768
    _self.Prism = _;
769
 
770
 
771
    // Typescript note:
772
    // The following can be used to import the Token type in JSDoc:
773
    //
774
    //   @typedef {InstanceType<import("./prism-core")["Token"]>} Token
775
 
776
    /**
777
     * Creates a new token.
778
     *
779
     * @param {string} type See {@link Token#type type}
780
     * @param {string | TokenStream} content See {@link Token#content content}
781
     * @param {string|string[]} [alias] The alias(es) of the token.
782
     * @param {string} [matchedStr=""] A copy of the full string this token was created from.
783
     * @class
784
     * @global
785
     * @public
786
     */
787
    function Token(type, content, alias, matchedStr) {
788
        /**
789
         * The type of the token.
790
         *
791
         * This is usually the key of a pattern in a {@link Grammar}.
792
         *
793
         * @type {string}
794
         * @see GrammarToken
795
         * @public
796
         */
797
        this.type = type;
798
        /**
799
         * The strings or tokens contained by this token.
800
         *
801
         * This will be a token stream if the pattern matched also defined an `inside` grammar.
802
         *
803
         * @type {string | TokenStream}
804
         * @public
805
         */
806
        this.content = content;
807
        /**
808
         * The alias(es) of the token.
809
         *
810
         * @type {string|string[]}
811
         * @see GrammarToken
812
         * @public
813
         */
814
        this.alias = alias;
815
        // Copy of the full string this token was created from
816
        this.length = (matchedStr || '').length | 0;
817
    }
818
 
819
    /**
820
     * A token stream is an array of strings and {@link Token Token} objects.
821
     *
822
     * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
823
     * them.
824
     *
825
     * 1. No adjacent strings.
826
     * 2. No empty strings.
827
     *
828
     *    The only exception here is the token stream that only contains the empty string and nothing else.
829
     *
830
     * @typedef {Array<string | Token>} TokenStream
831
     * @global
832
     * @public
833
     */
834
 
835
    /**
836
     * Converts the given token or token stream to an HTML representation.
837
     *
838
     * The following hooks will be run:
839
     * 1. `wrap`: On each {@link Token}.
840
     *
841
     * @param {string | Token | TokenStream} o The token or token stream to be converted.
842
     * @param {string} language The name of current language.
843
     * @returns {string} The HTML representation of the token or token stream.
844
     * @memberof Token
845
     * @static
846
     */
847
    Token.stringify = function stringify(o, language) {
848
        if (typeof o == 'string') {
849
            return o;
850
        }
851
        if (Array.isArray(o)) {
852
            var s = '';
853
            o.forEach(function (e) {
854
                s += stringify(e, language);
855
            });
856
            return s;
857
        }
858
 
859
        var env = {
860
            type: o.type,
861
            content: stringify(o.content, language),
862
            tag: 'span',
863
            classes: ['token', o.type],
864
            attributes: {},
865
            language: language
866
        };
867
 
868
        var aliases = o.alias;
869
        if (aliases) {
870
            if (Array.isArray(aliases)) {
871
                Array.prototype.push.apply(env.classes, aliases);
872
            } else {
873
                env.classes.push(aliases);
874
            }
875
        }
876
 
877
        _.hooks.run('wrap', env);
878
 
879
        var attributes = '';
880
        for (var name in env.attributes) {
881
            attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
882
        }
883
 
884
        return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
885
    };
886
 
887
    /**
888
     * @param {RegExp} pattern
889
     * @param {number} pos
890
     * @param {string} text
891
     * @param {boolean} lookbehind
892
     * @returns {RegExpExecArray | null}
893
     */
894
    function matchPattern(pattern, pos, text, lookbehind) {
895
        pattern.lastIndex = pos;
896
        var match = pattern.exec(text);
897
        if (match && lookbehind && match[1]) {
898
            // change the match to remove the text matched by the Prism lookbehind group
899
            var lookbehindLength = match[1].length;
900
            match.index += lookbehindLength;
901
            match[0] = match[0].slice(lookbehindLength);
902
        }
903
        return match;
904
    }
905
 
906
    /**
907
     * @param {string} text
908
     * @param {LinkedList<string | Token>} tokenList
909
     * @param {any} grammar
910
     * @param {LinkedListNode<string | Token>} startNode
911
     * @param {number} startPos
912
     * @param {RematchOptions} [rematch]
913
     * @returns {void}
914
     * @private
915
     *
916
     * @typedef RematchOptions
917
     * @property {string} cause
918
     * @property {number} reach
919
     */
920
    function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
921
        for (var token in grammar) {
922
            if (!grammar.hasOwnProperty(token) || !grammar[token]) {
923
                continue;
924
            }
925
 
926
            var patterns = grammar[token];
927
            patterns = Array.isArray(patterns) ? patterns : [patterns];
928
 
929
            for (var j = 0; j < patterns.length; ++j) {
930
                if (rematch && rematch.cause == token + ',' + j) {
931
                    return;
932
                }
933
 
934
                var patternObj = patterns[j];
935
                var inside = patternObj.inside;
936
                var lookbehind = !!patternObj.lookbehind;
937
                var greedy = !!patternObj.greedy;
938
                var alias = patternObj.alias;
939
 
940
                if (greedy && !patternObj.pattern.global) {
941
                    // Without the global flag, lastIndex won't work
942
                    var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
943
                    patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
944
                }
945
 
946
                /** @type {RegExp} */
947
                var pattern = patternObj.pattern || patternObj;
948
 
949
                for ( // iterate the token list and keep track of the current token/string position
950
                    var currentNode = startNode.next, pos = startPos;
951
                    currentNode !== tokenList.tail;
952
                    pos += currentNode.value.length, currentNode = currentNode.next
953
                ) {
954
 
955
                    if (rematch && pos >= rematch.reach) {
956
                        break;
957
                    }
958
 
959
                    var str = currentNode.value;
960
 
961
                    if (tokenList.length > text.length) {
962
                        // Something went terribly wrong, ABORT, ABORT!
963
                        return;
964
                    }
965
 
966
                    if (str instanceof Token) {
967
                        continue;
968
                    }
969
 
970
                    var removeCount = 1; // this is the to parameter of removeBetween
971
                    var match;
972
 
973
                    if (greedy) {
974
                        match = matchPattern(pattern, pos, text, lookbehind);
975
                        if (!match || match.index >= text.length) {
976
                            break;
977
                        }
978
 
979
                        var from = match.index;
980
                        var to = match.index + match[0].length;
981
                        var p = pos;
982
 
983
                        // find the node that contains the match
984
                        p += currentNode.value.length;
985
                        while (from >= p) {
986
                            currentNode = currentNode.next;
987
                            p += currentNode.value.length;
988
                        }
989
                        // adjust pos (and p)
990
                        p -= currentNode.value.length;
991
                        pos = p;
992
 
993
                        // the current node is a Token, then the match starts inside another Token, which is invalid
994
                        if (currentNode.value instanceof Token) {
995
                            continue;
996
                        }
997
 
998
                        // find the last node which is affected by this match
999
                        for (
1000
                            var k = currentNode;
1001
                            k !== tokenList.tail && (p < to || typeof k.value === 'string');
1002
                            k = k.next
1003
                        ) {
1004
                            removeCount++;
1005
                            p += k.value.length;
1006
                        }
1007
                        removeCount--;
1008
 
1009
                        // replace with the new match
1010
                        str = text.slice(pos, p);
1011
                        match.index -= pos;
1012
                    } else {
1013
                        match = matchPattern(pattern, 0, str, lookbehind);
1014
                        if (!match) {
1015
                            continue;
1016
                        }
1017
                    }
1018
 
1019
                    // eslint-disable-next-line no-redeclare
1020
                    var from = match.index;
1021
                    var matchStr = match[0];
1022
                    var before = str.slice(0, from);
1023
                    var after = str.slice(from + matchStr.length);
1024
 
1025
                    var reach = pos + str.length;
1026
                    if (rematch && reach > rematch.reach) {
1027
                        rematch.reach = reach;
1028
                    }
1029
 
1030
                    var removeFrom = currentNode.prev;
1031
 
1032
                    if (before) {
1033
                        removeFrom = addAfter(tokenList, removeFrom, before);
1034
                        pos += before.length;
1035
                    }
1036
 
1037
                    removeRange(tokenList, removeFrom, removeCount);
1038
 
1039
                    var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1040
                    currentNode = addAfter(tokenList, removeFrom, wrapped);
1041
 
1042
                    if (after) {
1043
                        addAfter(tokenList, currentNode, after);
1044
                    }
1045
 
1046
                    if (removeCount > 1) {
1047
                        // at least one Token object was removed, so we have to do some rematching
1048
                        // this can only happen if the current pattern is greedy
1049
 
1050
                        /** @type {RematchOptions} */
1051
                        var nestedRematch = {
1052
                            cause: token + ',' + j,
1053
                            reach: reach
1054
                        };
1055
                        matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1056
 
1057
                        // the reach might have been extended because of the rematching
1058
                        if (rematch && nestedRematch.reach > rematch.reach) {
1059
                            rematch.reach = nestedRematch.reach;
1060
                        }
1061
                    }
1062
                }
1063
            }
1064
        }
1065
    }
1066
 
1067
    /**
1068
     * @typedef LinkedListNode
1069
     * @property {T} value
1070
     * @property {LinkedListNode<T> | null} prev The previous node.
1071
     * @property {LinkedListNode<T> | null} next The next node.
1072
     * @template T
1073
     * @private
1074
     */
1075
 
1076
    /**
1077
     * @template T
1078
     * @private
1079
     */
1080
    function LinkedList() {
1081
        /** @type {LinkedListNode<T>} */
1082
        var head = { value: null, prev: null, next: null };
1083
        /** @type {LinkedListNode<T>} */
1084
        var tail = { value: null, prev: head, next: null };
1085
        head.next = tail;
1086
 
1087
        /** @type {LinkedListNode<T>} */
1088
        this.head = head;
1089
        /** @type {LinkedListNode<T>} */
1090
        this.tail = tail;
1091
        this.length = 0;
1092
    }
1093
 
1094
    /**
1095
     * Adds a new node with the given value to the list.
1096
     *
1097
     * @param {LinkedList<T>} list
1098
     * @param {LinkedListNode<T>} node
1099
     * @param {T} value
1100
     * @returns {LinkedListNode<T>} The added node.
1101
     * @template T
1102
     */
1103
    function addAfter(list, node, value) {
1104
        // assumes that node != list.tail && values.length >= 0
1105
        var next = node.next;
1106
 
1107
        var newNode = { value: value, prev: node, next: next };
1108
        node.next = newNode;
1109
        next.prev = newNode;
1110
        list.length++;
1111
 
1112
        return newNode;
1113
    }
1114
    /**
1115
     * Removes `count` nodes after the given node. The given node will not be removed.
1116
     *
1117
     * @param {LinkedList<T>} list
1118
     * @param {LinkedListNode<T>} node
1119
     * @param {number} count
1120
     * @template T
1121
     */
1122
    function removeRange(list, node, count) {
1123
        var next = node.next;
1124
        for (var i = 0; i < count && next !== list.tail; i++) {
1125
            next = next.next;
1126
        }
1127
        node.next = next;
1128
        next.prev = node;
1129
        list.length -= i;
1130
    }
1131
    /**
1132
     * @param {LinkedList<T>} list
1133
     * @returns {T[]}
1134
     * @template T
1135
     */
1136
    function toArray(list) {
1137
        var array = [];
1138
        var node = list.head.next;
1139
        while (node !== list.tail) {
1140
            array.push(node.value);
1141
            node = node.next;
1142
        }
1143
        return array;
1144
    }
1145
 
1146
 
1147
    if (!_self.document) {
1148
        if (!_self.addEventListener) {
1149
            // in Node.js
1150
            return _;
1151
        }
1152
 
1153
        if (!_.disableWorkerMessageHandler) {
1154
            // In worker
1155
            _self.addEventListener('message', function (evt) {
1156
                var message = JSON.parse(evt.data);
1157
                var lang = message.language;
1158
                var code = message.code;
1159
                var immediateClose = message.immediateClose;
1160
 
1161
                _self.postMessage(_.highlight(code, _.languages[lang], lang));
1162
                if (immediateClose) {
1163
                    _self.close();
1164
                }
1165
            }, false);
1166
        }
1167
 
1168
        return _;
1169
    }
1170
 
1171
    // Get current script and highlight
1172
    var script = _.util.currentScript();
1173
 
1174
    if (script) {
1175
        _.filename = script.src;
1176
 
1177
        if (script.hasAttribute('data-manual')) {
1178
            _.manual = true;
1179
        }
1180
    }
1181
 
1182
    function highlightAutomaticallyCallback() {
1183
        if (!_.manual) {
1184
            _.highlightAll();
1185
        }
1186
    }
1187
 
1188
    if (!_.manual) {
1189
        // If the document state is "loading", then we'll use DOMContentLoaded.
1190
        // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1191
        // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1192
        // might take longer one animation frame to execute which can create a race condition where only some plugins have
1193
        // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1194
        // See https://github.com/PrismJS/prism/issues/2102
1195
        var readyState = document.readyState;
1196
        if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1197
            document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1198
        } else {
1199
            if (window.requestAnimationFrame) {
1200
                window.requestAnimationFrame(highlightAutomaticallyCallback);
1201
            } else {
1202
                window.setTimeout(highlightAutomaticallyCallback, 16);
1203
            }
1204
        }
1205
    }
1206
 
1207
    return _;
1208
 
1209
}(_self));
1210
 
1211
if (typeof module !== 'undefined' && module.exports) {
1212
    module.exports = Prism;
1213
}
1214
 
1215
// hack for components to work correctly in node.js
1216
if (typeof global !== 'undefined') {
1217
    global.Prism = Prism;
1218
}
1219
 
1220
// some additional documentation/types
1221
 
1222
/**
1223
 * The expansion of a simple `RegExp` literal to support additional properties.
1224
 *
1225
 * @typedef GrammarToken
1226
 * @property {RegExp} pattern The regular expression of the token.
1227
 * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1228
 * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1229
 * @property {boolean} [greedy=false] Whether the token is greedy.
1230
 * @property {string|string[]} [alias] An optional alias or list of aliases.
1231
 * @property {Grammar} [inside] The nested grammar of this token.
1232
 *
1233
 * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1234
 *
1235
 * This can be used to make nested and even recursive language definitions.
1236
 *
1237
 * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1238
 * each another.
1239
 * @global
1240
 * @public
1241
 */
1242
 
1243
/**
1244
 * @typedef Grammar
1245
 * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1246
 * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1247
 * @global
1248
 * @public
1249
 */
1250
 
1251
/**
1252
 * A function which will invoked after an element was successfully highlighted.
1253
 *
1254
 * @callback HighlightCallback
1255
 * @param {Element} element The element successfully highlighted.
1256
 * @returns {void}
1257
 * @global
1258
 * @public
1259
 */
1260
 
1261
/**
1262
 * @callback HookCallback
1263
 * @param {Object<string, any>} env The environment variables of the hook.
1264
 * @returns {void}
1265
 * @global
1266
 * @public
1267
 */
1268
 
1269
Prism.languages.clike = {
1270
    'comment': [
1271
        {
1272
            pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1273
            lookbehind: true,
1274
            greedy: true
1275
        },
1276
        {
1277
            pattern: /(^|[^\\:])\/\/.*/,
1278
            lookbehind: true,
1279
            greedy: true
1280
        }
1281
    ],
1282
    'string': {
1283
        pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1284
        greedy: true
1285
    },
1286
    'class-name': {
1287
        pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1288
        lookbehind: true,
1289
        inside: {
1290
            'punctuation': /[.\\]/
1291
        }
1292
    },
1293
    'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1294
    'boolean': /\b(?:false|true)\b/,
1295
    'function': /\b\w+(?=\()/,
1296
    'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1297
    'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1298
    'punctuation': /[{}[\];(),.:]/
1299
};
1300
 
1301
(function (Prism) {
1302
 
1303
    /**
1304
     * Returns the placeholder for the given language id and index.
1305
     *
1306
     * @param {string} language
1307
     * @param {string|number} index
1308
     * @returns {string}
1309
     */
1310
    function getPlaceholder(language, index) {
1311
        return '___' + language.toUpperCase() + index + '___';
1312
    }
1313
 
1314
    Object.defineProperties(Prism.languages['markup-templating'] = {}, {
1315
        buildPlaceholders: {
1316
            /**
1317
             * Tokenize all inline templating expressions matching `placeholderPattern`.
1318
             *
1319
             * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
1320
             * `true` will be replaced.
1321
             *
1322
             * @param {object} env The environment of the `before-tokenize` hook.
1323
             * @param {string} language The language id.
1324
             * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
1325
             * @param {(match: string) => boolean} [replaceFilter]
1326
             */
1327
            value: function (env, language, placeholderPattern, replaceFilter) {
1328
                if (env.language !== language) {
1329
                    return;
1330
                }
1331
 
1332
                var tokenStack = env.tokenStack = [];
1333
 
1334
                env.code = env.code.replace(placeholderPattern, function (match) {
1335
                    if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
1336
                        return match;
1337
                    }
1338
                    var i = tokenStack.length;
1339
                    var placeholder;
1340
 
1341
                    // Check for existing strings
1342
                    while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
1343
                        ++i;
1344
                    }
1345
 
1346
                    // Create a sparse array
1347
                    tokenStack[i] = match;
1348
 
1349
                    return placeholder;
1350
                });
1351
 
1352
                // Switch the grammar to markup
1353
                env.grammar = Prism.languages.markup;
1354
            }
1355
        },
1356
        tokenizePlaceholders: {
1357
            /**
1358
             * Replace placeholders with proper tokens after tokenizing.
1359
             *
1360
             * @param {object} env The environment of the `after-tokenize` hook.
1361
             * @param {string} language The language id.
1362
             */
1363
            value: function (env, language) {
1364
                if (env.language !== language || !env.tokenStack) {
1365
                    return;
1366
                }
1367
 
1368
                // Switch the grammar back
1369
                env.grammar = Prism.languages[language];
1370
 
1371
                var j = 0;
1372
                var keys = Object.keys(env.tokenStack);
1373
 
1374
                function walkTokens(tokens) {
1375
                    for (var i = 0; i < tokens.length; i++) {
1376
                        // all placeholders are replaced already
1377
                        if (j >= keys.length) {
1378
                            break;
1379
                        }
1380
 
1381
                        var token = tokens[i];
1382
                        if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
1383
                            var k = keys[j];
1384
                            var t = env.tokenStack[k];
1385
                            var s = typeof token === 'string' ? token : token.content;
1386
                            var placeholder = getPlaceholder(language, k);
1387
 
1388
                            var index = s.indexOf(placeholder);
1389
                            if (index > -1) {
1390
                                ++j;
1391
 
1392
                                var before = s.substring(0, index);
1393
                                var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
1394
                                var after = s.substring(index + placeholder.length);
1395
 
1396
                                var replacement = [];
1397
                                if (before) {
1398
                                    replacement.push.apply(replacement, walkTokens([before]));
1399
                                }
1400
                                replacement.push(middle);
1401
                                if (after) {
1402
                                    replacement.push.apply(replacement, walkTokens([after]));
1403
                                }
1404
 
1405
                                if (typeof token === 'string') {
1406
                                    tokens.splice.apply(tokens, [i, 1].concat(replacement));
1407
                                } else {
1408
                                    token.content = replacement;
1409
                                }
1410
                            }
1411
                        } else if (token.content /* && typeof token.content !== 'string' */) {
1412
                            walkTokens(token.content);
1413
                        }
1414
                    }
1415
 
1416
                    return tokens;
1417
                }
1418
 
1419
                walkTokens(env.tokens);
1420
            }
1421
        }
1422
    });
1423
 
1424
}(Prism));
1425
 
1426
Prism.languages.c = Prism.languages.extend('clike', {
1427
    'comment': {
1428
        pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
1429
        greedy: true
1430
    },
1431
    'string': {
1432
        // https://en.cppreference.com/w/c/language/string_literal
1433
        pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
1434
        greedy: true
1435
    },
1436
    'class-name': {
1437
        pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
1438
        lookbehind: true
1439
    },
1440
    'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
1441
    'function': /\b[a-z_]\w*(?=\s*\()/i,
1442
    'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
1443
    'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
1444
});
1445
 
1446
Prism.languages.insertBefore('c', 'string', {
1447
    'char': {
1448
        // https://en.cppreference.com/w/c/language/character_constant
1449
        pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
1450
        greedy: true
1451
    }
1452
});
1453
 
1454
Prism.languages.insertBefore('c', 'string', {
1455
    'macro': {
1456
        // allow for multiline macro definitions
1457
        // spaces after the # character compile fine with gcc
1458
        pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
1459
        lookbehind: true,
1460
        greedy: true,
1461
        alias: 'property',
1462
        inside: {
1463
            'string': [
1464
                {
1465
                    // highlight the path of the include statement as a string
1466
                    pattern: /^(#\s*include\s*)<[^>]+>/,
1467
                    lookbehind: true
1468
                },
1469
                Prism.languages.c['string']
1470
            ],
1471
            'char': Prism.languages.c['char'],
1472
            'comment': Prism.languages.c['comment'],
1473
            'macro-name': [
1474
                {
1475
                    pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
1476
                    lookbehind: true
1477
                },
1478
                {
1479
                    pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
1480
                    lookbehind: true,
1481
                    alias: 'function'
1482
                }
1483
            ],
1484
            // highlight macro directives as keywords
1485
            'directive': {
1486
                pattern: /^(#\s*)[a-z]+/,
1487
                lookbehind: true,
1488
                alias: 'keyword'
1489
            },
1490
            'directive-hash': /^#/,
1491
            'punctuation': /##|\\(?=[\r\n])/,
1492
            'expression': {
1493
                pattern: /\S[\s\S]*/,
1494
                inside: Prism.languages.c
1495
            }
1496
        }
1497
    }
1498
});
1499
 
1500
Prism.languages.insertBefore('c', 'function', {
1501
    // highlight predefined macros as constants
1502
    'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
1503
});
1504
 
1505
delete Prism.languages.c['boolean'];
1506
 
1507
(function (Prism) {
1508
 
1509
    var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
1510
    var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; });
1511
 
1512
    Prism.languages.cpp = Prism.languages.extend('c', {
1513
        'class-name': [
1514
            {
1515
                pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
1516
                    .replace(/<keyword>/g, function () { return keyword.source; })),
1517
                lookbehind: true
1518
            },
1519
            // This is intended to capture the class name of method implementations like:
1520
            //   void foo::bar() const {}
1521
            // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
1522
            // it starts with an uppercase letter. This approximation should give decent results.
1523
            /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
1524
            // This will capture the class name before destructors like:
1525
            //   Foo::~Foo() {}
1526
            /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
1527
            // This also intends to capture the class name of method implementations but here the class has template
1528
            // parameters, so it can't be a namespace (until C++ adds generic namespaces).
1529
            /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
1530
        ],
1531
        'keyword': keyword,
1532
        'number': {
1533
            pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
1534
            greedy: true
1535
        },
1536
        'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
1537
        'boolean': /\b(?:false|true)\b/
1538
    });
1539
 
1540
    Prism.languages.insertBefore('cpp', 'string', {
1541
        'module': {
1542
            // https://en.cppreference.com/w/cpp/language/modules
1543
            pattern: RegExp(
1544
                /(\b(?:import|module)\s+)/.source +
1545
                '(?:' +
1546
                // header-name
1547
                /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source +
1548
                '|' +
1549
                // module name or partition or both
1550
                /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () { return modName; }) +
1551
                ')'
1552
            ),
1553
            lookbehind: true,
1554
            greedy: true,
1555
            inside: {
1556
                'string': /^[<"][\s\S]+/,
1557
                'operator': /:/,
1558
                'punctuation': /\./
1559
            }
1560
        },
1561
        'raw-string': {
1562
            pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
1563
            alias: 'string',
1564
            greedy: true
1565
        }
1566
    });
1567
 
1568
    Prism.languages.insertBefore('cpp', 'keyword', {
1569
        'generic-function': {
1570
            pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
1571
            inside: {
1572
                'function': /^\w+/,
1573
                'generic': {
1574
                    pattern: /<[\s\S]+/,
1575
                    alias: 'class-name',
1576
                    inside: Prism.languages.cpp
1577
                }
1578
            }
1579
        }
1580
    });
1581
 
1582
    Prism.languages.insertBefore('cpp', 'operator', {
1583
        'double-colon': {
1584
            pattern: /::/,
1585
            alias: 'punctuation'
1586
        }
1587
    });
1588
 
1589
    Prism.languages.insertBefore('cpp', 'class-name', {
1590
        // the base clause is an optional list of parent classes
1591
        // https://en.cppreference.com/w/cpp/language/class
1592
        'base-clause': {
1593
            pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
1594
            lookbehind: true,
1595
            greedy: true,
1596
            inside: Prism.languages.extend('cpp', {})
1597
        }
1598
    });
1599
 
1600
    Prism.languages.insertBefore('inside', 'double-colon', {
1601
        // All untokenized words that are not namespaces should be class names
1602
        'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
1603
    }, Prism.languages.cpp['base-clause']);
1604
 
1605
}(Prism));
1606
 
1607
(function (Prism) {
1608
 
1609
    /**
1610
     * Replaces all placeholders "<<n>>" of given pattern with the n-th replacement (zero based).
1611
     *
1612
     * Note: This is a simple text based replacement. Be careful when using backreferences!
1613
     *
1614
     * @param {string} pattern the given pattern.
1615
     * @param {string[]} replacements a list of replacement which can be inserted into the given pattern.
1616
     * @returns {string} the pattern with all placeholders replaced with their corresponding replacements.
1617
     * @example replace(/a<<0>>a/.source, [/b+/.source]) === /a(?:b+)a/.source
1618
     */
1619
    function replace(pattern, replacements) {
1620
        return pattern.replace(/<<(\d+)>>/g, function (m, index) {
1621
            return '(?:' + replacements[+index] + ')';
1622
        });
1623
    }
1624
    /**
1625
     * @param {string} pattern
1626
     * @param {string[]} replacements
1627
     * @param {string} [flags]
1628
     * @returns {RegExp}
1629
     */
1630
    function re(pattern, replacements, flags) {
1631
        return RegExp(replace(pattern, replacements), flags || '');
1632
    }
1633
 
1634
    /**
1635
     * Creates a nested pattern where all occurrences of the string `<<self>>` are replaced with the pattern itself.
1636
     *
1637
     * @param {string} pattern
1638
     * @param {number} depthLog2
1639
     * @returns {string}
1640
     */
1641
    function nested(pattern, depthLog2) {
1642
        for (var i = 0; i < depthLog2; i++) {
1643
            pattern = pattern.replace(/<<self>>/g, function () { return '(?:' + pattern + ')'; });
1644
        }
1645
        return pattern.replace(/<<self>>/g, '[^\\s\\S]');
1646
    }
1647
 
1648
    // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
1649
    var keywordKinds = {
1650
        // keywords which represent a return or variable type
1651
        type: 'bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void',
1652
        // keywords which are used to declare a type
1653
        typeDeclaration: 'class enum interface record struct',
1654
        // contextual keywords
1655
        // ("var" and "dynamic" are missing because they are used like types)
1656
        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*{)',
1657
        // all other keywords
1658
        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'
1659
    };
1660
 
1661
    // keywords
1662
    function keywordsToPattern(words) {
1663
        return '\\b(?:' + words.trim().replace(/ /g, '|') + ')\\b';
1664
    }
1665
    var typeDeclarationKeywords = keywordsToPattern(keywordKinds.typeDeclaration);
1666
    var keywords = RegExp(keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other));
1667
    var nonTypeKeywords = keywordsToPattern(keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other);
1668
    var nonContextualKeywords = keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.other);
1669
 
1670
    // types
1671
    var generic = nested(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source, 2); // the idea behind the other forbidden characters is to prevent false positives. Same for tupleElement.
1672
    var nestedRound = nested(/\((?:[^()]|<<self>>)*\)/.source, 2);
1673
    var name = /@?\b[A-Za-z_]\w*\b/.source;
1674
    var genericName = replace(/<<0>>(?:\s*<<1>>)?/.source, [name, generic]);
1675
    var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [nonTypeKeywords, genericName]);
1676
    var array = /\[\s*(?:,\s*)*\]/.source;
1677
    var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [identifier, array]);
1678
    var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [generic, nestedRound, array]);
1679
    var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
1680
    var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [tuple, identifier, array]);
1681
 
1682
    var typeInside = {
1683
        'keyword': keywords,
1684
        'punctuation': /[<>()?,.:[\]]/
1685
    };
1686
 
1687
    // strings & characters
1688
    // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#character-literals
1689
    // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#string-literals
1690
    var character = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source; // simplified pattern
1691
    var regularString = /"(?:\\.|[^\\"\r\n])*"/.source;
1692
    var verbatimString = /@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;
1693
 
1694
 
1695
    Prism.languages.csharp = Prism.languages.extend('clike', {
1696
        'string': [
1697
            {
1698
                pattern: re(/(^|[^$\\])<<0>>/.source, [verbatimString]),
1699
                lookbehind: true,
1700
                greedy: true
1701
            },
1702
            {
1703
                pattern: re(/(^|[^@$\\])<<0>>/.source, [regularString]),
1704
                lookbehind: true,
1705
                greedy: true
1706
            }
1707
        ],
1708
        'class-name': [
1709
            {
1710
                // Using static
1711
                // using static System.Math;
1712
                pattern: re(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [identifier]),
1713
                lookbehind: true,
1714
                inside: typeInside
1715
            },
1716
            {
1717
                // Using alias (type)
1718
                // using Project = PC.MyCompany.Project;
1719
                pattern: re(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [name, typeExpression]),
1720
                lookbehind: true,
1721
                inside: typeInside
1722
            },
1723
            {
1724
                // Using alias (alias)
1725
                // using Project = PC.MyCompany.Project;
1726
                pattern: re(/(\busing\s+)<<0>>(?=\s*=)/.source, [name]),
1727
                lookbehind: true
1728
            },
1729
            {
1730
                // Type declarations
1731
                // class Foo<A, B>
1732
                // interface Foo<out A, B>
1733
                pattern: re(/(\b<<0>>\s+)<<1>>/.source, [typeDeclarationKeywords, genericName]),
1734
                lookbehind: true,
1735
                inside: typeInside
1736
            },
1737
            {
1738
                // Single catch exception declaration
1739
                // catch(Foo)
1740
                // (things like catch(Foo e) is covered by variable declaration)
1741
                pattern: re(/(\bcatch\s*\(\s*)<<0>>/.source, [identifier]),
1742
                lookbehind: true,
1743
                inside: typeInside
1744
            },
1745
            {
1746
                // Name of the type parameter of generic constraints
1747
                // where Foo : class
1748
                pattern: re(/(\bwhere\s+)<<0>>/.source, [name]),
1749
                lookbehind: true
1750
            },
1751
            {
1752
                // Casts and checks via as and is.
1753
                // as Foo<A>, is Bar<B>
1754
                // (things like if(a is Foo b) is covered by variable declaration)
1755
                pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [typeExpressionWithoutTuple]),
1756
                lookbehind: true,
1757
                inside: typeInside
1758
            },
1759
            {
1760
                // Variable, field and parameter declaration
1761
                // (Foo bar, Bar baz, Foo[,,] bay, Foo<Bar, FooBar<Bar>> bax)
1762
                pattern: re(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [typeExpression, nonContextualKeywords, name]),
1763
                inside: typeInside
1764
            }
1765
        ],
1766
        'keyword': keywords,
1767
        // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#literals
1768
        '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,
1769
        'operator': />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
1770
        'punctuation': /\?\.?|::|[{}[\];(),.:]/
1771
    });
1772
 
1773
    Prism.languages.insertBefore('csharp', 'number', {
1774
        'range': {
1775
            pattern: /\.\./,
1776
            alias: 'operator'
1777
        }
1778
    });
1779
 
1780
    Prism.languages.insertBefore('csharp', 'punctuation', {
1781
        'named-parameter': {
1782
            pattern: re(/([(,]\s*)<<0>>(?=\s*:)/.source, [name]),
1783
            lookbehind: true,
1784
            alias: 'punctuation'
1785
        }
1786
    });
1787
 
1788
    Prism.languages.insertBefore('csharp', 'class-name', {
1789
        'namespace': {
1790
            // namespace Foo.Bar {}
1791
            // using Foo.Bar;
1792
            pattern: re(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source, [name]),
1793
            lookbehind: true,
1794
            inside: {
1795
                'punctuation': /\./
1796
            }
1797
        },
1798
        'type-expression': {
1799
            // default(Foo), typeof(Foo<Bar>), sizeof(int)
1800
            pattern: re(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source, [nestedRound]),
1801
            lookbehind: true,
1802
            alias: 'class-name',
1803
            inside: typeInside
1804
        },
1805
        'return-type': {
1806
            // Foo<Bar> ForBar(); Foo IFoo.Bar() => 0
1807
            // int this[int index] => 0; T IReadOnlyList<T>.this[int index] => this[index];
1808
            // int Foo => 0; int Foo { get; set } = 0;
1809
            pattern: re(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source, [typeExpression, identifier]),
1810
            inside: typeInside,
1811
            alias: 'class-name'
1812
        },
1813
        'constructor-invocation': {
1814
            // new List<Foo<Bar[]>> { }
1815
            pattern: re(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [typeExpression]),
1816
            lookbehind: true,
1817
            inside: typeInside,
1818
            alias: 'class-name'
1819
        },
1820
        /*'explicit-implementation': {
1821
            // int IFoo<Foo>.Bar => 0; void IFoo<Foo<Foo>>.Foo<T>();
1822
            pattern: replace(/\b<<0>>(?=\.<<1>>)/, className, methodOrPropertyDeclaration),
1823
            inside: classNameInside,
1824
            alias: 'class-name'
1825
        },*/
1826
        'generic-method': {
1827
            // foo<Bar>()
1828
            pattern: re(/<<0>>\s*<<1>>(?=\s*\()/.source, [name, generic]),
1829
            inside: {
1830
                'function': re(/^<<0>>/.source, [name]),
1831
                'generic': {
1832
                    pattern: RegExp(generic),
1833
                    alias: 'class-name',
1834
                    inside: typeInside
1835
                }
1836
            }
1837
        },
1838
        'type-list': {
1839
            // The list of types inherited or of generic constraints
1840
            // class Foo<F> : Bar, IList<FooBar>
1841
            // where F : Bar, IList<int>
1842
            pattern: re(
1843
                /\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,
1844
                [typeDeclarationKeywords, genericName, name, typeExpression, keywords.source, nestedRound, /\bnew\s*\(\s*\)/.source]
1845
            ),
1846
            lookbehind: true,
1847
            inside: {
1848
                'record-arguments': {
1849
                    pattern: re(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source, [genericName, nestedRound]),
1850
                    lookbehind: true,
1851
                    greedy: true,
1852
                    inside: Prism.languages.csharp
1853
                },
1854
                'keyword': keywords,
1855
                'class-name': {
1856
                    pattern: RegExp(typeExpression),
1857
                    greedy: true,
1858
                    inside: typeInside
1859
                },
1860
                'punctuation': /[,()]/
1861
            }
1862
        },
1863
        'preprocessor': {
1864
            pattern: /(^[\t ]*)#.*/m,
1865
            lookbehind: true,
1866
            alias: 'property',
1867
            inside: {
1868
                // highlight preprocessor directives as keywords
1869
                'directive': {
1870
                    pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
1871
                    lookbehind: true,
1872
                    alias: 'keyword'
1873
                }
1874
            }
1875
        }
1876
    });
1877
 
1878
    // attributes
1879
    var regularStringOrCharacter = regularString + '|' + character;
1880
    var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [regularStringOrCharacter]);
1881
    var roundExpression = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
1882
 
1883
    // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/#attribute-targets
1884
    var attrTarget = /\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source;
1885
    var attr = replace(/<<0>>(?:\s*\(<<1>>*\))?/.source, [identifier, roundExpression]);
1886
 
1887
    Prism.languages.insertBefore('csharp', 'class-name', {
1888
        'attribute': {
1889
            // Attributes
1890
            // [Foo], [Foo(1), Bar(2, Prop = "foo")], [return: Foo(1), Bar(2)], [assembly: Foo(Bar)]
1891
            pattern: re(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source, [attrTarget, attr]),
1892
            lookbehind: true,
1893
            greedy: true,
1894
            inside: {
1895
                'target': {
1896
                    pattern: re(/^<<0>>(?=\s*:)/.source, [attrTarget]),
1897
                    alias: 'keyword'
1898
                },
1899
                'attribute-arguments': {
1900
                    pattern: re(/\(<<0>>*\)/.source, [roundExpression]),
1901
                    inside: Prism.languages.csharp
1902
                },
1903
                'class-name': {
1904
                    pattern: RegExp(identifier),
1905
                    inside: {
1906
                        'punctuation': /\./
1907
                    }
1908
                },
1909
                'punctuation': /[:,]/
1910
            }
1911
        }
1912
    });
1913
 
1914
 
1915
    // string interpolation
1916
    var formatString = /:[^}\r\n]+/.source;
1917
    // multi line
1918
    var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
1919
    var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [mInterpolationRound, formatString]);
1920
    // single line
1921
    var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2);
1922
    var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [sInterpolationRound, formatString]);
1923
 
1924
    function createInterpolationInside(interpolation, interpolationRound) {
1925
        return {
1926
            'interpolation': {
1927
                pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
1928
                lookbehind: true,
1929
                inside: {
1930
                    'format-string': {
1931
                        pattern: re(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source, [interpolationRound, formatString]),
1932
                        lookbehind: true,
1933
                        inside: {
1934
                            'punctuation': /^:/
1935
                        }
1936
                    },
1937
                    'punctuation': /^\{|\}$/,
1938
                    'expression': {
1939
                        pattern: /[\s\S]+/,
1940
                        alias: 'language-csharp',
1941
                        inside: Prism.languages.csharp
1942
                    }
1943
                }
1944
            },
1945
            'string': /[\s\S]+/
1946
        };
1947
    }
1948
 
1949
    Prism.languages.insertBefore('csharp', 'string', {
1950
        'interpolation-string': [
1951
            {
1952
                pattern: re(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source, [mInterpolation]),
1953
                lookbehind: true,
1954
                greedy: true,
1955
                inside: createInterpolationInside(mInterpolation, mInterpolationRound),
1956
            },
1957
            {
1958
                pattern: re(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source, [sInterpolation]),
1959
                lookbehind: true,
1960
                greedy: true,
1961
                inside: createInterpolationInside(sInterpolation, sInterpolationRound),
1962
            }
1963
        ],
1964
        'char': {
1965
            pattern: RegExp(character),
1966
            greedy: true
1967
        }
1968
    });
1969
 
1970
    Prism.languages.dotnet = Prism.languages.cs = Prism.languages.csharp;
1971
 
1972
}(Prism));
1973
 
1974
(function (Prism) {
1975
 
1976
    var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1977
 
1978
    Prism.languages.css = {
1979
        'comment': /\/\*[\s\S]*?\*\//,
1980
        'atrule': {
1981
            pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
1982
            inside: {
1983
                'rule': /^@[\w-]+/,
1984
                'selector-function-argument': {
1985
                    pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1986
                    lookbehind: true,
1987
                    alias: 'selector'
1988
                },
1989
                'keyword': {
1990
                    pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1991
                    lookbehind: true
1992
                }
1993
                // See rest below
1994
            }
1995
        },
1996
        'url': {
1997
            // https://drafts.csswg.org/css-values-3/#urls
1998
            pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1999
            greedy: true,
2000
            inside: {
2001
                'function': /^url/i,
2002
                'punctuation': /^\(|\)$/,
2003
                'string': {
2004
                    pattern: RegExp('^' + string.source + '$'),
2005
                    alias: 'url'
2006
                }
2007
            }
2008
        },
2009
        'selector': {
2010
            pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
2011
            lookbehind: true
2012
        },
2013
        'string': {
2014
            pattern: string,
2015
            greedy: true
2016
        },
2017
        'property': {
2018
            pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
2019
            lookbehind: true
2020
        },
2021
        'important': /!important\b/i,
2022
        'function': {
2023
            pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
2024
            lookbehind: true
2025
        },
2026
        'punctuation': /[(){};:,]/
2027
    };
2028
 
2029
    Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
2030
 
2031
    var markup = Prism.languages.markup;
2032
    if (markup) {
2033
        markup.tag.addInlined('style', 'css');
2034
        markup.tag.addAttribute('style', 'css');
2035
    }
2036
 
2037
}(Prism));
2038
 
2039
(function (Prism) {
2040
 
2041
    var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
2042
 
2043
    // full package (optional) + parent classes (optional)
2044
    var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
2045
 
2046
    // based on the java naming conventions
2047
    var className = {
2048
        pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
2049
        lookbehind: true,
2050
        inside: {
2051
            'namespace': {
2052
                pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
2053
                inside: {
2054
                    'punctuation': /\./
2055
                }
2056
            },
2057
            'punctuation': /\./
2058
        }
2059
    };
2060
 
2061
    Prism.languages.java = Prism.languages.extend('clike', {
2062
        'string': {
2063
            pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
2064
            lookbehind: true,
2065
            greedy: true
2066
        },
2067
        'class-name': [
2068
            className,
2069
            {
2070
                // variables, parameters, and constructor references
2071
                // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
2072
                pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
2073
                lookbehind: true,
2074
                inside: className.inside
2075
            },
2076
            {
2077
                // class names based on keyword
2078
                // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
2079
                pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
2080
                lookbehind: true,
2081
                inside: className.inside
2082
            }
2083
        ],
2084
        'keyword': keywords,
2085
        'function': [
2086
            Prism.languages.clike.function,
2087
            {
2088
                pattern: /(::\s*)[a-z_]\w*/,
2089
                lookbehind: true
2090
            }
2091
        ],
2092
        'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
2093
        'operator': {
2094
            pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
2095
            lookbehind: true
2096
        }
2097
    });
2098
 
2099
    Prism.languages.insertBefore('java', 'string', {
2100
        'triple-quoted-string': {
2101
            // http://openjdk.java.net/jeps/355#Description
2102
            pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
2103
            greedy: true,
2104
            alias: 'string'
2105
        },
2106
        'char': {
2107
            pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
2108
            greedy: true
2109
        }
2110
    });
2111
 
2112
    Prism.languages.insertBefore('java', 'class-name', {
2113
        'annotation': {
2114
            pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
2115
            lookbehind: true,
2116
            alias: 'punctuation'
2117
        },
2118
        'generics': {
2119
            pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
2120
            inside: {
2121
                'class-name': className,
2122
                'keyword': keywords,
2123
                'punctuation': /[<>(),.:]/,
2124
                'operator': /[?&|]/
2125
            }
2126
        },
2127
        'import': [
2128
            {
2129
                pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
2130
                lookbehind: true,
2131
                inside: {
2132
                    'namespace': className.inside.namespace,
2133
                    'punctuation': /\./,
2134
                    'operator': /\*/,
2135
                    'class-name': /\w+/
2136
                }
2137
            },
2138
            {
2139
                pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
2140
                lookbehind: true,
2141
                alias: 'static',
2142
                inside: {
2143
                    'namespace': className.inside.namespace,
2144
                    'static': /\b\w+$/,
2145
                    'punctuation': /\./,
2146
                    'operator': /\*/,
2147
                    'class-name': /\w+/
2148
                }
2149
            }
2150
        ],
2151
        'namespace': {
2152
            pattern: RegExp(
2153
                /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/
2154
                    .source.replace(/<keyword>/g, function () { return keywords.source; })),
2155
            lookbehind: true,
2156
            inside: {
2157
                'punctuation': /\./,
2158
            }
2159
        }
2160
    });
2161
}(Prism));
2162
 
2163
Prism.languages.javascript = Prism.languages.extend('clike', {
2164
    'class-name': [
2165
        Prism.languages.clike['class-name'],
2166
        {
2167
            pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2168
            lookbehind: true
2169
        }
2170
    ],
2171
    'keyword': [
2172
        {
2173
            pattern: /((?:^|\})\s*)catch\b/,
2174
            lookbehind: true
2175
        },
2176
        {
2177
            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/,
2178
            lookbehind: true
2179
        },
2180
    ],
2181
    // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
2182
    'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
2183
    'number': {
2184
        pattern: RegExp(
2185
            /(^|[^\w$])/.source +
2186
            '(?:' +
2187
            (
2188
                // constant
2189
                /NaN|Infinity/.source +
2190
                '|' +
2191
                // binary integer
2192
                /0[bB][01]+(?:_[01]+)*n?/.source +
2193
                '|' +
2194
                // octal integer
2195
                /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
2196
                '|' +
2197
                // hexadecimal integer
2198
                /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
2199
                '|' +
2200
                // decimal bigint
2201
                /\d+(?:_\d+)*n/.source +
2202
                '|' +
2203
                // decimal number (integer or float) but no bigint
2204
                /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
2205
            ) +
2206
            ')' +
2207
            /(?![\w$])/.source
2208
        ),
2209
        lookbehind: true
2210
    },
2211
    'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
2212
});
2213
 
2214
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
2215
 
2216
Prism.languages.insertBefore('javascript', 'keyword', {
2217
    'regex': {
2218
        pattern: RegExp(
2219
            // lookbehind
2220
            // eslint-disable-next-line regexp/no-dupe-characters-character-class
2221
            /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
2222
            // Regex pattern:
2223
            // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
2224
            // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
2225
            // with the only syntax, so we have to define 2 different regex patterns.
2226
            /\//.source +
2227
            '(?:' +
2228
            /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
2229
            '|' +
2230
            // `v` flag syntax. This supports 3 levels of nested character classes.
2231
            /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
2232
            ')' +
2233
            // lookahead
2234
            /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
2235
        ),
2236
        lookbehind: true,
2237
        greedy: true,
2238
        inside: {
2239
            'regex-source': {
2240
                pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
2241
                lookbehind: true,
2242
                alias: 'language-regex',
2243
                inside: Prism.languages.regex
2244
            },
2245
            'regex-delimiter': /^\/|\/$/,
2246
            'regex-flags': /^[a-z]+$/,
2247
        }
2248
    },
2249
    // This must be declared before keyword because we use "function" inside the look-forward
2250
    'function-variable': {
2251
        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*=>))/,
2252
        alias: 'function'
2253
    },
2254
    'parameter': [
2255
        {
2256
            pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
2257
            lookbehind: true,
2258
            inside: Prism.languages.javascript
2259
        },
2260
        {
2261
            pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
2262
            lookbehind: true,
2263
            inside: Prism.languages.javascript
2264
        },
2265
        {
2266
            pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
2267
            lookbehind: true,
2268
            inside: Prism.languages.javascript
2269
        },
2270
        {
2271
            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*\{)/,
2272
            lookbehind: true,
2273
            inside: Prism.languages.javascript
2274
        }
2275
    ],
2276
    'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
2277
});
2278
 
2279
Prism.languages.insertBefore('javascript', 'string', {
2280
    'hashbang': {
2281
        pattern: /^#!.*/,
2282
        greedy: true,
2283
        alias: 'comment'
2284
    },
2285
    'template-string': {
2286
        pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
2287
        greedy: true,
2288
        inside: {
2289
            'template-punctuation': {
2290
                pattern: /^`|`$/,
2291
                alias: 'string'
2292
            },
2293
            'interpolation': {
2294
                pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
2295
                lookbehind: true,
2296
                inside: {
2297
                    'interpolation-punctuation': {
2298
                        pattern: /^\$\{|\}$/,
2299
                        alias: 'punctuation'
2300
                    },
2301
                    rest: Prism.languages.javascript
2302
                }
2303
            },
2304
            'string': /[\s\S]+/
2305
        }
2306
    },
2307
    'string-property': {
2308
        pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
2309
        lookbehind: true,
2310
        greedy: true,
2311
        alias: 'property'
2312
    }
2313
});
2314
 
2315
Prism.languages.insertBefore('javascript', 'operator', {
2316
    'literal-property': {
2317
        pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
2318
        lookbehind: true,
2319
        alias: 'property'
2320
    },
2321
});
2322
 
2323
if (Prism.languages.markup) {
2324
    Prism.languages.markup.tag.addInlined('script', 'javascript');
2325
 
2326
    // add attribute support for all DOM events.
2327
    // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
2328
    Prism.languages.markup.tag.addAttribute(
2329
        /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,
2330
        'javascript'
2331
    );
2332
}
2333
 
2334
Prism.languages.js = Prism.languages.javascript;
2335
 
2336
Prism.languages.markup = {
2337
    'comment': {
2338
        pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
2339
        greedy: true
2340
    },
2341
    'prolog': {
2342
        pattern: /<\?[\s\S]+?\?>/,
2343
        greedy: true
2344
    },
2345
    'doctype': {
2346
        // https://www.w3.org/TR/xml/#NT-doctypedecl
2347
        pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
2348
        greedy: true,
2349
        inside: {
2350
            'internal-subset': {
2351
                pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
2352
                lookbehind: true,
2353
                greedy: true,
2354
                inside: null // see below
2355
            },
2356
            'string': {
2357
                pattern: /"[^"]*"|'[^']*'/,
2358
                greedy: true
2359
            },
2360
            'punctuation': /^<!|>$|[[\]]/,
2361
            'doctype-tag': /^DOCTYPE/i,
2362
            'name': /[^\s<>'"]+/
2363
        }
2364
    },
2365
    'cdata': {
2366
        pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2367
        greedy: true
2368
    },
2369
    'tag': {
2370
        pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
2371
        greedy: true,
2372
        inside: {
2373
            'tag': {
2374
                pattern: /^<\/?[^\s>\/]+/,
2375
                inside: {
2376
                    'punctuation': /^<\/?/,
2377
                    'namespace': /^[^\s>\/:]+:/
2378
                }
2379
            },
2380
            'special-attr': [],
2381
            'attr-value': {
2382
                pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
2383
                inside: {
2384
                    'punctuation': [
2385
                        {
2386
                            pattern: /^=/,
2387
                            alias: 'attr-equals'
2388
                        },
2389
                        /"|'/
2390
                    ]
2391
                }
2392
            },
2393
            'punctuation': /\/?>/,
2394
            'attr-name': {
2395
                pattern: /[^\s>\/]+/,
2396
                inside: {
2397
                    'namespace': /^[^\s>\/:]+:/
2398
                }
2399
            }
2400
 
2401
        }
2402
    },
2403
    'entity': [
2404
        {
2405
            pattern: /&[\da-z]{1,8};/i,
2406
            alias: 'named-entity'
2407
        },
2408
        /&#x?[\da-f]{1,8};/i
2409
    ]
2410
};
2411
 
2412
Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
2413
    Prism.languages.markup['entity'];
2414
Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
2415
 
2416
// Plugin to make entity title show the real entity, idea by Roman Komarov
2417
Prism.hooks.add('wrap', function (env) {
2418
 
2419
    if (env.type === 'entity') {
2420
        env.attributes['title'] = env.content.replace(/&amp;/, '&');
2421
    }
2422
});
2423
 
2424
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
2425
    /**
2426
     * Adds an inlined language to markup.
2427
     *
2428
     * An example of an inlined language is CSS with `<style>` tags.
2429
     *
2430
     * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
2431
     * case insensitive.
2432
     * @param {string} lang The language key.
2433
     * @example
2434
     * addInlined('style', 'css');
2435
     */
2436
    value: function addInlined(tagName, lang) {
2437
        var includedCdataInside = {};
2438
        includedCdataInside['language-' + lang] = {
2439
            pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
2440
            lookbehind: true,
2441
            inside: Prism.languages[lang]
2442
        };
2443
        includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
2444
 
2445
        var inside = {
2446
            'included-cdata': {
2447
                pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2448
                inside: includedCdataInside
2449
            }
2450
        };
2451
        inside['language-' + lang] = {
2452
            pattern: /[\s\S]+/,
2453
            inside: Prism.languages[lang]
2454
        };
2455
 
2456
        var def = {};
2457
        def[tagName] = {
2458
            pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
2459
            lookbehind: true,
2460
            greedy: true,
2461
            inside: inside
2462
        };
2463
 
2464
        Prism.languages.insertBefore('markup', 'cdata', def);
2465
    }
2466
});
2467
Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
2468
    /**
2469
     * Adds an pattern to highlight languages embedded in HTML attributes.
2470
     *
2471
     * An example of an inlined language is CSS with `style` attributes.
2472
     *
2473
     * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
2474
     * case insensitive.
2475
     * @param {string} lang The language key.
2476
     * @example
2477
     * addAttribute('style', 'css');
2478
     */
2479
    value: function (attrName, lang) {
2480
        Prism.languages.markup.tag.inside['special-attr'].push({
2481
            pattern: RegExp(
2482
                /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
2483
                'i'
2484
            ),
2485
            lookbehind: true,
2486
            inside: {
2487
                'attr-name': /^[^\s=]+/,
2488
                'attr-value': {
2489
                    pattern: /=[\s\S]+/,
2490
                    inside: {
2491
                        'value': {
2492
                            pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
2493
                            lookbehind: true,
2494
                            alias: [lang, 'language-' + lang],
2495
                            inside: Prism.languages[lang]
2496
                        },
2497
                        'punctuation': [
2498
                            {
2499
                                pattern: /^=/,
2500
                                alias: 'attr-equals'
2501
                            },
2502
                            /"|'/
2503
                        ]
2504
                    }
2505
                }
2506
            }
2507
        });
2508
    }
2509
});
2510
 
2511
Prism.languages.html = Prism.languages.markup;
2512
Prism.languages.mathml = Prism.languages.markup;
2513
Prism.languages.svg = Prism.languages.markup;
2514
 
2515
Prism.languages.xml = Prism.languages.extend('markup', {});
2516
Prism.languages.ssml = Prism.languages.xml;
2517
Prism.languages.atom = Prism.languages.xml;
2518
Prism.languages.rss = Prism.languages.xml;
2519
 
2520
/**
2521
 * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
2522
 * Modified by Miles Johnson: http://milesj.me
2523
 * Rewritten by Tom Pavelec
2524
 *
2525
 * Supports PHP 5.3 - 8.0
2526
 */
2527
(function (Prism) {
2528
    var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
2529
    var constant = [
2530
        {
2531
            pattern: /\b(?:false|true)\b/i,
2532
            alias: 'boolean'
2533
        },
2534
        {
2535
            pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
2536
            greedy: true,
2537
            lookbehind: true,
2538
        },
2539
        {
2540
            pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
2541
            greedy: true,
2542
            lookbehind: true,
2543
        },
2544
        /\b(?:null)\b/i,
2545
        /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/,
2546
    ];
2547
    var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
2548
    var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
2549
    var punctuation = /[{}\[\](),:;]/;
2550
 
2551
    Prism.languages.php = {
2552
        'delimiter': {
2553
            pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
2554
            alias: 'important'
2555
        },
2556
        'comment': comment,
2557
        'variable': /\$+(?:\w+\b|(?=\{))/,
2558
        'package': {
2559
            pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2560
            lookbehind: true,
2561
            inside: {
2562
                'punctuation': /\\/
2563
            }
2564
        },
2565
        'class-name-definition': {
2566
            pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
2567
            lookbehind: true,
2568
            alias: 'class-name'
2569
        },
2570
        'function-definition': {
2571
            pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
2572
            lookbehind: true,
2573
            alias: 'function'
2574
        },
2575
        'keyword': [
2576
            {
2577
                pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
2578
                alias: 'type-casting',
2579
                greedy: true,
2580
                lookbehind: true
2581
            },
2582
            {
2583
                pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
2584
                alias: 'type-hint',
2585
                greedy: true,
2586
                lookbehind: true
2587
            },
2588
            {
2589
                pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
2590
                alias: 'return-type',
2591
                greedy: true,
2592
                lookbehind: true
2593
            },
2594
            {
2595
                pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
2596
                alias: 'type-declaration',
2597
                greedy: true
2598
            },
2599
            {
2600
                pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
2601
                alias: 'type-declaration',
2602
                greedy: true,
2603
                lookbehind: true
2604
            },
2605
            {
2606
                pattern: /\b(?:parent|self|static)(?=\s*::)/i,
2607
                alias: 'static-context',
2608
                greedy: true
2609
            },
2610
            {
2611
                // yield from
2612
                pattern: /(\byield\s+)from\b/i,
2613
                lookbehind: true
2614
            },
2615
            // `class` is always a keyword unlike other keywords
2616
            /\bclass\b/i,
2617
            {
2618
                // https://www.php.net/manual/en/reserved.keywords.php
2619
                //
2620
                // keywords cannot be preceded by "->"
2621
                // the complex lookbehind means `(?<!(?:->|::)\s*)`
2622
                pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
2623
                lookbehind: true
2624
            }
2625
        ],
2626
        'argument-name': {
2627
            pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
2628
            lookbehind: true
2629
        },
2630
        'class-name': [
2631
            {
2632
                pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
2633
                greedy: true,
2634
                lookbehind: true
2635
            },
2636
            {
2637
                pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
2638
                greedy: true,
2639
                lookbehind: true
2640
            },
2641
            {
2642
                pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
2643
                greedy: true
2644
            },
2645
            {
2646
                pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
2647
                alias: 'class-name-fully-qualified',
2648
                greedy: true,
2649
                lookbehind: true,
2650
                inside: {
2651
                    'punctuation': /\\/
2652
                }
2653
            },
2654
            {
2655
                pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
2656
                alias: 'class-name-fully-qualified',
2657
                greedy: true,
2658
                inside: {
2659
                    'punctuation': /\\/
2660
                }
2661
            },
2662
            {
2663
                pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2664
                alias: 'class-name-fully-qualified',
2665
                greedy: true,
2666
                lookbehind: true,
2667
                inside: {
2668
                    'punctuation': /\\/
2669
                }
2670
            },
2671
            {
2672
                pattern: /\b[a-z_]\w*(?=\s*\$)/i,
2673
                alias: 'type-declaration',
2674
                greedy: true
2675
            },
2676
            {
2677
                pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
2678
                alias: ['class-name-fully-qualified', 'type-declaration'],
2679
                greedy: true,
2680
                inside: {
2681
                    'punctuation': /\\/
2682
                }
2683
            },
2684
            {
2685
                pattern: /\b[a-z_]\w*(?=\s*::)/i,
2686
                alias: 'static-context',
2687
                greedy: true
2688
            },
2689
            {
2690
                pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
2691
                alias: ['class-name-fully-qualified', 'static-context'],
2692
                greedy: true,
2693
                inside: {
2694
                    'punctuation': /\\/
2695
                }
2696
            },
2697
            {
2698
                pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
2699
                alias: 'type-hint',
2700
                greedy: true,
2701
                lookbehind: true
2702
            },
2703
            {
2704
                pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
2705
                alias: ['class-name-fully-qualified', 'type-hint'],
2706
                greedy: true,
2707
                lookbehind: true,
2708
                inside: {
2709
                    'punctuation': /\\/
2710
                }
2711
            },
2712
            {
2713
                pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
2714
                alias: 'return-type',
2715
                greedy: true,
2716
                lookbehind: true
2717
            },
2718
            {
2719
                pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2720
                alias: ['class-name-fully-qualified', 'return-type'],
2721
                greedy: true,
2722
                lookbehind: true,
2723
                inside: {
2724
                    'punctuation': /\\/
2725
                }
2726
            }
2727
        ],
2728
        'constant': constant,
2729
        'function': {
2730
            pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
2731
            lookbehind: true,
2732
            inside: {
2733
                'punctuation': /\\/
2734
            }
2735
        },
2736
        'property': {
2737
            pattern: /(->\s*)\w+/,
2738
            lookbehind: true
2739
        },
2740
        'number': number,
2741
        'operator': operator,
2742
        'punctuation': punctuation
2743
    };
2744
 
2745
    var string_interpolation = {
2746
        pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
2747
        lookbehind: true,
2748
        inside: Prism.languages.php
2749
    };
2750
 
2751
    var string = [
2752
        {
2753
            pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
2754
            alias: 'nowdoc-string',
2755
            greedy: true,
2756
            inside: {
2757
                'delimiter': {
2758
                    pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
2759
                    alias: 'symbol',
2760
                    inside: {
2761
                        'punctuation': /^<<<'?|[';]$/
2762
                    }
2763
                }
2764
            }
2765
        },
2766
        {
2767
            pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
2768
            alias: 'heredoc-string',
2769
            greedy: true,
2770
            inside: {
2771
                'delimiter': {
2772
                    pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
2773
                    alias: 'symbol',
2774
                    inside: {
2775
                        'punctuation': /^<<<"?|[";]$/
2776
                    }
2777
                },
2778
                'interpolation': string_interpolation
2779
            }
2780
        },
2781
        {
2782
            pattern: /`(?:\\[\s\S]|[^\\`])*`/,
2783
            alias: 'backtick-quoted-string',
2784
            greedy: true
2785
        },
2786
        {
2787
            pattern: /'(?:\\[\s\S]|[^\\'])*'/,
2788
            alias: 'single-quoted-string',
2789
            greedy: true
2790
        },
2791
        {
2792
            pattern: /"(?:\\[\s\S]|[^\\"])*"/,
2793
            alias: 'double-quoted-string',
2794
            greedy: true,
2795
            inside: {
2796
                'interpolation': string_interpolation
2797
            }
2798
        }
2799
    ];
2800
 
2801
    Prism.languages.insertBefore('php', 'variable', {
2802
        'string': string,
2803
        'attribute': {
2804
            pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
2805
            greedy: true,
2806
            inside: {
2807
                'attribute-content': {
2808
                    pattern: /^(#\[)[\s\S]+(?=\]$)/,
2809
                    lookbehind: true,
2810
                    // inside can appear subset of php
2811
                    inside: {
2812
                        'comment': comment,
2813
                        'string': string,
2814
                        'attribute-class-name': [
2815
                            {
2816
                                pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
2817
                                alias: 'class-name',
2818
                                greedy: true,
2819
                                lookbehind: true
2820
                            },
2821
                            {
2822
                                pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
2823
                                alias: [
2824
                                    'class-name',
2825
                                    'class-name-fully-qualified'
2826
                                ],
2827
                                greedy: true,
2828
                                lookbehind: true,
2829
                                inside: {
2830
                                    'punctuation': /\\/
2831
                                }
2832
                            }
2833
                        ],
2834
                        'constant': constant,
2835
                        'number': number,
2836
                        'operator': operator,
2837
                        'punctuation': punctuation
2838
                    }
2839
                },
2840
                'delimiter': {
2841
                    pattern: /^#\[|\]$/,
2842
                    alias: 'punctuation'
2843
                }
2844
            }
2845
        },
2846
    });
2847
 
2848
    Prism.hooks.add('before-tokenize', function (env) {
2849
        if (!/<\?/.test(env.code)) {
2850
            return;
2851
        }
2852
 
2853
        var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
2854
        Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
2855
    });
2856
 
2857
    Prism.hooks.add('after-tokenize', function (env) {
2858
        Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
2859
    });
2860
 
2861
}(Prism));
2862
 
2863
Prism.languages.python = {
2864
    'comment': {
2865
        pattern: /(^|[^\\])#.*/,
2866
        lookbehind: true,
2867
        greedy: true
2868
    },
2869
    'string-interpolation': {
2870
        pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
2871
        greedy: true,
2872
        inside: {
2873
            'interpolation': {
2874
                // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
2875
                pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
2876
                lookbehind: true,
2877
                inside: {
2878
                    'format-spec': {
2879
                        pattern: /(:)[^:(){}]+(?=\}$)/,
2880
                        lookbehind: true
2881
                    },
2882
                    'conversion-option': {
2883
                        pattern: /![sra](?=[:}]$)/,
2884
                        alias: 'punctuation'
2885
                    },
2886
                    rest: null
2887
                }
2888
            },
2889
            'string': /[\s\S]+/
2890
        }
2891
    },
2892
    'triple-quoted-string': {
2893
        pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
2894
        greedy: true,
2895
        alias: 'string'
2896
    },
2897
    'string': {
2898
        pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
2899
        greedy: true
2900
    },
2901
    'function': {
2902
        pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
2903
        lookbehind: true
2904
    },
2905
    'class-name': {
2906
        pattern: /(\bclass\s+)\w+/i,
2907
        lookbehind: true
2908
    },
2909
    'decorator': {
2910
        pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
2911
        lookbehind: true,
2912
        alias: ['annotation', 'punctuation'],
2913
        inside: {
2914
            'punctuation': /\./
2915
        }
2916
    },
2917
    '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/,
2918
    '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/,
2919
    'boolean': /\b(?:False|None|True)\b/,
2920
    '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,
2921
    'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2922
    'punctuation': /[{}[\];(),.:]/
2923
};
2924
 
2925
Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
2926
 
2927
Prism.languages.py = Prism.languages.python;
2928
 
2929
/**
2930
 * Original by Samuel Flores
2931
 *
2932
 * Adds the following new token classes:
2933
 *     constant, builtin, variable, symbol, regex
2934
 */
2935
(function (Prism) {
2936
    Prism.languages.ruby = Prism.languages.extend('clike', {
2937
        'comment': {
2938
            pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
2939
            greedy: true
2940
        },
2941
        'class-name': {
2942
            pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
2943
            lookbehind: true,
2944
            inside: {
2945
                'punctuation': /[.\\]/
2946
            }
2947
        },
2948
        '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/,
2949
        'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
2950
        'punctuation': /[(){}[\].,;]/,
2951
    });
2952
 
2953
    Prism.languages.insertBefore('ruby', 'operator', {
2954
        'double-colon': {
2955
            pattern: /::/,
2956
            alias: 'punctuation'
2957
        },
2958
    });
2959
 
2960
    var interpolation = {
2961
        pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
2962
        lookbehind: true,
2963
        inside: {
2964
            'content': {
2965
                pattern: /^(#\{)[\s\S]+(?=\}$)/,
2966
                lookbehind: true,
2967
                inside: Prism.languages.ruby
2968
            },
2969
            'delimiter': {
2970
                pattern: /^#\{|\}$/,
2971
                alias: 'punctuation'
2972
            }
2973
        }
2974
    };
2975
 
2976
    delete Prism.languages.ruby.function;
2977
 
2978
    var percentExpression = '(?:' + [
2979
        /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
2980
        /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
2981
        /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
2982
        /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
2983
        /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
2984
    ].join('|') + ')';
2985
 
2986
    var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
2987
 
2988
    Prism.languages.insertBefore('ruby', 'keyword', {
2989
        'regex-literal': [
2990
            {
2991
                pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
2992
                greedy: true,
2993
                inside: {
2994
                    'interpolation': interpolation,
2995
                    'regex': /[\s\S]+/
2996
                }
2997
            },
2998
            {
2999
                pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
3000
                lookbehind: true,
3001
                greedy: true,
3002
                inside: {
3003
                    'interpolation': interpolation,
3004
                    'regex': /[\s\S]+/
3005
                }
3006
            }
3007
        ],
3008
        'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
3009
        'symbol': [
3010
            {
3011
                pattern: RegExp(/(^|[^:]):/.source + symbolName),
3012
                lookbehind: true,
3013
                greedy: true
3014
            },
3015
            {
3016
                pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
3017
                lookbehind: true,
3018
                greedy: true
3019
            },
3020
        ],
3021
        'method-definition': {
3022
            pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
3023
            lookbehind: true,
3024
            inside: {
3025
                'function': /\b\w+$/,
3026
                'keyword': /^self\b/,
3027
                'class-name': /^\w+/,
3028
                'punctuation': /\./
3029
            }
3030
        }
3031
    });
3032
 
3033
    Prism.languages.insertBefore('ruby', 'string', {
3034
        'string-literal': [
3035
            {
3036
                pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
3037
                greedy: true,
3038
                inside: {
3039
                    'interpolation': interpolation,
3040
                    'string': /[\s\S]+/
3041
                }
3042
            },
3043
            {
3044
                pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
3045
                greedy: true,
3046
                inside: {
3047
                    'interpolation': interpolation,
3048
                    'string': /[\s\S]+/
3049
                }
3050
            },
3051
            {
3052
                pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
3053
                alias: 'heredoc-string',
3054
                greedy: true,
3055
                inside: {
3056
                    'delimiter': {
3057
                        pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
3058
                        inside: {
3059
                            'symbol': /\b\w+/,
3060
                            'punctuation': /^<<[-~]?/
3061
                        }
3062
                    },
3063
                    'interpolation': interpolation,
3064
                    'string': /[\s\S]+/
3065
                }
3066
            },
3067
            {
3068
                pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
3069
                alias: 'heredoc-string',
3070
                greedy: true,
3071
                inside: {
3072
                    'delimiter': {
3073
                        pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
3074
                        inside: {
3075
                            'symbol': /\b\w+/,
3076
                            'punctuation': /^<<[-~]?'|'$/,
3077
                        }
3078
                    },
3079
                    'string': /[\s\S]+/
3080
                }
3081
            }
3082
        ],
3083
        'command-literal': [
3084
            {
3085
                pattern: RegExp(/%x/.source + percentExpression),
3086
                greedy: true,
3087
                inside: {
3088
                    'interpolation': interpolation,
3089
                    'command': {
3090
                        pattern: /[\s\S]+/,
3091
                        alias: 'string'
3092
                    }
3093
                }
3094
            },
3095
            {
3096
                pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
3097
                greedy: true,
3098
                inside: {
3099
                    'interpolation': interpolation,
3100
                    'command': {
3101
                        pattern: /[\s\S]+/,
3102
                        alias: 'string'
3103
                    }
3104
                }
3105
            }
3106
        ]
3107
    });
3108
 
3109
    delete Prism.languages.ruby.string;
3110
 
3111
    Prism.languages.insertBefore('ruby', 'number', {
3112
        '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/,
3113
        'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
3114
    });
3115
 
3116
    Prism.languages.rb = Prism.languages.ruby;
3117
}(Prism));
3118
 
3119
// restore the original Prism reference
3120
window.Prism = oldprism;
3121
return Prism;
3122
}(undefined, undefined, undefined);
3123
export default prismjs;