Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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': {
1441 ariadna 1981
            pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
1 efrain 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
1441 ariadna 2096
        },
2097
        'constant': /\b[A-Z][A-Z_\d]+\b/
1 efrain 2098
    });
2099
 
2100
    Prism.languages.insertBefore('java', 'string', {
2101
        'triple-quoted-string': {
2102
            // http://openjdk.java.net/jeps/355#Description
2103
            pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
2104
            greedy: true,
2105
            alias: 'string'
2106
        },
2107
        'char': {
2108
            pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
2109
            greedy: true
2110
        }
2111
    });
2112
 
2113
    Prism.languages.insertBefore('java', 'class-name', {
2114
        'annotation': {
2115
            pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
2116
            lookbehind: true,
2117
            alias: 'punctuation'
2118
        },
2119
        'generics': {
2120
            pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
2121
            inside: {
2122
                'class-name': className,
2123
                'keyword': keywords,
2124
                'punctuation': /[<>(),.:]/,
2125
                'operator': /[?&|]/
2126
            }
2127
        },
2128
        'import': [
2129
            {
2130
                pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
2131
                lookbehind: true,
2132
                inside: {
2133
                    'namespace': className.inside.namespace,
2134
                    'punctuation': /\./,
2135
                    'operator': /\*/,
2136
                    'class-name': /\w+/
2137
                }
2138
            },
2139
            {
2140
                pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
2141
                lookbehind: true,
2142
                alias: 'static',
2143
                inside: {
2144
                    'namespace': className.inside.namespace,
2145
                    'static': /\b\w+$/,
2146
                    'punctuation': /\./,
2147
                    'operator': /\*/,
2148
                    'class-name': /\w+/
2149
                }
2150
            }
2151
        ],
2152
        'namespace': {
2153
            pattern: RegExp(
2154
                /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/
2155
                    .source.replace(/<keyword>/g, function () { return keywords.source; })),
2156
            lookbehind: true,
2157
            inside: {
2158
                'punctuation': /\./,
2159
            }
2160
        }
2161
    });
2162
}(Prism));
2163
 
2164
Prism.languages.javascript = Prism.languages.extend('clike', {
2165
    'class-name': [
2166
        Prism.languages.clike['class-name'],
2167
        {
2168
            pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2169
            lookbehind: true
2170
        }
2171
    ],
2172
    'keyword': [
2173
        {
2174
            pattern: /((?:^|\})\s*)catch\b/,
2175
            lookbehind: true
2176
        },
2177
        {
2178
            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/,
2179
            lookbehind: true
2180
        },
2181
    ],
2182
    // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
2183
    'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
2184
    'number': {
2185
        pattern: RegExp(
2186
            /(^|[^\w$])/.source +
2187
            '(?:' +
2188
            (
2189
                // constant
2190
                /NaN|Infinity/.source +
2191
                '|' +
2192
                // binary integer
2193
                /0[bB][01]+(?:_[01]+)*n?/.source +
2194
                '|' +
2195
                // octal integer
2196
                /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
2197
                '|' +
2198
                // hexadecimal integer
2199
                /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
2200
                '|' +
2201
                // decimal bigint
2202
                /\d+(?:_\d+)*n/.source +
2203
                '|' +
2204
                // decimal number (integer or float) but no bigint
2205
                /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
2206
            ) +
2207
            ')' +
2208
            /(?![\w$])/.source
2209
        ),
2210
        lookbehind: true
2211
    },
2212
    'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
2213
});
2214
 
2215
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
2216
 
2217
Prism.languages.insertBefore('javascript', 'keyword', {
2218
    'regex': {
2219
        pattern: RegExp(
2220
            // lookbehind
2221
            // eslint-disable-next-line regexp/no-dupe-characters-character-class
2222
            /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
2223
            // Regex pattern:
2224
            // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
2225
            // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
2226
            // with the only syntax, so we have to define 2 different regex patterns.
2227
            /\//.source +
2228
            '(?:' +
2229
            /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
2230
            '|' +
2231
            // `v` flag syntax. This supports 3 levels of nested character classes.
2232
            /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
2233
            ')' +
2234
            // lookahead
2235
            /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
2236
        ),
2237
        lookbehind: true,
2238
        greedy: true,
2239
        inside: {
2240
            'regex-source': {
2241
                pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
2242
                lookbehind: true,
2243
                alias: 'language-regex',
2244
                inside: Prism.languages.regex
2245
            },
2246
            'regex-delimiter': /^\/|\/$/,
2247
            'regex-flags': /^[a-z]+$/,
2248
        }
2249
    },
2250
    // This must be declared before keyword because we use "function" inside the look-forward
2251
    'function-variable': {
2252
        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*=>))/,
2253
        alias: 'function'
2254
    },
