Blame view

bower_components/prism/prism.js 16.7 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  
  /* **********************************************
       Begin prism-core.js
  ********************************************** */
  
  var _self = (typeof window !== 'undefined')
  	? window   // if in browser
  	: (
  		(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
  		? self // if in worker
  		: {}   // if in node js
  	);
  
  /**
   * Prism: Lightweight, robust, elegant syntax highlighting
   * MIT license http://www.opensource.org/licenses/mit-license.php/
   * @author Lea Verou http://lea.verou.me
   */
  
  var Prism = (function(){
  
  // Private helper vars
  var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
  
  var _ = _self.Prism = {
  	util: {
  		encode: function (tokens) {
  			if (tokens instanceof Token) {
  				return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
  			} else if (_.util.type(tokens) === 'Array') {
  				return tokens.map(_.util.encode);
  			} else {
  				return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
  			}
  		},
  
  		type: function (o) {
  			return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
  		},
  
  		// Deep clone a language definition (e.g. to extend it)
  		clone: function (o) {
  			var type = _.util.type(o);
  
  			switch (type) {
  				case 'Object':
  					var clone = {};
  
  					for (var key in o) {
  						if (o.hasOwnProperty(key)) {
  							clone[key] = _.util.clone(o[key]);
  						}
  					}
  
  					return clone;
  
  				case 'Array':
  					// Check for existence for IE8
  					return o.map && o.map(function(v) { return _.util.clone(v); });
  			}
  
  			return o;
  		}
  	},
  
  	languages: {
  		extend: function (id, redef) {
  			var lang = _.util.clone(_.languages[id]);
  
  			for (var key in redef) {
  				lang[key] = redef[key];
  			}
  
  			return lang;
  		},
  
  		/**
  		 * Insert a token before another token in a language literal
  		 * As this needs to recreate the object (we cannot actually insert before keys in object literals),
  		 * we cannot just provide an object, we need anobject and a key.
  		 * @param inside The key (or language id) of the parent
  		 * @param before The key to insert before. If not provided, the function appends instead.
  		 * @param insert Object with the key/value pairs to insert
  		 * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
  		 */
  		insertBefore: function (inside, before, insert, root) {
  			root = root || _.languages;
  			var grammar = root[inside];
  			
  			if (arguments.length == 2) {
  				insert = arguments[1];
  				
  				for (var newToken in insert) {
  					if (insert.hasOwnProperty(newToken)) {
  						grammar[newToken] = insert[newToken];
  					}
  				}
  				
  				return grammar;
  			}
  			
  			var ret = {};
  
  			for (var token in grammar) {
  
  				if (grammar.hasOwnProperty(token)) {
  
  					if (token == before) {
  
  						for (var newToken in insert) {
  
  							if (insert.hasOwnProperty(newToken)) {
  								ret[newToken] = insert[newToken];
  							}
  						}
  					}
  
  					ret[token] = grammar[token];
  				}
  			}
  			
  			// Update references in other language definitions
  			_.languages.DFS(_.languages, function(key, value) {
  				if (value === root[inside] && key != inside) {
  					this[key] = ret;
  				}
  			});
  
  			return root[inside] = ret;
  		},
  
  		// Traverse a language definition with Depth First Search
  		DFS: function(o, callback, type) {
  			for (var i in o) {
  				if (o.hasOwnProperty(i)) {
  					callback.call(o, i, o[i], type || i);
  
  					if (_.util.type(o[i]) === 'Object') {
  						_.languages.DFS(o[i], callback);
  					}
  					else if (_.util.type(o[i]) === 'Array') {
  						_.languages.DFS(o[i], callback, i);
  					}
  				}
  			}
  		}
  	},
eb240478   Luigi Serra   public room cards...
148
149
  	plugins: {},
  	
73bcce88   luigser   COMPONENTS
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
  	highlightAll: function(async, callback) {
  		var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
  
  		for (var i=0, element; element = elements[i++];) {
  			_.highlightElement(element, async === true, callback);
  		}
  	},
  
  	highlightElement: function(element, async, callback) {
  		// Find language
  		var language, grammar, parent = element;
  
  		while (parent && !lang.test(parent.className)) {
  			parent = parent.parentNode;
  		}
  
  		if (parent) {
  			language = (parent.className.match(lang) || [,''])[1];
  			grammar = _.languages[language];
  		}
  
  		// Set language on the element, if not present
  		element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  
  		// Set language on the parent, for styling
  		parent = element.parentNode;
  
  		if (/pre/i.test(parent.nodeName)) {
  			parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  		}
  
73bcce88   luigser   COMPONENTS
181
182
  		var code = element.textContent;
  
73bcce88   luigser   COMPONENTS
183
184
185
186
187
188
189
  		var env = {
  			element: element,
  			language: language,
  			grammar: grammar,
  			code: code
  		};
  
eb240478   Luigi Serra   public room cards...
190
191
192
193
194
  		if (!code || !grammar) {
  			_.hooks.run('complete', env);
  			return;
  		}
  
73bcce88   luigser   COMPONENTS
195
196
197
198
199
200
  		_.hooks.run('before-highlight', env);
  
  		if (async && _self.Worker) {
  			var worker = new Worker(_.filename);
  
  			worker.onmessage = function(evt) {
eb240478   Luigi Serra   public room cards...
201
  				env.highlightedCode = evt.data;
73bcce88   luigser   COMPONENTS
202
203
204
205
206
207
208
  
  				_.hooks.run('before-insert', env);
  
  				env.element.innerHTML = env.highlightedCode;
  
  				callback && callback.call(env.element);
  				_.hooks.run('after-highlight', env);
eb240478   Luigi Serra   public room cards...
209
  				_.hooks.run('complete', env);
73bcce88   luigser   COMPONENTS
210
211
212
213
  			};
  
  			worker.postMessage(JSON.stringify({
  				language: env.language,
eb240478   Luigi Serra   public room cards...
214
215
  				code: env.code,
  				immediateClose: true
73bcce88   luigser   COMPONENTS
216
217
218
219
220
221
222
223
224
225
226
227
  			}));
  		}
  		else {
  			env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
  
  			_.hooks.run('before-insert', env);
  
  			env.element.innerHTML = env.highlightedCode;
  
  			callback && callback.call(element);
  
  			_.hooks.run('after-highlight', env);
eb240478   Luigi Serra   public room cards...
228
  			_.hooks.run('complete', env);
73bcce88   luigser   COMPONENTS
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
  		}
  	},
  
  	highlight: function (text, grammar, language) {
  		var tokens = _.tokenize(text, grammar);
  		return Token.stringify(_.util.encode(tokens), language);
  	},
  
  	tokenize: function(text, grammar, language) {
  		var Token = _.Token;
  
  		var strarr = [text];
  
  		var rest = grammar.rest;
  
  		if (rest) {
  			for (var token in rest) {
  				grammar[token] = rest[token];
  			}
  
  			delete grammar.rest;
  		}
  
  		tokenloop: for (var token in grammar) {
  			if(!grammar.hasOwnProperty(token) || !grammar[token]) {
  				continue;
  			}
  
  			var patterns = grammar[token];
  			patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
  
  			for (var j = 0; j < patterns.length; ++j) {
  				var pattern = patterns[j],
  					inside = pattern.inside,
  					lookbehind = !!pattern.lookbehind,
  					lookbehindLength = 0,
  					alias = pattern.alias;
  
  				pattern = pattern.pattern || pattern;
  
  				for (var i=0; i<strarr.length; i++) { // Don’t cache length as it changes during the loop
  
  					var str = strarr[i];
  
  					if (strarr.length > text.length) {
  						// Something went terribly wrong, ABORT, ABORT!
  						break tokenloop;
  					}
  
  					if (str instanceof Token) {
  						continue;
  					}
  
  					pattern.lastIndex = 0;
  
  					var match = pattern.exec(str);
  
  					if (match) {
  						if(lookbehind) {
  							lookbehindLength = match[1].length;
  						}
  
  						var from = match.index - 1 + lookbehindLength,
  							match = match[0].slice(lookbehindLength),
  							len = match.length,
  							to = from + len,
  							before = str.slice(0, from + 1),
  							after = str.slice(to + 1);
  
  						var args = [i, 1];
  
  						if (before) {
  							args.push(before);
  						}
  
  						var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias);
  
  						args.push(wrapped);
  
  						if (after) {
  							args.push(after);
  						}
  
  						Array.prototype.splice.apply(strarr, args);
  					}
  				}
  			}
  		}
  
  		return strarr;
  	},
  
  	hooks: {
  		all: {},
  
  		add: function (name, callback) {
  			var hooks = _.hooks.all;
  
  			hooks[name] = hooks[name] || [];
  
  			hooks[name].push(callback);
  		},
  
  		run: function (name, env) {
  			var callbacks = _.hooks.all[name];
  
  			if (!callbacks || !callbacks.length) {
  				return;
  			}
  
  			for (var i=0, callback; callback = callbacks[i++];) {
  				callback(env);
  			}
  		}
  	}
  };
  
  var Token = _.Token = function(type, content, alias) {
  	this.type = type;
  	this.content = content;
  	this.alias = alias;
  };
  
  Token.stringify = function(o, language, parent) {
  	if (typeof o == 'string') {
  		return o;
  	}
  
  	if (_.util.type(o) === 'Array') {
  		return o.map(function(element) {
  			return Token.stringify(element, language, o);
  		}).join('');
  	}
  
  	var env = {
  		type: o.type,
  		content: Token.stringify(o.content, language, parent),
  		tag: 'span',
  		classes: ['token', o.type],
  		attributes: {},
  		language: language,
  		parent: parent
  	};
  
  	if (env.type == 'comment') {
  		env.attributes['spellcheck'] = 'true';
  	}
  
  	if (o.alias) {
  		var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
  		Array.prototype.push.apply(env.classes, aliases);
  	}
  
  	_.hooks.run('wrap', env);
  
  	var attributes = '';
  
  	for (var name in env.attributes) {
eb240478   Luigi Serra   public room cards...
387
  		attributes += (attributes ? ' ' : '') + name + '="' + (env.attributes[name] || '') + '"';
73bcce88   luigser   COMPONENTS
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
  	}
  
  	return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
  
  };
  
  if (!_self.document) {
  	if (!_self.addEventListener) {
  		// in Node.js
  		return _self.Prism;
  	}
   	// In worker
  	_self.addEventListener('message', function(evt) {
  		var message = JSON.parse(evt.data),
  		    lang = message.language,
eb240478   Luigi Serra   public room cards...
403
404
  		    code = message.code,
  		    immediateClose = message.immediateClose;
73bcce88   luigser   COMPONENTS
405
  
eb240478   Luigi Serra   public room cards...
406
407
408
409
  		_self.postMessage(_.highlight(code, _.languages[lang], lang));
  		if (immediateClose) {
  			_self.close();
  		}
73bcce88   luigser   COMPONENTS
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
  	}, false);
  
  	return _self.Prism;
  }
  
  // Get current script and highlight
  var script = document.getElementsByTagName('script');
  
  script = script[script.length - 1];
  
  if (script) {
  	_.filename = script.src;
  
  	if (document.addEventListener && !script.hasAttribute('data-manual')) {
  		document.addEventListener('DOMContentLoaded', _.highlightAll);
  	}
  }
  
  return _self.Prism;
  
  })();
  
  if (typeof module !== 'undefined' && module.exports) {
  	module.exports = Prism;
  }
  
