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