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