eb240478   Luigi Serra   public room cards...
436
437
438
439
440
  // hack for components to work correctly in node.js
  if (typeof global !== 'undefined') {
  	global.Prism = Prism;
  }
  
73bcce88   luigser   COMPONENTS
441
442
443
444
445
446
447
448
449
450
451
  
  /* **********************************************
       Begin prism-markup.js
  ********************************************** */
  
  Prism.languages.markup = {
  	'comment': /<!--[\w\W]*?-->/,
  	'prolog': /<\?[\w\W]+?\?>/,
  	'doctype': /<!DOCTYPE[\w\W]+?>/,
  	'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
  	'tag': {
f748e9cf   Luigi Serra   new controllet an...
452
  		pattern: /<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
73bcce88   luigser   COMPONENTS
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
  		inside: {
  			'tag': {
  				pattern: /^<\/?[^\s>\/]+/i,
  				inside: {
  					'punctuation': /^<\/?/,
  					'namespace': /^[^\s>\/:]+:/
  				}
  			},
  			'attr-value': {
  				pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
  				inside: {
  					'punctuation': /[=>"']/
  				}
  			},
  			'punctuation': /\/?>/,
  			'attr-name': {
  				pattern: /[^\s>\/]+/,
  				inside: {
  					'namespace': /^[^\s>\/:]+:/
  				}
  			}
  
  		}
  	},
  	'entity': /&#?[\da-z]{1,8};/i
  };
  
  // Plugin to make entity title show the real entity, idea by Roman Komarov
  Prism.hooks.add('wrap', function(env) {
  
  	if (env.type === 'entity') {
  		env.attributes['title'] = env.content.replace(/&amp;/, '&');
  	}
  });
  
eb240478   Luigi Serra   public room cards...
488
489
490
491
492
  Prism.languages.xml = Prism.languages.markup;
  Prism.languages.html = Prism.languages.markup;
  Prism.languages.mathml = Prism.languages.markup;
  Prism.languages.svg = Prism.languages.markup;
  
73bcce88   luigser   COMPONENTS
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
  
  /* **********************************************
       Begin prism-css.js
  ********************************************** */
  
  Prism.languages.css = {
  	'comment': /\/\*[\w\W]*?\*\//,
  	'atrule': {
  		pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
  		inside: {
  			'rule': /@[\w-]+/
  			// See rest below
  		}
  	},
  	'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
  	'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
  	'string': /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
  	'property': /(\b|\B)[\w-]+(?=\s*:)/i,
  	'important': /\B!important\b/i,
  	'function': /[-a-z0-9]+(?=\()/i,
  	'punctuation': /[(){};:]/
  };
  
  Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
  
  if (Prism.languages.markup) {
  	Prism.languages.insertBefore('markup', 'tag', {
  		'style': {
eb240478   Luigi Serra   public room cards...
521
522
523
  			pattern: /(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,
  			lookbehind: true,
  			inside: Prism.languages.css,
73bcce88   luigser   COMPONENTS
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
  			alias: 'language-css'
  		}
  	});
  	
  	Prism.languages.insertBefore('inside', 'attr-value', {
  		'style-attr': {
  			pattern: /\s*style=("|').*?\1/i,
  			inside: {
  				'attr-name': {
  					pattern: /^\s*style/i,
  					inside: Prism.languages.markup.tag.inside
  				},
  				'punctuation': /^\s*=\s*['"]|['"]\s*$/,
  				'attr-value': {
  					pattern: /.+/i,
  					inside: Prism.languages.css
  				}
  			},
  			alias: 'language-css'
  		}
  	}, Prism.languages.markup.tag);
  }
  
  /* **********************************************
       Begin prism-clike.js
  ********************************************** */
  
  Prism.languages.clike = {
  	'comment': [
  		{
  			pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
  			lookbehind: true
  		},
  		{
  			pattern: /(^|[^\\:])\/\/.*/,
  			lookbehind: true
  		}
  	],
eb240478   Luigi Serra   public room cards...
562
  	'string': /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
73bcce88   luigser   COMPONENTS
563
  	'class-name': {
eb240478   Luigi Serra   public room cards...
564
  		pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
73bcce88   luigser   COMPONENTS
565
566
567
568
569
570
571
572
  		lookbehind: true,
  		inside: {
  			punctuation: /(\.|\\)/
  		}
  	},
  	'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
  	'boolean': /\b(true|false)\b/,
  	'function': /[a-z0-9_]+(?=\()/i,
eb240478   Luigi Serra   public room cards...
573
574
  	'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
  	'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
73bcce88   luigser   COMPONENTS
575
576
577
578
579
580
581
582
583
  	'punctuation': /[{}[\];(),.:]/
  };
  
  
  /* **********************************************
       Begin prism-javascript.js
  ********************************************** */
  
  Prism.languages.javascript = Prism.languages.extend('clike', {
f748e9cf   Luigi Serra   new controllet an...
584
  	'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/,
73bcce88   luigser   COMPONENTS
585
  	'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
eb240478   Luigi Serra   public room cards...
586
587
  	// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
  	'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i
73bcce88   luigser   COMPONENTS
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
  });
  
  Prism.languages.insertBefore('javascript', 'keyword', {
  	'regex': {
  		pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
  		lookbehind: true
  	}
  });
  
  Prism.languages.insertBefore('javascript', 'class-name', {
  	'template-string': {
  		pattern: /`(?:\\`|\\?[^`])*`/,
  		inside: {
  			'interpolation': {
  				pattern: /\$\{[^}]+\}/,
  				inside: {
  					'interpolation-punctuation': {
  						pattern: /^\$\{|\}$/,
  						alias: 'punctuation'
  					},
  					rest: Prism.languages.javascript
  				}
  			},
  			'string': /[\s\S]+/
  		}
  	}
  });
  
  if (Prism.languages.markup) {
  	Prism.languages.insertBefore('markup', 'tag', {
  		'script': {
eb240478   Luigi Serra   public room cards...
619
620
621
  			pattern: /(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,
  			lookbehind: true,
  			inside: Prism.languages.javascript,
73bcce88   luigser   COMPONENTS
622
623
624
625
626
  			alias: 'language-javascript'
  		}
  	});
  }
  
eb240478   Luigi Serra   public room cards...
627
  Prism.languages.js = Prism.languages.javascript;
73bcce88   luigser   COMPONENTS
628
629
630
631
632
633
  
  /* **********************************************
       Begin prism-file-highlight.js
  ********************************************** */
  
  (function () {
eb240478   Luigi Serra   public room cards...
634
  	if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
73bcce88   luigser   COMPONENTS
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
  		return;
  	}
  
  	self.Prism.fileHighlight = function() {
  
  		var Extensions = {
  			'js': 'javascript',
  			'html': 'markup',
  			'svg': 'markup',
  			'xml': 'markup',
  			'py': 'python',
  			'rb': 'ruby',
  			'ps1': 'powershell',
  			'psm1': 'powershell'
  		};
  
  		if(Array.prototype.forEach) { // Check to prevent error in IE8
  			Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
  				var src = pre.getAttribute('data-src');
  
  				var language, parent = pre;
  				var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
  				while (parent && !lang.test(parent.className)) {
  					parent = parent.parentNode;
  				}
  
  				if (parent) {
  					language = (pre.className.match(lang) || [, ''])[1];
  				}
  
  				if (!language) {
  					var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
  					language = Extensions[extension] || extension;
  				}
  
  				var code = document.createElement('code');
  				code.className = 'language-' + language;
  
  				pre.textContent = '';
  
  				code.textContent = 'Loading…';
  
  				pre.appendChild(code);
  
  				var xhr = new XMLHttpRequest();
  
  				xhr.open('GET', src, true);
  
  				xhr.onreadystatechange = function () {
  					if (xhr.readyState == 4) {
  
  						if (xhr.status < 400 && xhr.responseText) {
  							code.textContent = xhr.responseText;
  
  							Prism.highlightElement(code);
  						}
  						else if (xhr.status >= 400) {
  							code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
  						}
  						else {
  							code.textContent = '✖ Error: File does not exist or is empty';
  						}
  					}
  				};
  
  				xhr.send(null);
  			});
  		}
  
  	};
  
  	self.Prism.fileHighlight();
  
  })();