2255
    'parameter': [
2256
        {
2257
            pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
2258
            lookbehind: true,
2259
            inside: Prism.languages.javascript
2260
        },
2261
        {
2262
            pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
2263
            lookbehind: true,
2264
            inside: Prism.languages.javascript
2265
        },
2266
        {
2267
            pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
2268
            lookbehind: true,
2269
            inside: Prism.languages.javascript
2270
        },
2271
        {
2272
            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*\{)/,
2273
            lookbehind: true,
2274
            inside: Prism.languages.javascript
2275
        }
2276
    ],
2277
    'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
2278
});
2279
 
2280
Prism.languages.insertBefore('javascript', 'string', {
2281
    'hashbang': {
2282
        pattern: /^#!.*/,
2283
        greedy: true,
2284
        alias: 'comment'
2285
    },
2286
    'template-string': {
2287
        pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
2288
        greedy: true,
2289
        inside: {
2290
            'template-punctuation': {
2291
                pattern: /^`|`$/,
2292
                alias: 'string'
2293
            },
2294
            'interpolation': {
2295
                pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
2296
                lookbehind: true,
2297
                inside: {
2298
                    'interpolation-punctuation': {
2299
                        pattern: /^\$\{|\}$/,
2300
                        alias: 'punctuation'
2301
                    },
2302
                    rest: Prism.languages.javascript
2303
                }
2304
            },
2305
            'string': /[\s\S]+/
2306
        }
2307
    },
2308
    'string-property': {
2309
        pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
2310
        lookbehind: true,
2311
        greedy: true,
2312
        alias: 'property'
2313
    }
2314
});
2315
 
2316
Prism.languages.insertBefore('javascript', 'operator', {
2317
    'literal-property': {
2318
        pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
2319
        lookbehind: true,
2320
        alias: 'property'
2321
    },
2322
});
2323
 
2324
if (Prism.languages.markup) {
2325
    Prism.languages.markup.tag.addInlined('script', 'javascript');
2326
 
2327
    // add attribute support for all DOM events.
2328
    // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
2329
    Prism.languages.markup.tag.addAttribute(
2330
        /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,
2331
        'javascript'
2332
    );
2333
}
2334
 
2335
Prism.languages.js = Prism.languages.javascript;
2336
 
