phcthemes_admin_panel_pack 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1922 @@
1
+
2
+ /* **********************************************
3
+ Begin prism-core.js
4
+ ********************************************** */
5
+
6
+ /// <reference lib="WebWorker"/>
7
+
8
+ var _self = (typeof window !== 'undefined')
9
+ ? window // if in browser
10
+ : (
11
+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
12
+ ? self // if in worker
13
+ : {} // if in node js
14
+ );
15
+
16
+ /**
17
+ * Prism: Lightweight, robust, elegant syntax highlighting
18
+ *
19
+ * @license MIT <https://opensource.org/licenses/MIT>
20
+ * @author Lea Verou <https://lea.verou.me>
21
+ * @namespace
22
+ * @public
23
+ */
24
+ var Prism = (function (_self){
25
+
26
+ // Private helper vars
27
+ var lang = /\blang(?:uage)?-([\w-]+)\b/i;
28
+ var uniqueId = 0;
29
+
30
+
31
+ var _ = {
32
+ /**
33
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
34
+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
35
+ * additional languages or plugins yourself.
36
+ *
37
+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
38
+ *
39
+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
40
+ * empty Prism object into the global scope before loading the Prism script like this:
41
+ *
42
+ * ```js
43
+ * window.Prism = window.Prism || {};
44
+ * Prism.manual = true;
45
+ * // add a new <script> to load Prism's script
46
+ * ```
47
+ *
48
+ * @default false
49
+ * @type {boolean}
50
+ * @memberof Prism
51
+ * @public
52
+ */
53
+ manual: _self.Prism && _self.Prism.manual,
54
+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
55
+
56
+ /**
57
+ * A namespace for utility methods.
58
+ *
59
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
60
+ * change or disappear at any time.
61
+ *
62
+ * @namespace
63
+ * @memberof Prism
64
+ */
65
+ util: {
66
+ encode: function encode(tokens) {
67
+ if (tokens instanceof Token) {
68
+ return new Token(tokens.type, encode(tokens.content), tokens.alias);
69
+ } else if (Array.isArray(tokens)) {
70
+ return tokens.map(encode);
71
+ } else {
72
+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
73
+ }
74
+ },
75
+
76
+ /**
77
+ * Returns the name of the type of the given value.
78
+ *
79
+ * @param {any} o
80
+ * @returns {string}
81
+ * @example
82
+ * type(null) === 'Null'
83
+ * type(undefined) === 'Undefined'
84
+ * type(123) === 'Number'
85
+ * type('foo') === 'String'
86
+ * type(true) === 'Boolean'
87
+ * type([1, 2]) === 'Array'
88
+ * type({}) === 'Object'
89
+ * type(String) === 'Function'
90
+ * type(/abc+/) === 'RegExp'
91
+ */
92
+ type: function (o) {
93
+ return Object.prototype.toString.call(o).slice(8, -1);
94
+ },
95
+
96
+ /**
97
+ * Returns a unique number for the given object. Later calls will still return the same number.
98
+ *
99
+ * @param {Object} obj
100
+ * @returns {number}
101
+ */
102
+ objId: function (obj) {
103
+ if (!obj['__id']) {
104
+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
105
+ }
106
+ return obj['__id'];
107
+ },
108
+
109
+ /**
110
+ * Creates a deep clone of the given object.
111
+ *
112
+ * The main intended use of this function is to clone language definitions.
113
+ *
114
+ * @param {T} o
115
+ * @param {Record<number, any>} [visited]
116
+ * @returns {T}
117
+ * @template T
118
+ */
119
+ clone: function deepClone(o, visited) {
120
+ visited = visited || {};
121
+
122
+ var clone, id;
123
+ switch (_.util.type(o)) {
124
+ case 'Object':
125
+ id = _.util.objId(o);
126
+ if (visited[id]) {
127
+ return visited[id];
128
+ }
129
+ clone = /** @type {Record<string, any>} */ ({});
130
+ visited[id] = clone;
131
+
132
+ for (var key in o) {
133
+ if (o.hasOwnProperty(key)) {
134
+ clone[key] = deepClone(o[key], visited);
135
+ }
136
+ }
137
+
138
+ return /** @type {any} */ (clone);
139
+
140
+ case 'Array':
141
+ id = _.util.objId(o);
142
+ if (visited[id]) {
143
+ return visited[id];
144
+ }
145
+ clone = [];
146
+ visited[id] = clone;
147
+
148
+ (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
149
+ clone[i] = deepClone(v, visited);
150
+ });
151
+
152
+ return /** @type {any} */ (clone);
153
+
154
+ default:
155
+ return o;
156
+ }
157
+ },
158
+
159
+ /**
160
+ * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
161
+ *
162
+ * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
163
+ *
164
+ * @param {Element} element
165
+ * @returns {string}
166
+ */
167
+ getLanguage: function (element) {
168
+ while (element && !lang.test(element.className)) {
169
+ element = element.parentElement;
170
+ }
171
+ if (element) {
172
+ return (element.className.match(lang) || [, 'none'])[1].toLowerCase();
173
+ }
174
+ return 'none';
175
+ },
176
+
177
+ /**
178
+ * Returns the script element that is currently executing.
179
+ *
180
+ * This does __not__ work for line script element.
181
+ *
182
+ * @returns {HTMLScriptElement | null}
183
+ */
184
+ currentScript: function () {
185
+ if (typeof document === 'undefined') {
186
+ return null;
187
+ }
188
+ if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
189
+ return /** @type {any} */ (document.currentScript);
190
+ }
191
+
192
+ // IE11 workaround
193
+ // we'll get the src of the current script by parsing IE11's error stack trace
194
+ // this will not work for inline scripts
195
+
196
+ try {
197
+ throw new Error();
198
+ } catch (err) {
199
+ // Get file src url from stack. Specifically works with the format of stack traces in IE.
200
+ // A stack will look like this:
201
+ //
202
+ // Error
203
+ // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
204
+ // at Global code (http://localhost/components/prism-core.js:606:1)
205
+
206
+ var src = (/at [^(\r\n]*\((.*):.+:.+\)$/i.exec(err.stack) || [])[1];
207
+ if (src) {
208
+ var scripts = document.getElementsByTagName('script');
209
+ for (var i in scripts) {
210
+ if (scripts[i].src == src) {
211
+ return scripts[i];
212
+ }
213
+ }
214
+ }
215
+ return null;
216
+ }
217
+ },
218
+
219
+ /**
220
+ * Returns whether a given class is active for `element`.
221
+ *
222
+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
223
+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
224
+ * given class is just the given class with a `no-` prefix.
225
+ *
226
+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
227
+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
228
+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
229
+ *
230
+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
231
+ * version of it, the class is considered active.
232
+ *
233
+ * @param {Element} element
234
+ * @param {string} className
235
+ * @param {boolean} [defaultActivation=false]
236
+ * @returns {boolean}
237
+ */
238
+ isActive: function (element, className, defaultActivation) {
239
+ var no = 'no-' + className;
240
+
241
+ while (element) {
242
+ var classList = element.classList;
243
+ if (classList.contains(className)) {
244
+ return true;
245
+ }
246
+ if (classList.contains(no)) {
247
+ return false;
248
+ }
249
+ element = element.parentElement;
250
+ }
251
+ return !!defaultActivation;
252
+ }
253
+ },
254
+
255
+ /**
256
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
257
+ *
258
+ * @namespace
259
+ * @memberof Prism
260
+ * @public
261
+ */
262
+ languages: {
263
+ /**
264
+ * Creates a deep copy of the language with the given id and appends the given tokens.
265
+ *
266
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
267
+ * will be overwritten at its original position.
268
+ *
269
+ * ## Best practices
270
+ *
271
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
272
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
273
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
274
+ *
275
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
276
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
277
+ *
278
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
279
+ * @param {Grammar} redef The new tokens to append.
280
+ * @returns {Grammar} The new language created.
281
+ * @public
282
+ * @example
283
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
284
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
285
+ * // at its original position
286
+ * 'comment': { ... },
287
+ * // CSS doesn't have a 'color' token, so this token will be appended
288
+ * 'color': /\b(?:red|green|blue)\b/
289
+ * });
290
+ */
291
+ extend: function (id, redef) {
292
+ var lang = _.util.clone(_.languages[id]);
293
+
294
+ for (var key in redef) {
295
+ lang[key] = redef[key];
296
+ }
297
+
298
+ return lang;
299
+ },
300
+
301
+ /**
302
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
303
+ *
304
+ * ## Usage
305
+ *
306
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
307
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
308
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
309
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
310
+ * this:
311
+ *
312
+ * ```js
313
+ * Prism.languages.markup.style = {
314
+ * // token
315
+ * };
316
+ * ```
317
+ *
318
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
319
+ * before existing tokens. For the CSS example above, you would use it like this:
320
+ *
321
+ * ```js
322
+ * Prism.languages.insertBefore('markup', 'cdata', {
323
+ * 'style': {
324
+ * // token
325
+ * }
326
+ * });
327
+ * ```
328
+ *
329
+ * ## Special cases
330
+ *
331
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
332
+ * will be ignored.
333
+ *
334
+ * This behavior can be used to insert tokens after `before`:
335
+ *
336
+ * ```js
337
+ * Prism.languages.insertBefore('markup', 'comment', {
338
+ * 'comment': Prism.languages.markup.comment,
339
+ * // tokens after 'comment'
340
+ * });
341
+ * ```
342
+ *
343
+ * ## Limitations
344
+ *
345
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
346
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
347
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
348
+ * deleting properties which is necessary to insert at arbitrary positions.
349
+ *
350
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
351
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
352
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
353
+ *
354
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
355
+ * you hold the target object in a variable, then the value of the variable will not change.
356
+ *
357
+ * ```js
358
+ * var oldMarkup = Prism.languages.markup;
359
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
360
+ *
361
+ * assert(oldMarkup !== Prism.languages.markup);
362
+ * assert(newMarkup === Prism.languages.markup);
363
+ * ```
364
+ *
365
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
366
+ * object to be modified.
367
+ * @param {string} before The key to insert before.
368
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
369
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
370
+ * object to be modified.
371
+ *
372
+ * Defaults to `Prism.languages`.
373
+ * @returns {Grammar} The new grammar object.
374
+ * @public
375
+ */
376
+ insertBefore: function (inside, before, insert, root) {
377
+ root = root || /** @type {any} */ (_.languages);
378
+ var grammar = root[inside];
379
+ /** @type {Grammar} */
380
+ var ret = {};
381
+
382
+ for (var token in grammar) {
383
+ if (grammar.hasOwnProperty(token)) {
384
+
385
+ if (token == before) {
386
+ for (var newToken in insert) {
387
+ if (insert.hasOwnProperty(newToken)) {
388
+ ret[newToken] = insert[newToken];
389
+ }
390
+ }
391
+ }
392
+
393
+ // Do not insert token which also occur in insert. See #1525
394
+ if (!insert.hasOwnProperty(token)) {
395
+ ret[token] = grammar[token];
396
+ }
397
+ }
398
+ }
399
+
400
+ var old = root[inside];
401
+ root[inside] = ret;
402
+
403
+ // Update references in other language definitions
404
+ _.languages.DFS(_.languages, function(key, value) {
405
+ if (value === old && key != inside) {
406
+ this[key] = ret;
407
+ }
408
+ });
409
+
410
+ return ret;
411
+ },
412
+
413
+ // Traverse a language definition with Depth First Search
414
+ DFS: function DFS(o, callback, type, visited) {
415
+ visited = visited || {};
416
+
417
+ var objId = _.util.objId;
418
+
419
+ for (var i in o) {
420
+ if (o.hasOwnProperty(i)) {
421
+ callback.call(o, i, o[i], type || i);
422
+
423
+ var property = o[i],
424
+ propertyType = _.util.type(property);
425
+
426
+ if (propertyType === 'Object' && !visited[objId(property)]) {
427
+ visited[objId(property)] = true;
428
+ DFS(property, callback, null, visited);
429
+ }
430
+ else if (propertyType === 'Array' && !visited[objId(property)]) {
431
+ visited[objId(property)] = true;
432
+ DFS(property, callback, i, visited);
433
+ }
434
+ }
435
+ }
436
+ }
437
+ },
438
+
439
+ plugins: {},
440
+
441
+ /**
442
+ * This is the most high-level function in Prism’s API.
443
+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
444
+ * each one of them.
445
+ *
446
+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
447
+ *
448
+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
449
+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
450
+ * @memberof Prism
451
+ * @public
452
+ */
453
+ highlightAll: function(async, callback) {
454
+ _.highlightAllUnder(document, async, callback);
455
+ },
456
+
457
+ /**
458
+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
459
+ * {@link Prism.highlightElement} on each one of them.
460
+ *
461
+ * The following hooks will be run:
462
+ * 1. `before-highlightall`
463
+ * 2. `before-all-elements-highlight`
464
+ * 3. All hooks of {@link Prism.highlightElement} for each element.
465
+ *
466
+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
467
+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
468
+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
469
+ * @memberof Prism
470
+ * @public
471
+ */
472
+ highlightAllUnder: function(container, async, callback) {
473
+ var env = {
474
+ callback: callback,
475
+ container: container,
476
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
477
+ };
478
+
479
+ _.hooks.run('before-highlightall', env);
480
+
481
+ env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
482
+
483
+ _.hooks.run('before-all-elements-highlight', env);
484
+
485
+ for (var i = 0, element; element = env.elements[i++];) {
486
+ _.highlightElement(element, async === true, env.callback);
487
+ }
488
+ },
489
+
490
+ /**
491
+ * Highlights the code inside a single element.
492
+ *
493
+ * The following hooks will be run:
494
+ * 1. `before-sanity-check`
495
+ * 2. `before-highlight`
496
+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
497
+ * 4. `before-insert`
498
+ * 5. `after-highlight`
499
+ * 6. `complete`
500
+ *
501
+ * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
502
+ * the element's language.
503
+ *
504
+ * @param {Element} element The element containing the code.
505
+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
506
+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
507
+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
508
+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
509
+ *
510
+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
511
+ * asynchronous highlighting to work. You can build your own bundle on the
512
+ * [Download page](https://prismjs.com/download.html).
513
+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
514
+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
515
+ * @memberof Prism
516
+ * @public
517
+ */
518
+ highlightElement: function(element, async, callback) {
519
+ // Find language
520
+ var language = _.util.getLanguage(element);
521
+ var grammar = _.languages[language];
522
+
523
+ // Set language on the element, if not present
524
+ element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
525
+
526
+ // Set language on the parent, for styling
527
+ var parent = element.parentElement;
528
+ if (parent && parent.nodeName.toLowerCase() === 'pre') {
529
+ parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
530
+ }
531
+
532
+ var code = element.textContent;
533
+
534
+ var env = {
535
+ element: element,
536
+ language: language,
537
+ grammar: grammar,
538
+ code: code
539
+ };
540
+
541
+ function insertHighlightedCode(highlightedCode) {
542
+ env.highlightedCode = highlightedCode;
543
+
544
+ _.hooks.run('before-insert', env);
545
+
546
+ env.element.innerHTML = env.highlightedCode;
547
+
548
+ _.hooks.run('after-highlight', env);
549
+ _.hooks.run('complete', env);
550
+ callback && callback.call(env.element);
551
+ }
552
+
553
+ _.hooks.run('before-sanity-check', env);
554
+
555
+ if (!env.code) {
556
+ _.hooks.run('complete', env);
557
+ callback && callback.call(env.element);
558
+ return;
559
+ }
560
+
561
+ _.hooks.run('before-highlight', env);
562
+
563
+ if (!env.grammar) {
564
+ insertHighlightedCode(_.util.encode(env.code));
565
+ return;
566
+ }
567
+
568
+ if (async && _self.Worker) {
569
+ var worker = new Worker(_.filename);
570
+
571
+ worker.onmessage = function(evt) {
572
+ insertHighlightedCode(evt.data);
573
+ };
574
+
575
+ worker.postMessage(JSON.stringify({
576
+ language: env.language,
577
+ code: env.code,
578
+ immediateClose: true
579
+ }));
580
+ }
581
+ else {
582
+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
583
+ }
584
+ },
585
+
586
+ /**
587
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
588
+ * and the language definitions to use, and returns a string with the HTML produced.
589
+ *
590
+ * The following hooks will be run:
591
+ * 1. `before-tokenize`
592
+ * 2. `after-tokenize`
593
+ * 3. `wrap`: On each {@link Token}.
594
+ *
595
+ * @param {string} text A string with the code to be highlighted.
596
+ * @param {Grammar} grammar An object containing the tokens to use.
597
+ *
598
+ * Usually a language definition like `Prism.languages.markup`.
599
+ * @param {string} language The name of the language definition passed to `grammar`.
600
+ * @returns {string} The highlighted HTML.
601
+ * @memberof Prism
602
+ * @public
603
+ * @example
604
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
605
+ */
606
+ highlight: function (text, grammar, language) {
607
+ var env = {
608
+ code: text,
609
+ grammar: grammar,
610
+ language: language
611
+ };
612
+ _.hooks.run('before-tokenize', env);
613
+ env.tokens = _.tokenize(env.code, env.grammar);
614
+ _.hooks.run('after-tokenize', env);
615
+ return Token.stringify(_.util.encode(env.tokens), env.language);
616
+ },
617
+
618
+ /**
619
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
620
+ * and the language definitions to use, and returns an array with the tokenized code.
621
+ *
622
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
623
+ *
624
+ * This method could be useful in other contexts as well, as a very crude parser.
625
+ *
626
+ * @param {string} text A string with the code to be highlighted.
627
+ * @param {Grammar} grammar An object containing the tokens to use.
628
+ *
629
+ * Usually a language definition like `Prism.languages.markup`.
630
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
631
+ * @memberof Prism
632
+ * @public
633
+ * @example
634
+ * let code = `var foo = 0;`;
635
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
636
+ * tokens.forEach(token => {
637
+ * if (token instanceof Prism.Token && token.type === 'number') {
638
+ * console.log(`Found numeric literal: ${token.content}`);
639
+ * }
640
+ * });
641
+ */
642
+ tokenize: function(text, grammar) {
643
+ var rest = grammar.rest;
644
+ if (rest) {
645
+ for (var token in rest) {
646
+ grammar[token] = rest[token];
647
+ }
648
+
649
+ delete grammar.rest;
650
+ }
651
+
652
+ var tokenList = new LinkedList();
653
+ addAfter(tokenList, tokenList.head, text);
654
+
655
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0);
656
+
657
+ return toArray(tokenList);
658
+ },
659
+
660
+ /**
661
+ * @namespace
662
+ * @memberof Prism
663
+ * @public
664
+ */
665
+ hooks: {
666
+ all: {},
667
+
668
+ /**
669
+ * Adds the given callback to the list of callbacks for the given hook.
670
+ *
671
+ * The callback will be invoked when the hook it is registered for is run.
672
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
673
+ *
674
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
675
+ *
676
+ * @param {string} name The name of the hook.
677
+ * @param {HookCallback} callback The callback function which is given environment variables.
678
+ * @public
679
+ */
680
+ add: function (name, callback) {
681
+ var hooks = _.hooks.all;
682
+
683
+ hooks[name] = hooks[name] || [];
684
+
685
+ hooks[name].push(callback);
686
+ },
687
+
688
+ /**
689
+ * Runs a hook invoking all registered callbacks with the given environment variables.
690
+ *
691
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
692
+ *
693
+ * @param {string} name The name of the hook.
694
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
695
+ * @public
696
+ */
697
+ run: function (name, env) {
698
+ var callbacks = _.hooks.all[name];
699
+
700
+ if (!callbacks || !callbacks.length) {
701
+ return;
702
+ }
703
+
704
+ for (var i=0, callback; callback = callbacks[i++];) {
705
+ callback(env);
706
+ }
707
+ }
708
+ },
709
+
710
+ Token: Token
711
+ };
712
+ _self.Prism = _;
713
+
714
+
715
+ // Typescript note:
716
+ // The following can be used to import the Token type in JSDoc:
717
+ //
718
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
719
+
720
+ /**
721
+ * Creates a new token.
722
+ *
723
+ * @param {string} type See {@link Token#type type}
724
+ * @param {string | TokenStream} content See {@link Token#content content}
725
+ * @param {string|string[]} [alias] The alias(es) of the token.
726
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
727
+ * @class
728
+ * @global
729
+ * @public
730
+ */
731
+ function Token(type, content, alias, matchedStr) {
732
+ /**
733
+ * The type of the token.
734
+ *
735
+ * This is usually the key of a pattern in a {@link Grammar}.
736
+ *
737
+ * @type {string}
738
+ * @see GrammarToken
739
+ * @public
740
+ */
741
+ this.type = type;
742
+ /**
743
+ * The strings or tokens contained by this token.
744
+ *
745
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
746
+ *
747
+ * @type {string | TokenStream}
748
+ * @public
749
+ */
750
+ this.content = content;
751
+ /**
752
+ * The alias(es) of the token.
753
+ *
754
+ * @type {string|string[]}
755
+ * @see GrammarToken
756
+ * @public
757
+ */
758
+ this.alias = alias;
759
+ // Copy of the full string this token was created from
760
+ this.length = (matchedStr || '').length | 0;
761
+ }
762
+
763
+ /**
764
+ * A token stream is an array of strings and {@link Token Token} objects.
765
+ *
766
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
767
+ * them.
768
+ *
769
+ * 1. No adjacent strings.
770
+ * 2. No empty strings.
771
+ *
772
+ * The only exception here is the token stream that only contains the empty string and nothing else.
773
+ *
774
+ * @typedef {Array<string | Token>} TokenStream
775
+ * @global
776
+ * @public
777
+ */
778
+
779
+ /**
780
+ * Converts the given token or token stream to an HTML representation.
781
+ *
782
+ * The following hooks will be run:
783
+ * 1. `wrap`: On each {@link Token}.
784
+ *
785
+ * @param {string | Token | TokenStream} o The token or token stream to be converted.
786
+ * @param {string} language The name of current language.
787
+ * @returns {string} The HTML representation of the token or token stream.
788
+ * @memberof Token
789
+ * @static
790
+ */
791
+ Token.stringify = function stringify(o, language) {
792
+ if (typeof o == 'string') {
793
+ return o;
794
+ }
795
+ if (Array.isArray(o)) {
796
+ var s = '';
797
+ o.forEach(function (e) {
798
+ s += stringify(e, language);
799
+ });
800
+ return s;
801
+ }
802
+
803
+ var env = {
804
+ type: o.type,
805
+ content: stringify(o.content, language),
806
+ tag: 'span',
807
+ classes: ['token', o.type],
808
+ attributes: {},
809
+ language: language
810
+ };
811
+
812
+ var aliases = o.alias;
813
+ if (aliases) {
814
+ if (Array.isArray(aliases)) {
815
+ Array.prototype.push.apply(env.classes, aliases);
816
+ } else {
817
+ env.classes.push(aliases);
818
+ }
819
+ }
820
+
821
+ _.hooks.run('wrap', env);
822
+
823
+ var attributes = '';
824
+ for (var name in env.attributes) {
825
+ attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
826
+ }
827
+
828
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
829
+ };
830
+
831
+ /**
832
+ * @param {RegExp} pattern
833
+ * @param {number} pos
834
+ * @param {string} text
835
+ * @param {boolean} lookbehind
836
+ * @returns {RegExpExecArray | null}
837
+ */
838
+ function matchPattern(pattern, pos, text, lookbehind) {
839
+ pattern.lastIndex = pos;
840
+ var match = pattern.exec(text);
841
+ if (match && lookbehind && match[1]) {
842
+ // change the match to remove the text matched by the Prism lookbehind group
843
+ var lookbehindLength = match[1].length;
844
+ match.index += lookbehindLength;
845
+ match[0] = match[0].slice(lookbehindLength);
846
+ }
847
+ return match;
848
+ }
849
+
850
+ /**
851
+ * @param {string} text
852
+ * @param {LinkedList<string | Token>} tokenList
853
+ * @param {any} grammar
854
+ * @param {LinkedListNode<string | Token>} startNode
855
+ * @param {number} startPos
856
+ * @param {RematchOptions} [rematch]
857
+ * @returns {void}
858
+ * @private
859
+ *
860
+ * @typedef RematchOptions
861
+ * @property {string} cause
862
+ * @property {number} reach
863
+ */
864
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
865
+ for (var token in grammar) {
866
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
867
+ continue;
868
+ }
869
+
870
+ var patterns = grammar[token];
871
+ patterns = Array.isArray(patterns) ? patterns : [patterns];
872
+
873
+ for (var j = 0; j < patterns.length; ++j) {
874
+ if (rematch && rematch.cause == token + ',' + j) {
875
+ return;
876
+ }
877
+
878
+ var patternObj = patterns[j],
879
+ inside = patternObj.inside,
880
+ lookbehind = !!patternObj.lookbehind,
881
+ greedy = !!patternObj.greedy,
882
+ alias = patternObj.alias;
883
+
884
+ if (greedy && !patternObj.pattern.global) {
885
+ // Without the global flag, lastIndex won't work
886
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
887
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
888
+ }
889
+
890
+ /** @type {RegExp} */
891
+ var pattern = patternObj.pattern || patternObj;
892
+
893
+ for ( // iterate the token list and keep track of the current token/string position
894
+ var currentNode = startNode.next, pos = startPos;
895
+ currentNode !== tokenList.tail;
896
+ pos += currentNode.value.length, currentNode = currentNode.next
897
+ ) {
898
+
899
+ if (rematch && pos >= rematch.reach) {
900
+ break;
901
+ }
902
+
903
+ var str = currentNode.value;
904
+
905
+ if (tokenList.length > text.length) {
906
+ // Something went terribly wrong, ABORT, ABORT!
907
+ return;
908
+ }
909
+
910
+ if (str instanceof Token) {
911
+ continue;
912
+ }
913
+
914
+ var removeCount = 1; // this is the to parameter of removeBetween
915
+ var match;
916
+
917
+ if (greedy) {
918
+ match = matchPattern(pattern, pos, text, lookbehind);
919
+ if (!match) {
920
+ break;
921
+ }
922
+
923
+ var from = match.index;
924
+ var to = match.index + match[0].length;
925
+ var p = pos;
926
+
927
+ // find the node that contains the match
928
+ p += currentNode.value.length;
929
+ while (from >= p) {
930
+ currentNode = currentNode.next;
931
+ p += currentNode.value.length;
932
+ }
933
+ // adjust pos (and p)
934
+ p -= currentNode.value.length;
935
+ pos = p;
936
+
937
+ // the current node is a Token, then the match starts inside another Token, which is invalid
938
+ if (currentNode.value instanceof Token) {
939
+ continue;
940
+ }
941
+
942
+ // find the last node which is affected by this match
943
+ for (
944
+ var k = currentNode;
945
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
946
+ k = k.next
947
+ ) {
948
+ removeCount++;
949
+ p += k.value.length;
950
+ }
951
+ removeCount--;
952
+
953
+ // replace with the new match
954
+ str = text.slice(pos, p);
955
+ match.index -= pos;
956
+ } else {
957
+ match = matchPattern(pattern, 0, str, lookbehind);
958
+ if (!match) {
959
+ continue;
960
+ }
961
+ }
962
+
963
+ var from = match.index,
964
+ matchStr = match[0],
965
+ before = str.slice(0, from),
966
+ after = str.slice(from + matchStr.length);
967
+
968
+ var reach = pos + str.length;
969
+ if (rematch && reach > rematch.reach) {
970
+ rematch.reach = reach;
971
+ }
972
+
973
+ var removeFrom = currentNode.prev;
974
+
975
+ if (before) {
976
+ removeFrom = addAfter(tokenList, removeFrom, before);
977
+ pos += before.length;
978
+ }
979
+
980
+ removeRange(tokenList, removeFrom, removeCount);
981
+
982
+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
983
+ currentNode = addAfter(tokenList, removeFrom, wrapped);
984
+
985
+ if (after) {
986
+ addAfter(tokenList, currentNode, after);
987
+ }
988
+
989
+ if (removeCount > 1) {
990
+ // at least one Token object was removed, so we have to do some rematching
991
+ // this can only happen if the current pattern is greedy
992
+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, {
993
+ cause: token + ',' + j,
994
+ reach: reach
995
+ });
996
+ }
997
+ }
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ /**
1003
+ * @typedef LinkedListNode
1004
+ * @property {T} value
1005
+ * @property {LinkedListNode<T> | null} prev The previous node.
1006
+ * @property {LinkedListNode<T> | null} next The next node.
1007
+ * @template T
1008
+ * @private
1009
+ */
1010
+
1011
+ /**
1012
+ * @template T
1013
+ * @private
1014
+ */
1015
+ function LinkedList() {
1016
+ /** @type {LinkedListNode<T>} */
1017
+ var head = { value: null, prev: null, next: null };
1018
+ /** @type {LinkedListNode<T>} */
1019
+ var tail = { value: null, prev: head, next: null };
1020
+ head.next = tail;
1021
+
1022
+ /** @type {LinkedListNode<T>} */
1023
+ this.head = head;
1024
+ /** @type {LinkedListNode<T>} */
1025
+ this.tail = tail;
1026
+ this.length = 0;
1027
+ }
1028
+
1029
+ /**
1030
+ * Adds a new node with the given value to the list.
1031
+ * @param {LinkedList<T>} list
1032
+ * @param {LinkedListNode<T>} node
1033
+ * @param {T} value
1034
+ * @returns {LinkedListNode<T>} The added node.
1035
+ * @template T
1036
+ */
1037
+ function addAfter(list, node, value) {
1038
+ // assumes that node != list.tail && values.length >= 0
1039
+ var next = node.next;
1040
+
1041
+ var newNode = { value: value, prev: node, next: next };
1042
+ node.next = newNode;
1043
+ next.prev = newNode;
1044
+ list.length++;
1045
+
1046
+ return newNode;
1047
+ }
1048
+ /**
1049
+ * Removes `count` nodes after the given node. The given node will not be removed.
1050
+ * @param {LinkedList<T>} list
1051
+ * @param {LinkedListNode<T>} node
1052
+ * @param {number} count
1053
+ * @template T
1054
+ */
1055
+ function removeRange(list, node, count) {
1056
+ var next = node.next;
1057
+ for (var i = 0; i < count && next !== list.tail; i++) {
1058
+ next = next.next;
1059
+ }
1060
+ node.next = next;
1061
+ next.prev = node;
1062
+ list.length -= i;
1063
+ }
1064
+ /**
1065
+ * @param {LinkedList<T>} list
1066
+ * @returns {T[]}
1067
+ * @template T
1068
+ */
1069
+ function toArray(list) {
1070
+ var array = [];
1071
+ var node = list.head.next;
1072
+ while (node !== list.tail) {
1073
+ array.push(node.value);
1074
+ node = node.next;
1075
+ }
1076
+ return array;
1077
+ }
1078
+
1079
+
1080
+ if (!_self.document) {
1081
+ if (!_self.addEventListener) {
1082
+ // in Node.js
1083
+ return _;
1084
+ }
1085
+
1086
+ if (!_.disableWorkerMessageHandler) {
1087
+ // In worker
1088
+ _self.addEventListener('message', function (evt) {
1089
+ var message = JSON.parse(evt.data),
1090
+ lang = message.language,
1091
+ code = message.code,
1092
+ immediateClose = message.immediateClose;
1093
+
1094
+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
1095
+ if (immediateClose) {
1096
+ _self.close();
1097
+ }
1098
+ }, false);
1099
+ }
1100
+
1101
+ return _;
1102
+ }
1103
+
1104
+ // Get current script and highlight
1105
+ var script = _.util.currentScript();
1106
+
1107
+ if (script) {
1108
+ _.filename = script.src;
1109
+
1110
+ if (script.hasAttribute('data-manual')) {
1111
+ _.manual = true;
1112
+ }
1113
+ }
1114
+
1115
+ function highlightAutomaticallyCallback() {
1116
+ if (!_.manual) {
1117
+ _.highlightAll();
1118
+ }
1119
+ }
1120
+
1121
+ if (!_.manual) {
1122
+ // If the document state is "loading", then we'll use DOMContentLoaded.
1123
+ // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1124
+ // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1125
+ // might take longer one animation frame to execute which can create a race condition where only some plugins have
1126
+ // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1127
+ // See https://github.com/PrismJS/prism/issues/2102
1128
+ var readyState = document.readyState;
1129
+ if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1130
+ document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1131
+ } else {
1132
+ if (window.requestAnimationFrame) {
1133
+ window.requestAnimationFrame(highlightAutomaticallyCallback);
1134
+ } else {
1135
+ window.setTimeout(highlightAutomaticallyCallback, 16);
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+ return _;
1141
+
1142
+ })(_self);
1143
+
1144
+ if (typeof module !== 'undefined' && module.exports) {
1145
+ module.exports = Prism;
1146
+ }
1147
+
1148
+ // hack for components to work correctly in node.js
1149
+ if (typeof global !== 'undefined') {
1150
+ global.Prism = Prism;
1151
+ }
1152
+
1153
+ // some additional documentation/types
1154
+
1155
+ /**
1156
+ * The expansion of a simple `RegExp` literal to support additional properties.
1157
+ *
1158
+ * @typedef GrammarToken
1159
+ * @property {RegExp} pattern The regular expression of the token.
1160
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1161
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1162
+ * @property {boolean} [greedy=false] Whether the token is greedy.
1163
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
1164
+ * @property {Grammar} [inside] The nested grammar of this token.
1165
+ *
1166
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1167
+ *
1168
+ * This can be used to make nested and even recursive language definitions.
1169
+ *
1170
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1171
+ * each another.
1172
+ * @global
1173
+ * @public
1174
+ */
1175
+
1176
+ /**
1177
+ * @typedef Grammar
1178
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1179
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1180
+ * @global
1181
+ * @public
1182
+ */
1183
+
1184
+ /**
1185
+ * A function which will invoked after an element was successfully highlighted.
1186
+ *
1187
+ * @callback HighlightCallback
1188
+ * @param {Element} element The element successfully highlighted.
1189
+ * @returns {void}
1190
+ * @global
1191
+ * @public
1192
+ */
1193
+
1194
+ /**
1195
+ * @callback HookCallback
1196
+ * @param {Object<string, any>} env The environment variables of the hook.
1197
+ * @returns {void}
1198
+ * @global
1199
+ * @public
1200
+ */
1201
+
1202
+
1203
+ /* **********************************************
1204
+ Begin prism-markup.js
1205
+ ********************************************** */
1206
+
1207
+ Prism.languages.markup = {
1208
+ 'comment': /<!--[\s\S]*?-->/,
1209
+ 'prolog': /<\?[\s\S]+?\?>/,
1210
+ 'doctype': {
1211
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
1212
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1213
+ greedy: true,
1214
+ inside: {
1215
+ 'internal-subset': {
1216
+ pattern: /(\[)[\s\S]+(?=\]>$)/,
1217
+ lookbehind: true,
1218
+ greedy: true,
1219
+ inside: null // see below
1220
+ },
1221
+ 'string': {
1222
+ pattern: /"[^"]*"|'[^']*'/,
1223
+ greedy: true
1224
+ },
1225
+ 'punctuation': /^<!|>$|[[\]]/,
1226
+ 'doctype-tag': /^DOCTYPE/,
1227
+ 'name': /[^\s<>'"]+/
1228
+ }
1229
+ },
1230
+ 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
1231
+ 'tag': {
1232
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1233
+ greedy: true,
1234
+ inside: {
1235
+ 'tag': {
1236
+ pattern: /^<\/?[^\s>\/]+/,
1237
+ inside: {
1238
+ 'punctuation': /^<\/?/,
1239
+ 'namespace': /^[^\s>\/:]+:/
1240
+ }
1241
+ },
1242
+ 'attr-value': {
1243
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1244
+ inside: {
1245
+ 'punctuation': [
1246
+ {
1247
+ pattern: /^=/,
1248
+ alias: 'attr-equals'
1249
+ },
1250
+ /"|'/
1251
+ ]
1252
+ }
1253
+ },
1254
+ 'punctuation': /\/?>/,
1255
+ 'attr-name': {
1256
+ pattern: /[^\s>\/]+/,
1257
+ inside: {
1258
+ 'namespace': /^[^\s>\/:]+:/
1259
+ }
1260
+ }
1261
+
1262
+ }
1263
+ },
1264
+ 'entity': [
1265
+ {
1266
+ pattern: /&[\da-z]{1,8};/i,
1267
+ alias: 'named-entity'
1268
+ },
1269
+ /&#x?[\da-f]{1,8};/i
1270
+ ]
1271
+ };
1272
+
1273
+ Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
1274
+ Prism.languages.markup['entity'];
1275
+ Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
1276
+
1277
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
1278
+ Prism.hooks.add('wrap', function (env) {
1279
+
1280
+ if (env.type === 'entity') {
1281
+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
1282
+ }
1283
+ });
1284
+
1285
+ Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1286
+ /**
1287
+ * Adds an inlined language to markup.
1288
+ *
1289
+ * An example of an inlined language is CSS with `<style>` tags.
1290
+ *
1291
+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1292
+ * case insensitive.
1293
+ * @param {string} lang The language key.
1294
+ * @example
1295
+ * addInlined('style', 'css');
1296
+ */
1297
+ value: function addInlined(tagName, lang) {
1298
+ var includedCdataInside = {};
1299
+ includedCdataInside['language-' + lang] = {
1300
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1301
+ lookbehind: true,
1302
+ inside: Prism.languages[lang]
1303
+ };
1304
+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
1305
+
1306
+ var inside = {
1307
+ 'included-cdata': {
1308
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1309
+ inside: includedCdataInside
1310
+ }
1311
+ };
1312
+ inside['language-' + lang] = {
1313
+ pattern: /[\s\S]+/,
1314
+ inside: Prism.languages[lang]
1315
+ };
1316
+
1317
+ var def = {};
1318
+ def[tagName] = {
1319
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
1320
+ lookbehind: true,
1321
+ greedy: true,
1322
+ inside: inside
1323
+ };
1324
+
1325
+ Prism.languages.insertBefore('markup', 'cdata', def);
1326
+ }
1327
+ });
1328
+
1329
+ Prism.languages.html = Prism.languages.markup;
1330
+ Prism.languages.mathml = Prism.languages.markup;
1331
+ Prism.languages.svg = Prism.languages.markup;
1332
+
1333
+ Prism.languages.xml = Prism.languages.extend('markup', {});
1334
+ Prism.languages.ssml = Prism.languages.xml;
1335
+ Prism.languages.atom = Prism.languages.xml;
1336
+ Prism.languages.rss = Prism.languages.xml;
1337
+
1338
+
1339
+ /* **********************************************
1340
+ Begin prism-css.js
1341
+ ********************************************** */
1342
+
1343
+ (function (Prism) {
1344
+
1345
+ var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
1346
+
1347
+ Prism.languages.css = {
1348
+ 'comment': /\/\*[\s\S]*?\*\//,
1349
+ 'atrule': {
1350
+ pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
1351
+ inside: {
1352
+ 'rule': /^@[\w-]+/,
1353
+ 'selector-function-argument': {
1354
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1355
+ lookbehind: true,
1356
+ alias: 'selector'
1357
+ },
1358
+ 'keyword': {
1359
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1360
+ lookbehind: true
1361
+ }
1362
+ // See rest below
1363
+ }
1364
+ },
1365
+ 'url': {
1366
+ // https://drafts.csswg.org/css-values-3/#urls
1367
+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1368
+ greedy: true,
1369
+ inside: {
1370
+ 'function': /^url/i,
1371
+ 'punctuation': /^\(|\)$/,
1372
+ 'string': {
1373
+ pattern: RegExp('^' + string.source + '$'),
1374
+ alias: 'url'
1375
+ }
1376
+ }
1377
+ },
1378
+ 'selector': RegExp('[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
1379
+ 'string': {
1380
+ pattern: string,
1381
+ greedy: true
1382
+ },
1383
+ 'property': /(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1384
+ 'important': /!important\b/i,
1385
+ 'function': /[-a-z0-9]+(?=\()/i,
1386
+ 'punctuation': /[(){};:,]/
1387
+ };
1388
+
1389
+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
1390
+
1391
+ var markup = Prism.languages.markup;
1392
+ if (markup) {
1393
+ markup.tag.addInlined('style', 'css');
1394
+
1395
+ Prism.languages.insertBefore('inside', 'attr-value', {
1396
+ 'style-attr': {
1397
+ pattern: /(^|["'\s])style\s*=\s*(?:"[^"]*"|'[^']*')/i,
1398
+ lookbehind: true,
1399
+ inside: {
1400
+ 'attr-value': {
1401
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1402
+ inside: {
1403
+ 'style': {
1404
+ pattern: /(["'])[\s\S]+(?=["']$)/,
1405
+ lookbehind: true,
1406
+ alias: 'language-css',
1407
+ inside: Prism.languages.css
1408
+ },
1409
+ 'punctuation': [
1410
+ {
1411
+ pattern: /^=/,
1412
+ alias: 'attr-equals'
1413
+ },
1414
+ /"|'/
1415
+ ]
1416
+ }
1417
+ },
1418
+ 'attr-name': /^style/i
1419
+ }
1420
+ }
1421
+ }, markup.tag);
1422
+ }
1423
+
1424
+ }(Prism));
1425
+
1426
+
1427
+ /* **********************************************
1428
+ Begin prism-clike.js
1429
+ ********************************************** */
1430
+
1431
+ Prism.languages.clike = {
1432
+ 'comment': [
1433
+ {
1434
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1435
+ lookbehind: true,
1436
+ greedy: true
1437
+ },
1438
+ {
1439
+ pattern: /(^|[^\\:])\/\/.*/,
1440
+ lookbehind: true,
1441
+ greedy: true
1442
+ }
1443
+ ],
1444
+ 'string': {
1445
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1446
+ greedy: true
1447
+ },
1448
+ 'class-name': {
1449
+ pattern: /(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,
1450
+ lookbehind: true,
1451
+ inside: {
1452
+ 'punctuation': /[.\\]/
1453
+ }
1454
+ },
1455
+ 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
1456
+ 'boolean': /\b(?:true|false)\b/,
1457
+ 'function': /\w+(?=\()/,
1458
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1459
+ 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1460
+ 'punctuation': /[{}[\];(),.:]/
1461
+ };
1462
+
1463
+
1464
+ /* **********************************************
1465
+ Begin prism-javascript.js
1466
+ ********************************************** */
1467
+
1468
+ Prism.languages.javascript = Prism.languages.extend('clike', {
1469
+ 'class-name': [
1470
+ Prism.languages.clike['class-name'],
1471
+ {
1472
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:prototype|constructor))/,
1473
+ lookbehind: true
1474
+ }
1475
+ ],
1476
+ 'keyword': [
1477
+ {
1478
+ pattern: /((?:^|})\s*)(?:catch|finally)\b/,
1479
+ lookbehind: true
1480
+ },
1481
+ {
1482
+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|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/,
1483
+ lookbehind: true
1484
+ },
1485
+ ],
1486
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1487
+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1488
+ 'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
1489
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1490
+ });
1491
+
1492
+ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
1493
+
1494
+ Prism.languages.insertBefore('javascript', 'keyword', {
1495
+ 'regex': {
1496
+ pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
1497
+ lookbehind: true,
1498
+ greedy: true,
1499
+ inside: {
1500
+ 'regex-source': {
1501
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1502
+ lookbehind: true,
1503
+ alias: 'language-regex',
1504
+ inside: Prism.languages.regex
1505
+ },
1506
+ 'regex-flags': /[a-z]+$/,
1507
+ 'regex-delimiter': /^\/|\/$/
1508
+ }
1509
+ },
1510
+ // This must be declared before keyword because we use "function" inside the look-forward
1511
+ 'function-variable': {
1512
+ 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*=>))/,
1513
+ alias: 'function'
1514
+ },
1515
+ 'parameter': [
1516
+ {
1517
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1518
+ lookbehind: true,
1519
+ inside: Prism.languages.javascript
1520
+ },
1521
+ {
1522
+ pattern: /(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1523
+ inside: Prism.languages.javascript
1524
+ },
1525
+ {
1526
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1527
+ lookbehind: true,
1528
+ inside: Prism.languages.javascript
1529
+ },
1530
+ {
1531
+ 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*\{)/,
1532
+ lookbehind: true,
1533
+ inside: Prism.languages.javascript
1534
+ }
1535
+ ],
1536
+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1537
+ });
1538
+
1539
+ Prism.languages.insertBefore('javascript', 'string', {
1540
+ 'template-string': {
1541
+ pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
1542
+ greedy: true,
1543
+ inside: {
1544
+ 'template-punctuation': {
1545
+ pattern: /^`|`$/,
1546
+ alias: 'string'
1547
+ },
1548
+ 'interpolation': {
1549
+ pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
1550
+ lookbehind: true,
1551
+ inside: {
1552
+ 'interpolation-punctuation': {
1553
+ pattern: /^\${|}$/,
1554
+ alias: 'punctuation'
1555
+ },
1556
+ rest: Prism.languages.javascript
1557
+ }
1558
+ },
1559
+ 'string': /[\s\S]+/
1560
+ }
1561
+ }
1562
+ });
1563
+
1564
+ if (Prism.languages.markup) {
1565
+ Prism.languages.markup.tag.addInlined('script', 'javascript');
1566
+ }
1567
+
1568
+ Prism.languages.js = Prism.languages.javascript;
1569
+
1570
+
1571
+ /* **********************************************
1572
+ Begin prism-file-highlight.js
1573
+ ********************************************** */
1574
+
1575
+ (function () {
1576
+ if (typeof self === 'undefined' || !self.Prism || !self.document) {
1577
+ return;
1578
+ }
1579
+
1580
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
1581
+ if (!Element.prototype.matches) {
1582
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1583
+ }
1584
+
1585
+ var Prism = window.Prism;
1586
+
1587
+ var LOADING_MESSAGE = 'Loading…';
1588
+ var FAILURE_MESSAGE = function (status, message) {
1589
+ return '✖ Error ' + status + ' while fetching file: ' + message;
1590
+ };
1591
+ var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
1592
+
1593
+ var EXTENSIONS = {
1594
+ 'js': 'javascript',
1595
+ 'py': 'python',
1596
+ 'rb': 'ruby',
1597
+ 'ps1': 'powershell',
1598
+ 'psm1': 'powershell',
1599
+ 'sh': 'bash',
1600
+ 'bat': 'batch',
1601
+ 'h': 'c',
1602
+ 'tex': 'latex'
1603
+ };
1604
+
1605
+ var STATUS_ATTR = 'data-src-status';
1606
+ var STATUS_LOADING = 'loading';
1607
+ var STATUS_LOADED = 'loaded';
1608
+ var STATUS_FAILED = 'failed';
1609
+
1610
+ var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
1611
+ + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
1612
+
1613
+ var lang = /\blang(?:uage)?-([\w-]+)\b/i;
1614
+
1615
+ /**
1616
+ * Sets the Prism `language-xxxx` or `lang-xxxx` class to the given language.
1617
+ *
1618
+ * @param {HTMLElement} element
1619
+ * @param {string} language
1620
+ * @returns {void}
1621
+ */
1622
+ function setLanguageClass(element, language) {
1623
+ var className = element.className;
1624
+ className = className.replace(lang, ' ') + ' language-' + language;
1625
+ element.className = className.replace(/\s+/g, ' ').trim();
1626
+ }
1627
+
1628
+
1629
+ Prism.hooks.add('before-highlightall', function (env) {
1630
+ env.selector += ', ' + SELECTOR;
1631
+ });
1632
+
1633
+ Prism.hooks.add('before-sanity-check', function (env) {
1634
+ var pre = /** @type {HTMLPreElement} */ (env.element);
1635
+ if (pre.matches(SELECTOR)) {
1636
+ env.code = ''; // fast-path the whole thing and go to complete
1637
+
1638
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
1639
+
1640
+ // add code element with loading message
1641
+ var code = pre.appendChild(document.createElement('CODE'));
1642
+ code.textContent = LOADING_MESSAGE;
1643
+
1644
+ var src = pre.getAttribute('data-src');
1645
+
1646
+ var language = env.language;
1647
+ if (language === 'none') {
1648
+ // the language might be 'none' because there is no language set;
1649
+ // in this case, we want to use the extension as the language
1650
+ var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
1651
+ language = EXTENSIONS[extension] || extension;
1652
+ }
1653
+
1654
+ // set language classes
1655
+ setLanguageClass(code, language);
1656
+ setLanguageClass(pre, language);
1657
+
1658
+ // preload the language
1659
+ var autoloader = Prism.plugins.autoloader;
1660
+ if (autoloader) {
1661
+ autoloader.loadLanguages(language);
1662
+ }
1663
+
1664
+ // load file
1665
+ var xhr = new XMLHttpRequest();
1666
+ xhr.open('GET', src, true);
1667
+ xhr.onreadystatechange = function () {
1668
+ if (xhr.readyState == 4) {
1669
+ if (xhr.status < 400 && xhr.responseText) {
1670
+ // mark as loaded
1671
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
1672
+
1673
+ // highlight code
1674
+ code.textContent = xhr.responseText;
1675
+ Prism.highlightElement(code);
1676
+
1677
+ } else {
1678
+ // mark as failed
1679
+ pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
1680
+
1681
+ if (xhr.status >= 400) {
1682
+ code.textContent = FAILURE_MESSAGE(xhr.status, xhr.statusText);
1683
+ } else {
1684
+ code.textContent = FAILURE_EMPTY_MESSAGE;
1685
+ }
1686
+ }
1687
+ }
1688
+ };
1689
+ xhr.send(null);
1690
+ }
1691
+ });
1692
+
1693
+ Prism.plugins.fileHighlight = {
1694
+ /**
1695
+ * Executes the File Highlight plugin for all matching `pre` elements under the given container.
1696
+ *
1697
+ * Note: Elements which are already loaded or currently loading will not be touched by this method.
1698
+ *
1699
+ * @param {ParentNode} [container=document]
1700
+ */
1701
+ highlight: function highlight(container) {
1702
+ var elements = (container || document).querySelectorAll(SELECTOR);
1703
+
1704
+ for (var i = 0, element; element = elements[i++];) {
1705
+ Prism.highlightElement(element);
1706
+ }
1707
+ }
1708
+ };
1709
+
1710
+ var logged = false;
1711
+ /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
1712
+ Prism.fileHighlight = function () {
1713
+ if (!logged) {
1714
+ console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
1715
+ logged = true;
1716
+ }
1717
+ Prism.plugins.fileHighlight.highlight.apply(this, arguments);
1718
+ }
1719
+
1720
+ })();
1721
+
1722
+ (function() {
1723
+
1724
+ var assign = Object.assign || function (obj1, obj2) {
1725
+ for (var name in obj2) {
1726
+ if (obj2.hasOwnProperty(name))
1727
+ obj1[name] = obj2[name];
1728
+ }
1729
+ return obj1;
1730
+ }
1731
+
1732
+ function NormalizeWhitespace(defaults) {
1733
+ this.defaults = assign({}, defaults);
1734
+ }
1735
+
1736
+ function toCamelCase(value) {
1737
+ return value.replace(/-(\w)/g, function(match, firstChar) {
1738
+ return firstChar.toUpperCase();
1739
+ });
1740
+ }
1741
+
1742
+ function tabLen(str) {
1743
+ var res = 0;
1744
+ for (var i = 0; i < str.length; ++i) {
1745
+ if (str.charCodeAt(i) == '\t'.charCodeAt(0))
1746
+ res += 3;
1747
+ }
1748
+ return str.length + res;
1749
+ }
1750
+
1751
+ NormalizeWhitespace.prototype = {
1752
+ setDefaults: function (defaults) {
1753
+ this.defaults = assign(this.defaults, defaults);
1754
+ },
1755
+ normalize: function (input, settings) {
1756
+ settings = assign(this.defaults, settings);
1757
+
1758
+ for (var name in settings) {
1759
+ var methodName = toCamelCase(name);
1760
+ if (name !== "normalize" && methodName !== 'setDefaults' &&
1761
+ settings[name] && this[methodName]) {
1762
+ input = this[methodName].call(this, input, settings[name]);
1763
+ }
1764
+ }
1765
+
1766
+ return input;
1767
+ },
1768
+
1769
+ /*
1770
+ * Normalization methods
1771
+ */
1772
+ leftTrim: function (input) {
1773
+ return input.replace(/^\s+/, '');
1774
+ },
1775
+ rightTrim: function (input) {
1776
+ return input.replace(/\s+$/, '');
1777
+ },
1778
+ tabsToSpaces: function (input, spaces) {
1779
+ spaces = spaces|0 || 4;
1780
+ return input.replace(/\t/g, new Array(++spaces).join(' '));
1781
+ },
1782
+ spacesToTabs: function (input, spaces) {
1783
+ spaces = spaces|0 || 4;
1784
+ return input.replace(RegExp(' {' + spaces + '}', 'g'), '\t');
1785
+ },
1786
+ removeTrailing: function (input) {
1787
+ return input.replace(/\s*?$/gm, '');
1788
+ },
1789
+ // Support for deprecated plugin remove-initial-line-feed
1790
+ removeInitialLineFeed: function (input) {
1791
+ return input.replace(/^(?:\r?\n|\r)/, '');
1792
+ },
1793
+ removeIndent: function (input) {
1794
+ var indents = input.match(/^[^\S\n\r]*(?=\S)/gm);
1795
+
1796
+ if (!indents || !indents[0].length)
1797
+ return input;
1798
+
1799
+ indents.sort(function(a, b){return a.length - b.length; });
1800
+
1801
+ if (!indents[0].length)
1802
+ return input;
1803
+
1804
+ return input.replace(RegExp('^' + indents[0], 'gm'), '');
1805
+ },
1806
+ indent: function (input, tabs) {
1807
+ return input.replace(/^[^\S\n\r]*(?=\S)/gm, new Array(++tabs).join('\t') + '$&');
1808
+ },
1809
+ breakLines: function (input, characters) {
1810
+ characters = (characters === true) ? 80 : characters|0 || 80;
1811
+
1812
+ var lines = input.split('\n');
1813
+ for (var i = 0; i < lines.length; ++i) {
1814
+ if (tabLen(lines[i]) <= characters)
1815
+ continue;
1816
+
1817
+ var line = lines[i].split(/(\s+)/g),
1818
+ len = 0;
1819
+
1820
+ for (var j = 0; j < line.length; ++j) {
1821
+ var tl = tabLen(line[j]);
1822
+ len += tl;
1823
+ if (len > characters) {
1824
+ line[j] = '\n' + line[j];
1825
+ len = tl;
1826
+ }
1827
+ }
1828
+ lines[i] = line.join('');
1829
+ }
1830
+ return lines.join('\n');
1831
+ }
1832
+ };
1833
+
1834
+ // Support node modules
1835
+ if (typeof module !== 'undefined' && module.exports) {
1836
+ module.exports = NormalizeWhitespace;
1837
+ }
1838
+
1839
+ // Exit if prism is not loaded
1840
+ if (typeof Prism === 'undefined') {
1841
+ return;
1842
+ }
1843
+
1844
+ Prism.plugins.NormalizeWhitespace = new NormalizeWhitespace({
1845
+ 'remove-trailing': true,
1846
+ 'remove-indent': true,
1847
+ 'left-trim': true,
1848
+ 'right-trim': true,
1849
+ /*'break-lines': 80,
1850
+ 'indent': 2,
1851
+ 'remove-initial-line-feed': false,
1852
+ 'tabs-to-spaces': 4,
1853
+ 'spaces-to-tabs': 4*/
1854
+ });
1855
+
1856
+ Prism.hooks.add('before-sanity-check', function (env) {
1857
+ var Normalizer = Prism.plugins.NormalizeWhitespace;
1858
+
1859
+ // Check settings
1860
+ if (env.settings && env.settings['whitespace-normalization'] === false) {
1861
+ return;
1862
+ }
1863
+
1864
+ // Check classes
1865
+ if (!Prism.util.isActive(env.element, 'whitespace-normalization', true)) {
1866
+ return;
1867
+ }
1868
+
1869
+ // Simple mode if there is no env.element
1870
+ if ((!env.element || !env.element.parentNode) && env.code) {
1871
+ env.code = Normalizer.normalize(env.code, env.settings);
1872
+ return;
1873
+ }
1874
+
1875
+ // Normal mode
1876
+ var pre = env.element.parentNode;
1877
+ if (!env.code || !pre || pre.nodeName.toLowerCase() !== 'pre') {
1878
+ return;
1879
+ }
1880
+
1881
+ var children = pre.childNodes,
1882
+ before = '',
1883
+ after = '',
1884
+ codeFound = false;
1885
+
1886
+ // Move surrounding whitespace from the <pre> tag into the <code> tag
1887
+ for (var i = 0; i < children.length; ++i) {
1888
+ var node = children[i];
1889
+
1890
+ if (node == env.element) {
1891
+ codeFound = true;
1892
+ } else if (node.nodeName === "#text") {
1893
+ if (codeFound) {
1894
+ after += node.nodeValue;
1895
+ } else {
1896
+ before += node.nodeValue;
1897
+ }
1898
+
1899
+ pre.removeChild(node);
1900
+ --i;
1901
+ }
1902
+ }
1903
+
1904
+ if (!env.element.children.length || !Prism.plugins.KeepMarkup) {
1905
+ env.code = before + env.code + after;
1906
+ env.code = Normalizer.normalize(env.code, env.settings);
1907
+ } else {
1908
+ // Preserve markup for keep-markup plugin
1909
+ var html = before + env.element.innerHTML + after;
1910
+ env.element.innerHTML = Normalizer.normalize(html, env.settings);
1911
+ env.code = env.element.textContent;
1912
+ }
1913
+ });
1914
+
1915
+ }());
1916
+
1917
+ Prism.plugins.NormalizeWhitespace.setDefaults({
1918
+ 'remove-trailing': true,
1919
+ 'remove-indent': true,
1920
+ 'left-trim': true,
1921
+ 'right-trim': true
1922
+ });