1 2/* ********************************************** 3 Begin prism-core.js 4********************************************** */ 5 6var _self = (typeof window !== 'undefined') 7 ? window // if in browser 8 : ( 9 (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) 10 ? self // if in worker 11 : {} // if in node js 12 ); 13 14/** 15 * Prism: Lightweight, robust, elegant syntax highlighting 16 * MIT license http://www.opensource.org/licenses/mit-license.php/ 17 * @author Lea Verou http://lea.verou.me 18 */ 19 20var Prism = (function (_self){ 21 22// Private helper vars 23var lang = /\blang(?:uage)?-([\w-]+)\b/i; 24var uniqueId = 0; 25 26var _ = { 27 manual: _self.Prism && _self.Prism.manual, 28 disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, 29 util: { 30 encode: function (tokens) { 31 if (tokens instanceof Token) { 32 return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias); 33 } else if (Array.isArray(tokens)) { 34 return tokens.map(_.util.encode); 35 } else { 36 return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' '); 37 } 38 }, 39 40 type: function (o) { 41 return Object.prototype.toString.call(o).slice(8, -1); 42 }, 43 44 objId: function (obj) { 45 if (!obj['__id']) { 46 Object.defineProperty(obj, '__id', { value: ++uniqueId }); 47 } 48 return obj['__id']; 49 }, 50 51 // Deep clone a language definition (e.g. to extend it) 52 clone: function deepClone(o, visited) { 53 var clone, id, type = _.util.type(o); 54 visited = visited || {}; 55 56 switch (type) { 57 case 'Object': 58 id = _.util.objId(o); 59 if (visited[id]) { 60 return visited[id]; 61 } 62 clone = {}; 63 visited[id] = clone; 64 65 for (var key in o) { 66 if (o.hasOwnProperty(key)) { 67 clone[key] = deepClone(o[key], visited); 68 } 69 } 70 71 return clone; 72 73 case 'Array': 74 id = _.util.objId(o); 75 if (visited[id]) { 76 return visited[id]; 77 } 78 clone = []; 79 visited[id] = clone; 80 81 o.forEach(function (v, i) { 82 clone[i] = deepClone(v, visited); 83 }); 84 85 return clone; 86 87 default: 88 return o; 89 } 90 } 91 }, 92 93 languages: { 94 extend: function (id, redef) { 95 var lang = _.util.clone(_.languages[id]); 96 97 for (var key in redef) { 98 lang[key] = redef[key]; 99 } 100 101 return lang; 102 }, 103 104 /** 105 * Insert a token before another token in a language literal 106 * As this needs to recreate the object (we cannot actually insert before keys in object literals), 107 * we cannot just provide an object, we need an object and a key. 108 * @param inside The key (or language id) of the parent 109 * @param before The key to insert before. 110 * @param insert Object with the key/value pairs to insert 111 * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted. 112 */ 113 insertBefore: function (inside, before, insert, root) { 114 root = root || _.languages; 115 var grammar = root[inside]; 116 var ret = {}; 117 118 for (var token in grammar) { 119 if (grammar.hasOwnProperty(token)) { 120 121 if (token == before) { 122 for (var newToken in insert) { 123 if (insert.hasOwnProperty(newToken)) { 124 ret[newToken] = insert[newToken]; 125 } 126 } 127 } 128 129 // Do not insert token which also occur in insert. See #1525 130 if (!insert.hasOwnProperty(token)) { 131 ret[token] = grammar[token]; 132 } 133 } 134 } 135 136 var old = root[inside]; 137 root[inside] = ret; 138 139 // Update references in other language definitions 140 _.languages.DFS(_.languages, function(key, value) { 141 if (value === old && key != inside) { 142 this[key] = ret; 143 } 144 }); 145 146 return ret; 147 }, 148 149 // Traverse a language definition with Depth First Search 150 DFS: function DFS(o, callback, type, visited) { 151 visited = visited || {}; 152 153 var objId = _.util.objId; 154 155 for (var i in o) { 156 if (o.hasOwnProperty(i)) { 157 callback.call(o, i, o[i], type || i); 158 159 var property = o[i], 160 propertyType = _.util.type(property); 161 162 if (propertyType === 'Object' && !visited[objId(property)]) { 163 visited[objId(property)] = true; 164 DFS(property, callback, null, visited); 165 } 166 else if (propertyType === 'Array' && !visited[objId(property)]) { 167 visited[objId(property)] = true; 168 DFS(property, callback, i, visited); 169 } 170 } 171 } 172 } 173 }, 174 plugins: {}, 175 176 highlightAll: function(async, callback) { 177 _.highlightAllUnder(document, async, callback); 178 }, 179 180 highlightAllUnder: function(container, async, callback) { 181 var env = { 182 callback: callback, 183 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' 184 }; 185 186 _.hooks.run("before-highlightall", env); 187 188 var elements = env.elements || container.querySelectorAll(env.selector); 189 190 for (var i=0, element; element = elements[i++];) { 191 _.highlightElement(element, async === true, env.callback); 192 } 193 }, 194 195 highlightElement: function(element, async, callback) { 196 // Find language 197 var language, grammar, parent = element; 198 199 while (parent && !lang.test(parent.className)) { 200 parent = parent.parentNode; 201 } 202 203 if (parent) { 204 language = (parent.className.match(lang) || [,''])[1].toLowerCase(); 205 grammar = _.languages[language]; 206 } 207 208 // Set language on the element, if not present 209 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; 210 211 if (element.parentNode) { 212 // Set language on the parent, for styling 213 parent = element.parentNode; 214 215 if (/pre/i.test(parent.nodeName)) { 216 parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; 217 } 218 } 219 220 var code = element.textContent; 221 222 var env = { 223 element: element, 224 language: language, 225 grammar: grammar,
226 code: code 227 }; 228 229 var insertHighlightedCode = function (highlightedCode) { 230 env.highlightedCode = highlightedCode; 231 232 _.hooks.run('before-insert', env); 233 234 env.element.innerHTML = env.highlightedCode; 235 236 _.hooks.run('after-highlight', env); 237 _.hooks.run('complete', env); 238 callback && callback.call(env.element); 239 } 240 241 _.hooks.run('before-sanity-check', env); 242 243 if (!env.code) { 244 _.hooks.run('complete', env); 245 return; 246 } 247 248 _.hooks.run('before-highlight', env); 249 250 if (!env.grammar) { 251 insertHighlightedCode(_.util.encode(env.code)); 252 return; 253 } 254 255 if (async && _self.Worker) { 256 var worker = new Worker(_.filename); 257 258 worker.onmessage = function(evt) { 259 insertHighlightedCode(evt.data); 260 }; 261 262 worker.postMessage(JSON.stringify({ 263 language: env.language, 264 code: env.code, 265 immediateClose: true 266 })); 267 } 268 else { 269 insertHighlightedCode(_.highlight(env.code, env.grammar, env.language)); 270 } 271 }, 272 273 highlight: function (text, grammar, language) { 274 var env = { 275 code: text, 276 grammar: grammar, 277 language: language 278 }; 279 _.hooks.run('before-tokenize', env); 280 env.tokens = _.tokenize(env.code, env.grammar); 281 _.hooks.run('after-tokenize', env); 282 return Token.stringify(_.util.encode(env.tokens), env.language); 283 }, 284 285 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) { 286 for (var token in grammar) { 287 if(!grammar.hasOwnProperty(token) || !grammar[token]) { 288 continue; 289 } 290 291 if (token == target) { 292 return; 293 } 294 295 var patterns = grammar[token]; 296 patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns]; 297 298 for (var j = 0; j < patterns.length; ++j) { 299 var pattern = patterns[j], 300 inside = pattern.inside, 301 lookbehind = !!pattern.lookbehind, 302 greedy = !!pattern.greedy, 303 lookbehindLength = 0, 304 alias = pattern.alias; 305 306 if (greedy && !pattern.pattern.global) { 307 // Without the global flag, lastIndex won't work 308 var flags = pattern.pattern.toString().match(/[imuy]*$/)[0]; 309 pattern.pattern = RegExp(pattern.pattern.source, flags + "g"); 310 } 311 312 pattern = pattern.pattern || pattern; 313 314 // Donât cache length as it changes during the loop 315 for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) { 316 317 var str = strarr[i]; 318 319 if (strarr.length > text.length) { 320 // Something went terribly wrong, ABORT, ABORT! 321 return; 322 } 323 324 if (str instanceof Token) { 325 continue; 326 } 327 328 if (greedy && i != strarr.length - 1) { 329 pattern.lastIndex = pos; 330 var match = pattern.exec(text); 331 if (!match) { 332 break; 333 } 334 335 var from = match.index + (lookbehind ? match[1].length : 0), 336 to = match.index + match[0].length, 337 k = i, 338 p = pos; 339 340 for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) { 341 p += strarr[k].length; 342 // Move the index i to the element in strarr that is closest to from 343 if (from >= p) { 344 ++i; 345 pos = p; 346 } 347 } 348 349 // If strarr[i] is a Token, then the match starts inside another Token, which is invalid 350 if (strarr[i] instanceof Token) { 351 continue; 352 } 353 354 // Number of tokens to delete and replace with the new match 355 delNum = k - i; 356 str = text.slice(pos, p); 357 match.index -= pos; 358 } else { 359 pattern.lastIndex = 0; 360 361 var match = pattern.exec(str), 362 delNum = 1; 363 } 364 365 if (!match) { 366 if (oneshot) { 367 break; 368 } 369 370 continue; 371 } 372 373 if(lookbehind) { 374 lookbehindLength = match[1] ? match[1].length : 0; 375 } 376 377 var from = match.index + lookbehindLength, 378 match = match[0].slice(lookbehindLength), 379 to = from + match.length, 380 before = str.slice(0, from), 381 after = str.slice(to); 382 383 var args = [i, delNum]; 384 385 if (before) { 386 ++i; 387 pos += before.length; 388 args.push(before); 389 } 390 391 var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy); 392 393 args.push(wrapped); 394 395 if (after) { 396 args.push(after); 397 } 398 399 Array.prototype.splice.apply(strarr, args); 400 401 if (delNum != 1) 402 _.matchGrammar(text, strarr, grammar, i, pos, true, token); 403 404 if (oneshot) 405 break; 406 } 407 } 408 } 409 }, 410 411 tokenize: function(text, grammar) { 412 var strarr = [text]; 413 414 var rest = grammar.rest; 415 416 if (rest) { 417 for (var token in rest) { 418 grammar[token] = rest[token]; 419 } 420 421 delete grammar.rest; 422 } 423 424 _.matchGrammar(text, strarr, grammar, 0, 0, false); 425 426 return strarr; 427 }, 428 429 hooks: { 430 all: {}, 431 432 add: function (name, callback) { 433 var hooks = _.hooks.all; 434 435 hooks[name] = hooks[name] || []; 436 437 hooks[name].push(callback); 438 }, 439 440 run: function (name, env) { 441 var callbacks = _.hooks.all[name]; 442 443 if (!callbacks || !callbacks.length) { 444 return; 445 } 446 447 for (var i=0, callback; callback = callbacks[i++];) { 448 callback(env); 449 } 450 } 451 }, 452 453 Token: Token 454}; 455 456_self.Prism = _; 457 458function Token(type, content, alias, matchedStr, greedy) { 459 this.type = type; 460 this.content = content; 461 this.alias = alias; 462 // Copy of the full string this token was created from 463 this.length = (matchedStr || "").length|0; 464 this.greedy = !!greedy; 465} 466 467Token.stringify = function(o, language, parent) { 468 if (typeof o == 'string') { 469 return o; 470 } 471 472 if (Array.isArray(o)) { 473 return o.map(function(element) { 474 return Token.stringify(element, language, o); 475 }).join(''); 476 } 477 478 var env = { 479 type: o.type, 480 content: Token.stringify(o.content, language, parent), 481 tag: 'span', 482 classes: ['token', o.type], 483 attributes: {}, 484 language: language, 485 parent: parent 486 }; 487 488 if (o.alias) { 489 var aliases = Array.isArray(o.alias) ? o.alias : [o.alias];
490 Array.prototype.push.apply(env.classes, aliases); 491 } 492 493 _.hooks.run('wrap', env); 494 495 var attributes = Object.keys(env.attributes).map(function(name) { 496 return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; 497 }).join(' '); 498 499 return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>'; 500 501}; 502 503if (!_self.document) { 504 if (!_self.addEventListener) { 505 // in Node.js 506 return _; 507 } 508 509 if (!_.disableWorkerMessageHandler) { 510 // In worker 511 _self.addEventListener('message', function (evt) { 512 var message = JSON.parse(evt.data), 513 lang = message.language, 514 code = message.code, 515 immediateClose = message.immediateClose; 516 517 _self.postMessage(_.highlight(code, _.languages[lang], lang)); 518 if (immediateClose) { 519 _self.close(); 520 } 521 }, false); 522 } 523 524 return _; 525} 526 527//Get current script and highlight 528var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); 529 530if (script) { 531 _.filename = script.src; 532 533 if (!_.manual && !script.hasAttribute('data-manual')) { 534 if(document.readyState !== "loading") { 535 if (window.requestAnimationFrame) { 536 window.requestAnimationFrame(_.highlightAll); 537 } else { 538 window.setTimeout(_.highlightAll, 16); 539 } 540 } 541 else { 542 document.addEventListener('DOMContentLoaded', _.highlightAll); 543 } 544 } 545} 546 547return _; 548 549})(_self); 550 551if (typeof module !== 'undefined' && module.exports) { 552 module.exports = Prism; 553} 554 555// hack for components to work correctly in node.js 556if (typeof global !== 'undefined') { 557 global.Prism = Prism; 558} 559 560 561/* ********************************************** 562 Begin prism-markup.js 563********************************************** */ 564 565Prism.languages.markup = { 566 'comment': /<!--[\s\S]*?-->/, 567 'prolog': /<\?[\s\S]+?\?>/, 568 'doctype': /<!DOCTYPE[\s\S]+?>/i, 569 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i, 570 'tag': { 571 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i, 572 greedy: true, 573 inside: { 574 'tag': { 575 pattern: /^<\/?[^\s>\/]+/i, 576 inside: { 577 'punctuation': /^<\/?/, 578 'namespace': /^[^\s>\/:]+:/ 579 } 580 }, 581 'attr-value': { 582 pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i, 583 inside: { 584 'punctuation': [ 585 /^=/, 586 { 587 pattern: /^(\s*)["']|["']$/, 588 lookbehind: true 589 } 590 ] 591 } 592 }, 593 'punctuation': /\/?>/, 594 'attr-name': { 595 pattern: /[^\s>\/]+/, 596 inside: { 597 'namespace': /^[^\s>\/:]+:/ 598 } 599 } 600 601 } 602 }, 603 'entity': /&#?[\da-z]{1,8};/i 604}; 605 606Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = 607 Prism.languages.markup['entity']; 608 609// Plugin to make entity title show the real entity, idea by Roman Komarov 610Prism.hooks.add('wrap', function(env) { 611 612 if (env.type === 'entity') { 613 env.attributes['title'] = env.content.replace(/&/, '&'); 614 } 615}); 616 617Object.defineProperty(Prism.languages.markup.tag, 'addInlined', { 618 /** 619 * Adds an inlined language to markup. 620 * 621 * An example of an inlined language is CSS with `<style>` tags. 622 * 623 * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as 624 * case insensitive. 625 * @param {string} lang The language key. 626 * @example 627 * addInlined('style', 'css'); 628 */ 629 value: function addInlined(tagName, lang) { 630 var includedCdataInside = {}; 631 includedCdataInside['language-' + lang] = { 632 pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, 633 lookbehind: true, 634 inside: Prism.languages[lang] 635 }; 636 includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i; 637 638 var inside = { 639 'included-cdata': { 640 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 641 inside: includedCdataInside 642 } 643 }; 644 inside['language-' + lang] = { 645 pattern: /[\s\S]+/, 646 inside: Prism.languages[lang] 647 }; 648 649 var def = {}; 650 def[tagName] = { 651 pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'), 652 lookbehind: true, 653 greedy: true, 654 inside: inside 655 }; 656 657 Prism.languages.insertBefore('markup', 'cdata', def); 658 } 659}); 660 661Prism.languages.xml = Prism.languages.extend('markup', {}); 662Prism.languages.html = Prism.languages.markup; 663Prism.languages.mathml = Prism.languages.markup; 664Prism.languages.svg = Prism.languages.markup; 665 666 667/* ********************************************** 668 Begin prism-css.js 669********************************************** */ 670 671(function (Prism) { 672 673 var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/; 674 675 Prism.languages.css = { 676 'comment': /\/\*[\s\S]*?\*\//, 677 'atrule': { 678 pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i, 679 inside: { 680 'rule': /@[\w-]+/ 681 // See rest below 682 } 683 }, 684 'url': RegExp('url\\((?:' + string.source + '|.*?)\\)', 'i'), 685 'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'), 686 'string': { 687 pattern: string, 688 greedy: true 689 }, 690 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, 691 'important': /!important\b/i, 692 'function': /[-a-z0-9]+(?=\()/i, 693 'punctuation': /[(){};:,]/ 694 }; 695 696 Prism.languages.css['atrule'].inside.rest = Prism.languages.css; 697 698 var markup = Prism.languages.markup; 699 if (markup) { 700 markup.tag.addInlined('style', 'css'); 701 702 Prism.languages.insertBefore('inside', 'attr-value', { 703 'style-attr': { 704 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, 705 inside: { 706 'attr-name': { 707 pattern: /^\s*style/i, 708 inside: markup.tag.inside 709 }, 710 'punctuation': /^\s*=\s*['"]|['"]\s*$/, 711 'attr-value': { 712 pattern: /.+/i, 713 inside: Prism.languages.css 714 } 715 }, 716 alias: 'language-css' 717 } 718 }, markup.tag); 719 } 720 721}(Prism)); 722 723 724/* ********************************************** 725 Begin prism-clike.js 726********************************************** */ 727 728Prism.languages.clike = { 729 'comment': [ 730 { 731 pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, 732 lookbehind: true 733 }, 734 { 735 pattern: /(^|[^\\:])\/\/.*/, 736 lookbehind: true, 737 greedy: true 738 } 739 ], 740 'string': { 741 pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 742 greedy: true 743 }, 744 'class-name': { 745 pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i, 746 lookbehind: true, 747 inside: { 748 punctuation: /[.\\]/ 749 } 750 }, 751 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, 752 'boolean': /\b(?:true|false)\b/, 753 'function': /\w+(?=\()/, 754 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, 755 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, 756 'punctuation': /[{}[\];(),.:]/ 757}; 758 759 760/* ********************************************** 761 Begin prism-javascript.js 762********************************************** */ 763 764Prism.languages.javascript = Prism.languages.extend('clike', { 765 'class-name': [ 766 Prism.languages.clike['class-name'], 767 { 768 pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/, 769 lookbehind: true 770 } 771 ], 772 'keyword': [ 773 { 774 pattern: /((?:^|})\s*)(?:catch|finally)\b/, 775 lookbehind: true 776 }, 777 { 778 pattern: /(^|[^.])\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|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)\b/, 779 lookbehind: true 780 }, 781 ], 782 'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, 783 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) 784 'function': /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, 785 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/ 786}); 787 788Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/ 789 790Prism.languages.insertBefore('javascript', 'keyword', { 791 'regex': { 792 pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, 793 lookbehind: true, 794 greedy: true 795 }, 796 // This must be declared before keyword because we use "function" inside the look-forward 797 'function-variable': { 798 pattern: /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]
798*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/, 799 alias: 'function' 800 }, 801 'parameter': [ 802 { 803 pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/, 804 lookbehind: true, 805 inside: Prism.languages.javascript 806 }, 807 { 808 pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i, 809 inside: Prism.languages.javascript 810 }, 811 { 812 pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/, 813 lookbehind: true, 814 inside: Prism.languages.javascript 815 }, 816 { 817 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]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/, 818 lookbehind: true, 819 inside: Prism.languages.javascript 820 } 821 ], 822 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/ 823}); 824 825Prism.languages.insertBefore('javascript', 'string', { 826 'template-string': { 827 pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, 828 greedy: true, 829 inside: { 830 'interpolation': { 831 pattern: /\${[^}]+}/, 832 inside: { 833 'interpolation-punctuation': { 834 pattern: /^\${|}$/, 835 alias: 'punctuation' 836 }, 837 rest: Prism.languages.javascript 838 } 839 }, 840 'string': /[\s\S]+/ 841 } 842 } 843}); 844 845if (Prism.languages.markup) { 846 Prism.languages.markup.tag.addInlined('script', 'javascript'); 847} 848 849Prism.languages.js = Prism.languages.javascript; 850 851 852/* ********************************************** 853 Begin prism-file-highlight.js 854********************************************** */ 855 856(function () { 857 if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) { 858 return; 859 } 860 861 /** 862 * @param {Element} [container=document] 863 */ 864 self.Prism.fileHighlight = function(container) { 865 container = container || document; 866 867 var Extensions = { 868 'js': 'javascript', 869 'py': 'python', 870 'rb': 'ruby', 871 'ps1': 'powershell', 872 'psm1': 'powershell', 873 'sh': 'bash', 874 'bat': 'batch', 875 'h': 'c', 876 'tex': 'latex' 877 }; 878 879 Array.prototype.slice.call(container.querySelectorAll('pre[data-src]')).forEach(function (pre) { 880 // ignore if already loaded 881 if (pre.hasAttribute('data-src-loaded')) { 882 return; 883 } 884 885 // load current 886 var src = pre.getAttribute('data-src'); 887 888 var language, parent = pre; 889 var lang = /\blang(?:uage)?-([\w-]+)\b/i; 890 while (parent && !lang.test(parent.className)) { 891 parent = parent.parentNode; 892 } 893 894 if (parent) { 895 language = (pre.className.match(lang) || [, ''])[1]; 896 } 897 898 if (!language) { 899 var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; 900 language = Extensions[extension] || extension; 901 } 902 903 var code = document.createElement('code'); 904 code.className = 'language-' + language; 905 906 pre.textContent = ''; 907 908 code.textContent = 'Loadingâ¦'; 909 910 pre.appendChild(code); 911 912 var xhr = new XMLHttpRequest(); 913 914 xhr.open('GET', src, true); 915 916 xhr.onreadystatechange = function () { 917 if (xhr.readyState == 4) { 918 919 if (xhr.status < 400 && xhr.responseText) { 920 code.textContent = xhr.responseText; 921 922 Prism.highlightElement(code); 923 // mark as loaded 924 pre.setAttribute('data-src-loaded', ''); 925 } 926 else if (xhr.status >= 400) { 927 code.textContent = 'â Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; 928 } 929 else { 930 code.textContent = 'â Error: File does not exist or is empty'; 931 } 932 } 933 }; 934 935 xhr.send(null); 936 }); 937 938 if (Prism.plugins.toolbar) { 939 Prism.plugins.toolbar.registerButton('download-file', function (env) { 940 var pre = env.element.parentNode; 941 if (!pre || !/pre/i.test(pre.nodeName) || !pre.hasAttribute('data-src') || !pre.hasAttribute('data-download-link')) { 942 return; 943 } 944 var src = pre.getAttribute('data-src'); 945 var a = document.createElement('a');
946 a.textContent = pre.getAttribute('data-download-link-label') || 'Download'; 947 a.setAttribute('download', ''); 948 a.href = src; 949 return a; 950 }); 951 } 952 953 }; 954 955 document.addEventListener('DOMContentLoaded', function () { 956 // execute inside handler, for dropping Event as argument 957 self.Prism.fileHighlight(); 958 }); 959 960})();
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.