2337
Prism.languages.markup = {
2338
    'comment': {
2339
        pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
2340
        greedy: true
2341
    },
2342
    'prolog': {
2343
        pattern: /<\?[\s\S]+?\?>/,
2344
        greedy: true
2345
    },
2346
    'doctype': {
2347
        // https://www.w3.org/TR/xml/#NT-doctypedecl
2348
        pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
2349
        greedy: true,
2350
        inside: {
2351
            'internal-subset': {
2352
                pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
2353
                lookbehind: true,
2354
                greedy: true,
2355
                inside: null // see below
2356
            },
2357
            'string': {
2358
                pattern: /"[^"]*"|'[^']*'/,
2359
                greedy: true
2360
            },
2361
            'punctuation': /^<!|>$|[[\]]/,
2362
            'doctype-tag': /^DOCTYPE/i,
2363
            'name': /[^\s<>'"]+/
2364
        }
2365
    },
2366
    'cdata': {
2367
        pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2368
        greedy: true
2369
    },
2370
    'tag': {
2371
        pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
2372
        greedy: true,
2373
        inside: {
2374
            'tag': {
2375
                pattern: /^<\/?[^\s>\/]+/,
2376
                inside: {
2377
                    'punctuation': /^<\/?/,
2378
                    'namespace': /^[^\s>\/:]+:/
2379
                }
2380
            },
2381
            'special-attr': [],
2382
            'attr-value': {
2383
                pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
2384
                inside: {
2385
                    'punctuation': [
2386
                        {
2387
                            pattern: /^=/,
2388
                            alias: 'attr-equals'
2389
                        },
1441 ariadna 2390
                        {
2391
                            pattern: /^(\s*)["']|["']$/,
2392
                            lookbehind: true
2393
                        }
1 efrain 2394
                    ]
2395
                }
2396
            },
2397
            'punctuation': /\/?>/,
2398
            'attr-name': {
2399
                pattern: /[^\s>\/]+/,
2400
                inside: {
2401
                    'namespace': /^[^\s>\/:]+:/
2402
                }
2403
            }
2404
 
2405
        }
2406
    },
2407
    'entity': [
2408
        {
2409
            pattern: /&[\da-z]{1,8};/i,
2410
            alias: 'named-entity'
2411
        },
2412
        /&#x?[\da-f]{1,8};/i
2413
    ]
2414
};
2415
 
2416
Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
2417
    Prism.languages.markup['entity'];
2418
Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
2419
 
2420
// Plugin to make entity title show the real entity, idea by Roman Komarov
2421
Prism.hooks.add('wrap', function (env) {
2422
 
2423
    if (env.type === 'entity') {
2424
        env.attributes['title'] = env.content.replace(/&amp;/, '&');
2425
    }
2426
});
2427
 
2428
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
2429
    /**
2430
     * Adds an inlined language to markup.
2431
     *
2432
     * An example of an inlined language is CSS with `<style>` tags.
2433
     *
2434
     * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
2435
     * case insensitive.
2436
     * @param {string} lang The language key.
2437
     * @example
2438
     * addInlined('style', 'css');
2439
     */
2440
    value: function addInlined(tagName, lang) {
2441
        var includedCdataInside = {};
2442
        includedCdataInside['language-' + lang] = {
2443
            pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
2444
            lookbehind: true,
2445
            inside: Prism.languages[lang]
2446
        };
2447
        includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
2448
 
2449
        var inside = {
2450
            'included-cdata': {
2451
                pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2452
                inside: includedCdataInside
2453
            }
2454
        };
2455
        inside['language-' + lang] = {
2456
            pattern: /[\s\S]+/,
2457
            inside: Prism.languages[lang]
2458
        };
2459
 
2460
        var def = {};
2461
        def[tagName] = {
2462
            pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
2463
            lookbehind: true,
2464
            greedy: true,
2465
            inside: inside
2466
        };
2467
 
2468
        Prism.languages.insertBefore('markup', 'cdata', def);
2469
    }
2470
});
2471
Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
2472
    /**
2473
     * Adds an pattern to highlight languages embedded in HTML attributes.
2474
     *
2475
     * An example of an inlined language is CSS with `style` attributes.
2476
     *
2477
     * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
2478
     * case insensitive.
2479
     * @param {string} lang The language key.
2480
     * @example
2481
     * addAttribute('style', 'css');
2482
     */
2483
    value: function (attrName, lang) {
2484
        Prism.languages.markup.tag.inside['special-attr'].push({
2485
            pattern: RegExp(
2486
                /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
2487
                'i'
2488
            ),
2489
            lookbehind: true,
2490
            inside: {
2491
                'attr-name': /^[^\s=]+/,
2492
                'attr-value': {
2493
                    pattern: /=[\s\S]+/,
2494
                    inside: {
2495
                        'value': {
2496
                            pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
2497
                            lookbehind: true,
2498
                            alias: [lang, 'language-' + lang],
2499
                            inside: Prism.languages[lang]
2500
                        },
2501
                        'punctuation': [
2502
                            {
2503
                                pattern: /^=/,
2504
                                alias: 'attr-equals'
2505
                            },
2506
                            /"|'/
2507
                        ]
2508
                    }
2509
                }
2510
            }
2511
        });
2512
    }
2513
});
2514
 
2515
Prism.languages.html = Prism.languages.markup;
2516
Prism.languages.mathml = Prism.languages.markup;
2517
Prism.languages.svg = Prism.languages.markup;
2518
 
2519
Prism.languages.xml = Prism.languages.extend('markup', {});
2520
Prism.languages.ssml = Prism.languages.xml;
2521
Prism.languages.atom = Prism.languages.xml;
2522
Prism.languages.rss = Prism.languages.xml;
2523
 
2524
/**
2525
 * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
2526
 * Modified by Miles Johnson: http://milesj.me
2527
 * Rewritten by Tom Pavelec
2528
 *
2529
 * Supports PHP 5.3 - 8.0
2530
 */
2531
(function (Prism) {
2532
    var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
2533
    var constant = [
2534
        {
2535
            pattern: /\b(?:false|true)\b/i,
2536
            alias: 'boolean'
2537
        },
2538
        {
2539
            pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
2540
            greedy: true,
2541
            lookbehind: true,
2542
        },
2543
        {
2544
            pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
2545
            greedy: true,
2546
            lookbehind: true,
2547
        },
2548
        /\b(?:null)\b/i,
2549
        /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/,
2550
    ];
2551
    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;
2552
    var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
2553
    var punctuation = /[{}\[\](),:;]/;
2554
 
2555
    Prism.languages.php = {
2556
        'delimiter': {
2557
            pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
2558
            alias: 'important'
2559
        },
2560
        'comment': comment,
2561
        'variable': /\$+(?:\w+\b|(?=\{))/,
2562
        'package': {
2563
            pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2564
            lookbehind: true,
2565
            inside: {
2566
                'punctuation': /\\/
2567
            }
2568
        },
2569
        'class-name-definition': {
2570
            pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
2571
            lookbehind: true,
2572
            alias: 'class-name'
2573
        },
2574
        'function-definition': {
2575
            pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
2576
            lookbehind: true,
2577
            alias: 'function'
2578
        },
2579
        'keyword': [
2580
            {
2581
                pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
2582
                alias: 'type-casting',
2583
                greedy: true,
2584
                lookbehind: true
2585
            },
2586
            {
2587
                pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
2588
                alias: 'type-hint',
2589
                greedy: true,
2590
                lookbehind: true
2591
            },
2592
            {
2593
                pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
2594
                alias: 'return-type',
2595
                greedy: true,
2596
                lookbehind: true
2597
            },
2598
            {
2599
                pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
2600
                alias: 'type-declaration',
2601
                greedy: true
2602
            },
2603
            {
2604
                pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
2605
                alias: 'type-declaration',
2606
                greedy: true,
2607
                lookbehind: true
2608
            },
2609
            {
2610
                pattern: /\b(?:parent|self|static)(?=\s*::)/i,
2611
                alias: 'static-context',
2612
                greedy: true
2613
            },
2614
            {
2615
                // yield from
2616
                pattern: /(\byield\s+)from\b/i,
2617
                lookbehind: true
2618
            },
2619
            // `class` is always a keyword unlike other keywords
2620
            /\bclass\b/i,
2621
            {
2622
                // https://www.php.net/manual/en/reserved.keywords.php
2623
                //
2624
                // keywords cannot be preceded by "->"
2625
                // the complex lookbehind means `(?<!(?:->|::)\s*)`
2626
                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,
2627
                lookbehind: true
2628
            }
2629
        ],
2630
        'argument-name': {
2631
            pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
2632
            lookbehind: true
2633
        },
2634
        'class-name': [
2635
            {
2636
                pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
2637
                greedy: true,
2638
                lookbehind: true
2639
            },
2640
            {
2641
                pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
2642
                greedy: true,
2643
                lookbehind: true
2644
            },
2645
            {
2646
                pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
2647
                greedy: true
2648
            },
2649
            {
2650
                pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
2651
                alias: 'class-name-fully-qualified',
2652
                greedy: true,
2653
                lookbehind: true,
2654
                inside: {
2655
                    'punctuation': /\\/
2656
                }
2657
            },
2658
            {
2659
                pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
2660
                alias: 'class-name-fully-qualified',
2661
                greedy: true,
2662
                inside: {
2663
                    'punctuation': /\\/
2664
                }
2665
            },
2666
            {
2667
                pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2668
                alias: 'class-name-fully-qualified',
2669
                greedy: true,
2670
                lookbehind: true,
2671
                inside: {
2672
                    'punctuation': /\\/
2673
                }
2674
            },
2675
            {
2676
                pattern: /\b[a-z_]\w*(?=\s*\$)/i,
2677
                alias: 'type-declaration',
2678
                greedy: true
2679
            },
2680
            {
2681
                pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
2682
                alias: ['class-name-fully-qualified', 'type-declaration'],
2683
                greedy: true,
2684
                inside: {
2685
                    'punctuation': /\\/
2686
                }
2687
            },
2688
            {
2689
                pattern: /\b[a-z_]\w*(?=\s*::)/i,
2690
                alias: 'static-context',
2691
                greedy: true
2692
            },
2693
            {
2694
                pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
2695
                alias: ['class-name-fully-qualified', 'static-context'],
2696
                greedy: true,
2697
                inside: {
2698
                    'punctuation': /\\/
2699
                }
2700
            },
2701
            {
2702
                pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
2703
                alias: 'type-hint',
2704
                greedy: true,
2705
                lookbehind: true
2706
            },
2707
            {
2708
                pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
2709
                alias: ['class-name-fully-qualified', 'type-hint'],
2710
                greedy: true,
2711
                lookbehind: true,
2712
                inside: {
2713
                    'punctuation': /\\/
2714
                }
2715
            },
2716
            {
2717
                pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
2718
                alias: 'return-type',
2719
                greedy: true,
2720
                lookbehind: true
2721
            },
2722
            {
2723
                pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2724
                alias: ['class-name-fully-qualified', 'return-type'],
2725
                greedy: true,
2726
                lookbehind: true,
2727
                inside: {
2728
                    'punctuation': /\\/
2729
                }
2730
            }
2731
        ],
2732
        'constant': constant,
2733
        'function': {
2734
            pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
2735
            lookbehind: true,
2736
            inside: {
2737
                'punctuation': /\\/
2738
            }
2739
        },
2740
        'property': {
2741
            pattern: /(->\s*)\w+/,
2742
            lookbehind: true
2743
        },
2744
        'number': number,
2745
        'operator': operator,
2746
        'punctuation': punctuation
2747
    };
2748
 
2749
    var string_interpolation = {
2750
        pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
2751
        lookbehind: true,
2752
        inside: Prism.languages.php
2753
    };
2754
 
2755
    var string = [
2756
        {
2757
            pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
2758
            alias: 'nowdoc-string',
2759
            greedy: true,
2760
            inside: {
2761
                'delimiter': {
2762
                    pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
2763
                    alias: 'symbol',
2764
                    inside: {
2765
                        'punctuation': /^<<<'?|[';]$/
2766
                    }
2767
                }
2768
            }
2769
        },
2770
        {
2771
            pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
2772
            alias: 'heredoc-string',
2773
            greedy: true,
2774
            inside: {
2775
                'delimiter': {
2776
                    pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
2777
                    alias: 'symbol',
2778
                    inside: {
2779
                        'punctuation': /^<<<"?|[";]$/
2780
                    }
2781
                },
2782
                'interpolation': string_interpolation
2783
            }
2784
        },
2785
        {
2786
            pattern: /`(?:\\[\s\S]|[^\\`])*`/,
2787
            alias: 'backtick-quoted-string',
2788
            greedy: true
2789
        },
2790
        {
2791
            pattern: /'(?:\\[\s\S]|[^\\'])*'/,
2792
            alias: 'single-quoted-string',
2793
            greedy: true
2794
        },
2795
        {
2796
            pattern: /"(?:\\[\s\S]|[^\\"])*"/,
2797
            alias: 'double-quoted-string',
2798
            greedy: true,
2799
            inside: {
2800
                'interpolation': string_interpolation
2801
            }
2802
        }
2803
    ];
2804
 
2805
    Prism.languages.insertBefore('php', 'variable', {
2806
        'string': string,
2807
        'attribute': {
2808
            pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
2809
            greedy: true,
2810
            inside: {
2811
                'attribute-content': {
2812
                    pattern: /^(#\[)[\s\S]+(?=\]$)/,
2813
                    lookbehind: true,
2814
                    // inside can appear subset of php
2815
                    inside: {
2816
                        'comment': comment,
2817
                        'string': string,
2818
                        'attribute-class-name': [
2819
                            {
2820
                                pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
2821
                                alias: 'class-name',
2822
                                greedy: true,
2823
                                lookbehind: true
2824
                            },
2825
                            {
2826
                                pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
2827
                                alias: [
2828
                                    'class-name',
2829
                                    'class-name-fully-qualified'
2830
                                ],
2831
                                greedy: true,
2832
                                lookbehind: true,
2833
                                inside: {
2834
                                    'punctuation': /\\/
2835
                                }
2836
                            }
2837
                        ],
2838
                        'constant': constant,
2839
                        'number': number,
2840
                        'operator': operator,
2841
                        'punctuation': punctuation
2842
                    }
2843
                },
2844
                'delimiter': {
2845
                    pattern: /^#\[|\]$/,
2846
                    alias: 'punctuation'
2847
                }
2848
            }
2849
        },
2850
    });
2851
 
2852
    Prism.hooks.add('before-tokenize', function (env) {
2853
        if (!/<\?/.test(env.code)) {
2854
            return;
2855
        }
2856
 
2857
        var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
2858
        Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
2859
    });
2860
 
2861
    Prism.hooks.add('after-tokenize', function (env) {
2862
        Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
2863
    });
2864
 
2865
}(Prism));
2866
 
2867
Prism.languages.python = {
2868
    'comment': {
2869
        pattern: /(^|[^\\])#.*/,
2870
        lookbehind: true,
2871
        greedy: true
2872
    },
2873
    'string-interpolation': {
2874
        pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
2875
        greedy: true,
2876
        inside: {
2877
            'interpolation': {
2878
                // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
2879
                pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
2880
                lookbehind: true,
2881
                inside: {
2882
                    'format-spec': {
2883
                        pattern: /(:)[^:(){}]+(?=\}$)/,
2884
                        lookbehind: true
2885
                    },
2886
                    'conversion-option': {
2887
                        pattern: /![sra](?=[:}]$)/,
2888
                        alias: 'punctuation'
2889
                    },
2890
                    rest: null
2891
                }
2892
            },
2893
            'string': /[\s\S]+/
2894
        }
2895
    },
2896
    'triple-quoted-string': {
2897
        pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
2898
        greedy: true,
2899
        alias: 'string'
2900
    },
2901
    'string': {
2902
        pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
2903
        greedy: true
2904
    },
2905
    'function': {
2906
        pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
2907
        lookbehind: true
2908
    },
2909
    'class-name': {
2910
        pattern: /(\bclass\s+)\w+/i,
2911
        lookbehind: true
2912
    },
2913
    'decorator': {
2914
        pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
2915
        lookbehind: true,
2916
        alias: ['annotation', 'punctuation'],
2917
        inside: {
2918
            'punctuation': /\./
2919
        }
2920
    },
2921
    '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/,
2922
    '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/,
2923
    'boolean': /\b(?:False|None|True)\b/,
2924
    '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,
2925
    'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2926
    'punctuation': /[{}[\];(),.:]/
2927
};
2928
 
2929
Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
2930
 
2931
Prism.languages.py = Prism.languages.python;
2932
 
2933
/**
2934
 * Original by Samuel Flores
2935
 *
2936
 * Adds the following new token classes:
2937
 *     constant, builtin, variable, symbol, regex
2938
 */
2939
(function (Prism) {
2940
    Prism.languages.ruby = Prism.languages.extend('clike', {
2941
        'comment': {
2942
            pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
2943
            greedy: true
2944
        },
2945
        'class-name': {
2946
            pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
2947
            lookbehind: true,
2948
            inside: {
2949
                'punctuation': /[.\\]/
2950
            }
2951
        },
2952
        '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/,
2953
        'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
2954
        'punctuation': /[(){}[\].,;]/,
2955
    });
2956
 
2957
    Prism.languages.insertBefore('ruby', 'operator', {
2958
        'double-colon': {
2959
            pattern: /::/,
2960
            alias: 'punctuation'
2961
        },
2962
    });
2963
 
2964
    var interpolation = {
2965
        pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
2966
        lookbehind: true,
2967
        inside: {
2968
            'content': {
2969
                pattern: /^(#\{)[\s\S]+(?=\}$)/,
2970
                lookbehind: true,
2971
                inside: Prism.languages.ruby
2972
            },
2973
            'delimiter': {
2974
                pattern: /^#\{|\}$/,
2975
                alias: 'punctuation'
2976
            }
2977
        }
2978
    };
2979
 
2980
    delete Prism.languages.ruby.function;
2981
 
2982
    var percentExpression = '(?:' + [
2983
        /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
2984
        /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
2985
        /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
2986
        /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
2987
        /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
2988
    ].join('|') + ')';
2989
 
2990
    var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
2991
 
2992
    Prism.languages.insertBefore('ruby', 'keyword', {
2993
        'regex-literal': [
2994
            {
2995
                pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
2996
                greedy: true,
2997
                inside: {
2998
                    'interpolation': interpolation,
2999
                    'regex': /[\s\S]+/
3000
                }
3001
            },
3002
            {
3003
                pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
3004
                lookbehind: true,
3005
                greedy: true,
3006
                inside: {
3007
                    'interpolation': interpolation,
3008
                    'regex': /[\s\S]+/
3009
                }
3010
            }
3011
        ],
3012
        'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
3013
        'symbol': [
3014
            {
3015
                pattern: RegExp(/(^|[^:]):/.source + symbolName),
3016
                lookbehind: true,
3017
                greedy: true
3018
            },
3019
            {
3020
                pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
3021
                lookbehind: true,
3022
                greedy: true
3023
            },
3024
        ],
3025
        'method-definition': {
3026
            pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
3027
            lookbehind: true,
3028
            inside: {
3029
                'function': /\b\w+$/,
3030
                'keyword': /^self\b/,
3031
                'class-name': /^\w+/,
3032
                'punctuation': /\./
3033
            }
3034
        }
3035
    });
3036
 
3037
    Prism.languages.insertBefore('ruby', 'string', {
3038
        'string-literal': [
3039
            {
3040
                pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
3041
                greedy: true,
3042
                inside: {
3043
                    'interpolation': interpolation,
3044
                    'string': /[\s\S]+/
3045
                }
3046
            },
3047
            {
3048
                pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
3049
                greedy: true,
3050
                inside: {
3051
                    'interpolation': interpolation,
3052
                    'string': /[\s\S]+/
3053
                }
3054
            },
3055
            {
3056
                pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
3057
                alias: 'heredoc-string',
3058
                greedy: true,
3059
                inside: {
3060
                    'delimiter': {
3061
                        pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
3062
                        inside: {
3063
                            'symbol': /\b\w+/,
3064
                            'punctuation': /^<<[-~]?/
3065
                        }
3066
                    },
3067
                    'interpolation': interpolation,
3068
                    'string': /[\s\S]+/
3069
                }
3070
            },
3071
            {
3072
                pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
3073
                alias: 'heredoc-string',
3074
                greedy: true,
3075
                inside: {
3076
                    'delimiter': {
3077
                        pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
3078
                        inside: {
3079
                            'symbol': /\b\w+/,
3080
                            'punctuation': /^<<[-~]?'|'$/,
3081
                        }
3082
                    },
3083
                    'string': /[\s\S]+/
3084
                }
3085
            }
3086
        ],
3087
        'command-literal': [
3088
            {
3089
                pattern: RegExp(/%x/.source + percentExpression),
3090
                greedy: true,
3091
                inside: {
3092
                    'interpolation': interpolation,
3093
                    'command': {
3094
                        pattern: /[\s\S]+/,
3095
                        alias: 'string'
3096
                    }
3097
                }
3098
            },
3099
            {
3100
                pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
3101
                greedy: true,
3102
                inside: {
3103
                    'interpolation': interpolation,
3104
                    'command': {
3105
                        pattern: /[\s\S]+/,
3106
                        alias: 'string'
3107
                    }
3108
                }
3109
            }
3110
        ]
3111
    });
3112
 
3113
    delete Prism.languages.ruby.string;
3114
 
3115
    Prism.languages.insertBefore('ruby', 'number', {
3116
        '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/,
3117
        'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
3118
    });
3119
 
3120
    Prism.languages.rb = Prism.languages.ruby;
3121
}(Prism));
3122
 
3123
// restore the original Prism reference
3124
window.Prism = oldprism;
3125
return Prism;
3126
}(undefined, undefined, undefined);
1441 ariadna 3127
export default prismjs;