PageSourceSearch

https://liacademy.co.uk/wp-content/plugins/tutor-pro/assets/lib/codesample/prism.min.js?ver=4.0.9

js liacademy.co.uk collected 2026-09-24 21:01:45 UTC 43,267 bytes, 970 lines download raw bytes

1
2
3    jQuery(document).ready(function($){
4        'use strict';
5        var codesample = (function () {
6            'use strict';
7        
8            var Cell = function (initial) {
9              var value = initial;
10              var get = function () {
11                return value;
12              };
13              var set = function (v) {
14                value = v;
15              };
16              var clone = function () {
17                return Cell(get());
18              };
19              return {
20                get: get,
21                set: set,
22                clone: clone
23              };
24            };
25        
26            var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
27        
28            var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
29        
30            var getContentCss = function (editor) {
31              return editor.settings.codesample_content_css;
32            };
33            var getLanguages = function (editor) {
34              return editor.settings.codesample_languages;
35            };
36            var getDialogMinWidth = function (editor) {
37              return Math.min(global$1.DOM.getViewPort().w, editor.getParam('codesample_dialog_width', 800));
38            };
39            var getDialogMinHeight = function (editor) {
40              return Math.min(global$1.DOM.getViewPort().w, editor.getParam('codesample_dialog_height', 650));
41            };
42            var Settings = {
43              getContentCss: getContentCss,
44              getLanguages: getLanguages,
45              getDialogMinWidth: getDialogMinWidth,
46              getDialogMinHeight: getDialogMinHeight
47            };
48        
49            var window$$1 = {};
50            var global$2 = window$$1;
51            var _self = typeof window$$1 !== 'undefined' ? window$$1 : typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : {};
52            var Prism = function () {
53              var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
54              var _ = _self.Prism = {
55                util: {
56                  encode: function (tokens) {
57                    if (tokens instanceof Token) {
58                      return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
59                    } else if (_.util.type(tokens) === 'Array') {
60                      return tokens.map(_.util.encode);
61                    } else {
62                      return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
63                    }
64                  },
65                  type: function (o) {
66                    return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
67                  },
68                  clone: function (o) {
69                    var type = _.util.type(o);
70                    switch (type) {
71                    case 'Object':
72                      var clone = {};
73                      for (var key in o) {
74                        if (o.hasOwnProperty(key)) {
75                          clone[key] = _.util.clone(o[key]);
76                        }
77                      }
78                      return clone;
79                    case 'Array':
80                      return o.map && o.map(function (v) {
81                        return _.util.clone(v);
82                      });
83                    }
84                    return o;
85                  }
86                },
87                languages: {
88                  extend: function (id, redef) {
89                    var lang = _.util.clone(_.languages[id]);
90                    for (var key in redef) {
91                      lang[key] = redef[key];
92                    }
93                    return lang;
94                  },
95                  insertBefore: function (inside, before, insert, root) {
96                    root = root || _.languages;
97                    var grammar = root[inside];
98                    if (arguments.length === 2) {
99                      insert = arguments[1];
100                      for (var newToken in insert) {
101                        if (insert.hasOwnProperty(newToken)) {
102                          grammar[newToken] = insert[newToken];
103                        }
104                      }
105                      return grammar;
106                    }
107                    var ret = {};
108                    for (var token in grammar) {
109                      if (grammar.hasOwnProperty(token)) {
110                        if (token === before) {
111                          for (var newToken in insert) {
112                            if (insert.hasOwnProperty(newToken)) {
113                              ret[newToken] = insert[newToken];
114                            }
115                          }
116                        }
117                        ret[token] = grammar[token];
118                      }
119                    }
120                    _.languages.DFS(_.languages, function (key, value) {
121                      if (value === root[inside] && key !== inside) {
122                        this[key] = ret;
123                      }
124                    });
125                    return root[inside] = ret;
126                  },
127                  DFS: function (o, callback, type) {
128                    for (var i in o) {
129                      if (o.hasOwnProperty(i)) {
130                        callback.call(o, i, o[i], type || i);
131                        if (_.util.type(o[i]) === 'Object') {
132                          _.languages.DFS(o[i], callback);
133                        } else if (_.util.type(o[i]) === 'Array') {
134                          _.languages.DFS(o[i], callback, i);
135                        }
136                      }
137                    }
138                  }
139                },
140                plugins: {},
141                highlightAll: function (async, callback) {
142                  var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
143                  for (var i = 0, element = void 0; element = elements[i++];) {
144                    _.highlightElement(element, async === true, callback);
145                  }
146                },
147                highlightElement: function (element, async, callback) {
148                  var language, grammar, parent$$1 = element;
149                  while (parent$$1 && !lang.test(parent$$1.className)) {
150                    parent$$1 = parent$$1.parentNode;
151                  }
152                  if (parent$$1) {
153                    language = (parent$$1.className.match(lang) || [
154                      ,
155                      ''
156                    ])[1];
157                    grammar = _.languages[language];
158                  }
159                  element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
160                  parent$$1 = element.parentNode;
161                  if (/pre/i.test(parent$$1.nodeName)) {
162                    parent$$1.className = parent$$1.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
163                  }
164                  var code = element.textContent;
165                  var env = {
166                    element: element,
167                    language: language,
168                    grammar: grammar,
169                    code: code
170                  };
171                  if (!code || !grammar) {
172                    _.hooks.run('complete', env);
173                    return;
174                  }
175                  _.hooks.run('before-highlight', env);
176                  if (async && _self.Worker) {
177                    var worker = new Worker(_.filename);
178                    worker.onmessage = function (evt) {
179                      env.highlightedCode = evt.data;
180                      _.hooks.run('before-insert', env);
181                      env.element.innerHTML = env.highlightedCode;
182                      if (callback) {
183                        callback.call(env.element);
184                      }
185                      _.hooks.run('after-highlight', env);
186                      _.hooks.run('complete', env);
187                    };
188                    worker.postMessage(JSON.stringify({
189                      language: env.language,
190                      code: env.code,
191                      immediateClose: true
192                    }));
193                  } else {
194                    env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
195                    _.hooks.run('before-insert', env);
196                    env.element.innerHTML = env.highlightedCode;
197                    if (callback) {
198                      callback.call(element);
199                    }
200                    _.hooks.run('after-highlight', env);
201                    _.hooks.run('complete', env);
202                  }
203                },
204                highlight: function (text, grammar, language) {
205                  var tokens = _.tokenize(text, grammar);
206                  return Token.stringify(_.util.encode(tokens), language);
207                },
208                tokenize: function (text, grammar, language) {
209                  var Token = _.Token;
210                  var strarr = [text];
211                  var rest = grammar.rest;
212                  if (rest) {
213                    for (var token in rest) {
214                      grammar[token] = rest[token];
215                    }
216                    delete grammar.rest;
217                  }
218                  tokenloop:
219                    for (var token in grammar) {
220                      if (!grammar.hasOwnProperty(token) || !grammar[token]) {
221                        continue;
222                      }
223                      var patterns = grammar[token];
224                      patterns = _.util.type(patterns) === 'Array' ? patterns : [patterns];
225                      for (var j = 0; j < patterns.length; ++j) {
226                        var pattern = patterns[j];
227                        var inside = pattern.inside;
228                        var lookbehind = !!pattern.lookbehind;
229                        var lookbehindLength = 0;
230                        var alias = pattern.alias;
231                        pattern = pattern.pattern || pattern;
232                        for (var i = 0; i < strarr.length; i++) {
233                          var str = strarr[i];
234                          if (strarr.length > text.length) {
235                            break tokenloop;
236                          }
237                          if (str instanceof Token) {
238                            continue;
239                          }
240                          pattern.lastIndex = 0;
241                          var match = pattern.exec(str);
242                          if (match) {
243                            if (lookbehind) {
244                              lookbehindLength = match[1].length;
245                            }
246                            var from = match.index - 1 + lookbehindLength;
247                            match = match[0].slice(lookbehindLength);
248                            var len = match.length, to = from + len, before = str.slice(0, from + 1), after = str.slice(to + 1);
249                            var args = [
250                              i,
251                              1
252                            ];
253                            if (before) {
254                              args.push(before);
255                            }
256                            var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias);
257                            args.push(wrapped);
258                            if (after) {
259                              args.push(after);
260                            }
261                            Array.prototype.splice.apply(strarr, args);
262                          }
263                        }
264                      }
265                    }
266                  return strarr;
267                },
268                hooks: {
269                  all: {},
270                  add: function (name$$1, callback) {
271                    var hooks = _.hooks.all;
272                    hooks[name$$1] = hooks[name$$1] || [];
273                    hooks[name$$1].push(callback);
274                  },
275                  run: function (name$$1, env) {
276                    var callbacks = _.hooks.all[name$$1];
277                    if (!callbacks || !callbacks.length) {
278                      return;
279                    }
280                    for (var i = 0, callback = void 0; callback = callbacks[i++];) {
281                      callback(env);
282                    }
283                  }
284                }
285              };
286              var Token = _.Token = function (type, content, alias) {
287                this.type = type;
288                this.content = content;
289                this.alias = alias;
290              };
291              Token.stringify = function (o, language, parent$$1) {
292                if (typeof o === 'string') {
293                  return o;
294                }
295                if (_.util.type(o) === 'Array') {
296                  return o.map(function (element) {
297                    return Token.stringify(element, language, o);
298                  }).join('');
299                }
300                var env = {
301                  type: o.type,
302                  content: Token.stringify(o.content, language, parent$$1),
303                  tag: 'span',
304                  classes: [
305                    'token',
306                    o.type
307                  ],
308                  attributes: {},
309                  language: language,
310                  parent: parent$$1
311                };
312                if (env.type === 'comment') {
313                  env.attributes.spellcheck = 'true';
314                }
315                if (o.alias) {
316                  var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
317                  Array.prototype.push.apply(env.classes, aliases);
318                }
319                _.hooks.run('wrap', env);
320                var attributes = '';
321                for (var name$$1 in env.attributes) {
322                  attributes += (attributes ? ' ' : '') + name$$1 + '="' + (env.attributes[name$$1] || '') + '"';
323                }
324                return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
325              };
326              if (!_self.document) {
327                if (!_self.addEventListener) {
328                  return _self.Prism;
329                }
330                _self.addEventListener('message', function (evt) {
331                  var message = JSON.parse(evt.data), lang = message.language, code = message.code, immediateClose = message.immediateClose;
332                  _self.postMessage(_.highlight(code, _.languages[lang], lang));
333                  if (immediateClose) {
334                    _self.close();
335                  }
336                }, false);
337                return _self.Prism;
338              }
339            }();
340            if (typeof global$2 !== 'undefined') {
341              global$2.Prism = Prism;
342            }
343            Prism.languages.markup = {
344              comment: /<!--[\w\W]*?-->/,
345              prolog: /<\?[\w\W]+?\?>/,
346              doctype: /<!DOCTYPE[\w\W]+?>/,
347              cdata: /<!\[CDATA\[[\w\W]*?]]>/i,
348              tag: {
349                pattern: /<\/?[^\s>\/=.]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
350                inside: {
351                  'tag': {
352                    pattern: /^<\/?[^\s>\/]+/i,
353                    inside: {
354                      punctuation: /^<\/?/,
355                      namespace: /^[^\s>\/:]+:/
356                    }
357                  },
358                  'attr-value': {
359                    pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
360                    inside: { punctuation: /[=>"']/ }
361                  },
362                  'punctuation': /\/?>/,
363                  'attr-name': {
364                    pattern: /[^\s>\/]+/,
365                    inside: { namespace: /^[^\s>\/:]+:/ }
366                  }
367                }
368              },
369              entity: /&#?[\da-z]{1,8};/i
370            };
371            Prism.hooks.add('wrap', function (env) {
372              if (env.type === 'entity') {
373                env.attributes.title = env.content.replace(/&amp;/, '&');
374              }
375            });
376            Prism.languages.xml = Prism.languages.markup;
377            Prism.languages.html = Prism.languages.markup;
378            Prism.languages.mathml = Prism.languages.markup;
379            Prism.languages.svg = Prism.languages.markup;
380            Prism.languages.css = {
381              comment: /\/\*[\w\W]*?\*\//,
382              atrule: {
383                pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
384                inside: { rule: /@[\w-]+/ }
385              },
386              url: /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
387              selector: /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
388              string: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
389              property: /(\b|\B)[\w-]+(?=\s*:)/i,
390              important: /\B!important\b/i,
391              function: /[-a-z0-9]+(?=\()/i,
392              punctuation: /[(){};:]/
393            };
394            Prism.languages.css.atrule.inside.rest = Prism.util.clone(Prism.languages.css);
395            if (Prism.languages.markup) {
396              Prism.languages.insertBefore('markup', 'tag', {
397                style: {
398                  pattern: /<style[\w\W]*?>[\w\W]*?<\/style>/i,
399                  inside: {
400                    tag: {
401                      pattern: /<style[\w\W]*?>|<\/style>/i,
402                      inside: Prism.languages.markup.tag.inside
403                    },
404                    rest: Prism.languages.css
405                  },
406                  alias: 'language-css'
407                }
408              });
409              Prism.languages.insertBefore('inside', 'attr-value', {
410                'style-attr': {
411                  pattern: /\s*style=("|').*?\1/i,
412                  inside: {
413                    'attr-name': {
414                      pattern: /^\s*style/i,
415                      inside: Prism.languages.markup.tag.inside
416                    },
417                    'punctuation': /^\s*=\s*['"]|['"]\s*$/,
418                    'attr-value': {
419                      pattern: /.+/i,
420                      inside: Prism.languages.css
421                    }
422                  },
423                  alias: 'language-css'
424                }
425              }, Prism.languages.markup.tag);
426            }
427            Prism.languages.clike = {
428              'comment': [
429                {
430                  pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
431                  lookbehind: true
432                },
433                {
434                  pattern: /(^|[^\\:])\/\/.*/,
435                  lookbehind: true
436                }
437              ],
438              'string': /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
439              'class-name': {
440                pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
441                lookbehind: true,
442                inside: { punctuation: /(\.|\\)/ }
443              },
444              'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
445              'boolean': /\b(true|false)\b/,
446              'function': /[a-z0-9_]+(?=\()/i,
447              'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
448              'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
449              'punctuation': /[{}[\];(),.:]/
450            };
451            Prism.languages.javascript = Prism.languages.extend('clike', {
452              keyword: /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|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|true|try|typeof|var|void|while|with|yield)\b/,
453              number: /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
454              function: /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i
455            });
456            Prism.languages.insertBefore('javascript', 'keyword', {
457              regex: {
458                pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
459                lookbehind: true
460              }
461            });
462            Prism.languages.insertBefore('javascript', 'class-name', {
463              'template-string': {
464                pattern: /`(?:\\`|\\?[^`])*`/,
465                inside: {
466                  interpolation: {
467                    pattern: /\$\{[^}]+\}/,
468                    inside: {
469                      'interpolation-punctuation': {
470                        pattern: /^\$\{|\}$/,
471                        alias: 'punctuation'
472                      },
473                      'rest': Prism.languages.javascript
474                    }
475                  },
476                  string: /[\s\S]+/
477                }
478              }
479            });
480            if (Prism.languages.markup) {
481              Prism.languages.insertBefore('markup', 'tag', {
482                script: {
483                  pattern: /<script[\w\W]*?>[\w\W]*?<\/script>/i,
484                  inside: {
485                    tag: {
486                      pattern: /<script[\w\W]*?>|<\/script>/i,
487                      inside: Prism.languages.markup.tag.inside
488                    },
489                    rest: Prism.languages.javascript
490                  },
491                  alias: 'language-javascript'
492                }
493              });
494            }
495            Prism.languages.js = Prism.languages.javascript;
496            Prism.languages.c = Prism.languages.extend('clike', {
497              keyword: /\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
498              operator: /\-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*\/]/,
499              number: /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
500            });
501            Prism.languages.insertBefore('c', 'string', {
502              macro: {
503                pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,
504                lookbehind: true,
505                alias: 'property',
506                inside: {
507                  string: {
508                    pattern: /(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,
509                    lookbehind: true
510                  }
511                }
512              }
513            });
514            delete Prism.languages.c['class-name'];
515            delete Prism.languages.c.boolean;
516            Prism.languages.csharp = Prism.languages.extend('clike', {
517              keyword: /\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,
518              string: [
519                /@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
520                /("|')(\\?.)*?\1/
521              ],
522              number: /\b-?(0x[\da-f]+|\d*\.?\d+)\b/i
523            });
524            Prism.languages.insertBefore('csharp', 'keyword', {
525              preprocessor: {
526                pattern: /(^\s*)#.*/m,
527                lookbehind: true
528              }
529            });
530            Prism.languages.cpp = Prism.languages.extend('c', {
531              keyword: /\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
532              boolean: /\b(true|false)\b/,
533              operator: /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/
534            });
535            Prism.languages.insertBefore('cpp', 'keyword', {
536              'class-name': {
537                pattern: /(class\s+)[a-z0-9_]+/i,
538                lookbehind: true
539              }
540            });
541            Prism.languages.java = Prism.languages.extend('clike', {
542              keyword: /\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,
543              number: /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,
544              operator: {
545                pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
546                lookbehind: true
547              }
548            });
549            Prism.languages.php = Prism.languages.extend('clike', {
550              keyword: /\b(and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
551              constant: /\b[A-Z0-9_]{2,}\b/,
552              comment: {
553                pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
554                lookbehind: true
555              }
556            });
557            Prism.languages.insertBefore('php', 'class-name', {
558              'shell-comment': {
559                pattern: /(^|[^\\])#.*/,
560                lookbehind: true,
561                alias: 'comment'
562              }
563            });
564            Prism.languages.insertBefore('php', 'keyword', {
565              delimiter: /\?>|<\?(?:php)?/i,
566              variable: /\$\w+\b/i,
567              package: {
568                pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
569                lookbehind: true,
570                inside: { punctuation: /\\/ }
571              }
572            });
573            Prism.languages.insertBefore('php', 'operator', {
574              property: {
575                pattern: /(->)[\w]+/,
576                lookbehind: true
577              }
578            });
579            if (Prism.languages.markup) {
580              Prism.hooks.add('before-highlight', function (env) {
581                if (env.language !== 'php') {
582                  return;
583                }
584                env.tokenStack = [];
585                env.backupCode = env.code;
586                env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/ig, function (match) {
587                  env.tokenStack.push(match);
588                  return '{{{PHP' + env.tokenStack.length + '}}}';
589                });
590              });
591              Prism.hooks.add('before-insert', function (env) {
592                if (env.language === 'php') {
593                  env.code = env.backupCode;
594                  delete env.backupCode;
595                }
596              });
597              Prism.hooks.add('after-highlight', function (env) {
598                if (env.language !== 'php') {
599                  return;
600                }
601                for (var i = 0, t = void 0; t = env.tokenStack[i]; i++) {
602                  env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$'));
603                }
604                env.element.innerHTML = env.highlightedCode;
605              });
606              Prism.hooks.add('wrap', function (env) {
607                if (env.language === 'php' && env.type === 'markup') {
608                  env.content = env.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g, '<span class="token php">$1</span>');
609                }
610              });
611              Prism.languages.insertBefore('php', 'comment', {
612                markup: {
613                  pattern: /<[^?]\/?(.*?)>/,
614                  inside: Prism.languages.markup
615                },
616                php: /\{\{\{PHP[0-9]+\}\}\}/
617              });
618            }
619            Prism.languages.python = {
620              'comment': {
621                pattern: /(^|[^\\])#.*/,
622                lookbehind: true
623              },
624              'string': /"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(?:\\?.)*?\1/,
625              'function': {
626                pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\(
626)/g,
627                lookbehind: true
628              },
629              'class-name': {
630                pattern: /(\bclass\s+)[a-z0-9_]+/i,
631                lookbehind: true
632              },
633              'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
634              'boolean': /\b(?:True|False)\b/,
635              'number': /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
636              'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
637              'punctuation': /[{}[\];(),.:]/
638            };
639            (function (Prism) {
640              Prism.languages.ruby = Prism.languages.extend('clike', {
641                comment: /#(?!\{[^\r\n]*?\}).*/,
642                keyword: /\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
643              });
644              var interpolation = {
645                pattern: /#\{[^}]+\}/,
646                inside: {
647                  delimiter: {
648                    pattern: /^#\{|\}$/,
649                    alias: 'tag'
650                  },
651                  rest: Prism.util.clone(Prism.languages.ruby)
652                }
653              };
654              Prism.languages.insertBefore('ruby', 'keyword', {
655                regex: [
656                  {
657                    pattern: /%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,
658                    inside: { interpolation: interpolation }
659                  },
660                  {
661                    pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
662                    inside: { interpolation: interpolation }
663                  },
664                  {
665                    pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
666                    inside: { interpolation: interpolation }
667                  },
668                  {
669                    pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
670                    inside: { interpolation: interpolation }
671                  },
672                  {
673                    pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
674                    inside: { interpolation: interpolation }
675                  },
676                  {
677                    pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
678                    lookbehind: true
679                  }
680                ],
681                variable: /[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,
682                symbol: /:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/
683              });
684              Prism.languages.insertBefore('ruby', 'number', {
685                builtin: /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
686                constant: /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/
687              });
688              Prism.languages.ruby.string = [
689                {
690                  pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
691                  inside: { interpolation: interpolation }
692                },
693                {
694                  pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
695                  inside: { interpolation: interpolation }
696                },
697                {
698                  pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
699                  inside: { interpolation: interpolation }
700                },
701                {
702                  pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
703                  inside: { interpolation: interpolation }
704                },
705                {
706                  pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
707                  inside: { interpolation: interpolation }
708                },
709                {
710                  pattern: /("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,
711                  inside: { interpolation: interpolation }
712                }
713              ];
714            }(Prism));
715        
716            function isCodeSample(elm) {
717              return elm && elm.nodeName === 'PRE' && elm.className.indexOf('language-') !== -1;
718            }
719            function trimArg(predicateFn) {
720              return function (arg1, arg2) {
721                return predicateFn(arg2);
722              };
723            }
724            var Utils = {
725              isCodeSample: isCodeSample,
726              trimArg: trimArg
727            };
728        
729            var getSelectedCodeSample = function (editor) {
730              var node = editor.selection.getNode();
731              if (Utils.isCodeSample(node)) {
732                return node;
733              }
734              return null;
735            };
736            var insertCodeSample = function (editor, language, code) {
737              editor.undoManager.transact(function () {
738                var node = getSelectedCodeSample(editor);
739                code = global$1.DOM.encode(code);
740                if (node) {
741                  editor.dom.setAttrib(node, 'class', 'language-' + language);
742                  node.innerHTML = code;
743                  Prism.highlightElement(node);
744                  editor.selection.select(node);
745                } else {
746                  editor.insertContent('<pre id="__new" class="language-' + language + '">' + code + '</pre>');
747                  editor.selection.select(editor.$('#__new').removeAttr('id')[0]);
748                }
749              });
750            };
751            var getCurrentCode = function (editor) {
752              var node = getSelectedCodeSample(editor);
753              if (node) {
754                return node.textContent;
755              }
756              return '';
757            };
758            var CodeSample = {
759              getSelectedCodeSample: getSelectedCodeSample,
760              insertCodeSample: insertCodeSample,
761              getCurrentCode: getCurrentCode
762            };
763        
764            var getLanguages$1 = function (editor) {
765              var defaultLanguages = [
766                {
767                  text: 'HTML/XML',
768                  value: 'markup'
769                },
770                {
771                  text: 'JavaScript',
772                  value: 'javascript'
773                },
774                {
775                  text: 'CSS',
776                  value: 'css'
777                },
778                {
779                  text: 'PHP',
780                  value: 'php'
781                },
782                {
783                  text: 'Ruby',
784                  value: 'ruby'
785                },
786                {
787                  text: 'Python',
788                  value: 'python'
789                },
790                {
791                  text: 'Java',
792                  value: 'java'
793                },
794                {
795                  text: 'C',
796                  value: 'c'
797                },
798                {
799                  text: 'C#',
800                  value: 'csharp'
801                },
802                {
803                  text: 'C++',
804                  value: 'cpp'
805                }
806              ];
807              var customLanguages = Settings.getLanguages(editor);
808              return customLanguages ? customLanguages : defaultLanguages;
809            };
810            var getCurrentLanguage = function (editor) {
811              var matches;
812              var node = CodeSample.getSelectedCodeSample(editor);
813              if (node) {
814                matches = node.className.match(/language-(\w+)/);
815                return matches ? matches[1] : '';
816              }
817              return '';
818            };
819            var Languages = {
820              getLanguages: getLanguages$1,
821              getCurrentLanguage: getCurrentLanguage
822            };
823        
824            var Dialog = {
825              open: function (editor) {
826                var minWidth = Settings.getDialogMinWidth(editor);
827                var minHeight = Settings.getDialogMinHeight(editor);
828                var currentLanguage = Languages.getCurrentLanguage(editor);
829                var currentLanguages = Languages.getLanguages(editor);
830                var currentCode = CodeSample.getCurrentCode(editor);
831                editor.windowManager.open({
832                  title: 'Insert/Edit code sample',
833                  minWidth: minWidth,
834                  minHeight: minHeight,
835                  layout: 'flex',
836                  direction: 'column',
837                  align: 'stretch',
838                  body: [
839                    {
840                      type: 'listbox',
841                      name: 'language',
842                      label: 'Language',
843                      maxWidth: 200,
844                      value: currentLanguage,
845                      values: currentLanguages
846                    },
847                    {
848                      type: 'textbox',
849                      name: 'code',
850                      multiline: true,
851                      spellcheck: false,
852                      ariaLabel: 'Code view',
853                      flex: 1,
854                      style: 'direction: ltr; text-align: left',
855                      classes: 'monospace',
856                      value: currentCode,
857                      autofocus: true
858                    }
859                  ],
860                  onSubmit: function (e) {
861                    CodeSample.insertCodeSample(editor, e.data.language, e.data.code);
862                  }
863                });
864              }
865            };
866        
867            var register = function (editor) {
868              editor.addCommand('codesample', function () {
869                var node = editor.selection.getNode();
870                if (editor.selection.isCollapsed() || Utils.isCodeSample(node)) {
871                  Dialog.open(editor);
872                } else {
873                  editor.formatter.toggle('code');
874                }
875              });
876            };
877            var Commands = { register: register };
878        
879            var setup = function (editor) {
880              var $ = editor.$;
881              editor.on('PreProcess', function (e) {
882                $('pre[contenteditable=false]', e.node).filter(Utils.trimArg(Utils.isCodeSample)).each(function (idx, elm) {
883                  var $elm = $(elm), code = elm.textContent;
884                  $elm.attr('class', $.trim($elm.attr('class')));
885                  $elm.removeAttr('contentEditable');
886                  $elm.empty().append($('<code></code>').each(function () {
887                    this.textContent = code;
888                  }));
889                });
890              });
891              editor.on('SetContent', function () {
892                var unprocessedCodeSamples = $('pre').filter(Utils.trimArg(Utils.isCodeSample)).filter(function (idx, elm) {
893                  return elm.contentEditable !== 'false';
894                });
895                if (unprocessedCodeSamples.length) {
896                  editor.undoManager.transact(function () {
897                    unprocessedCodeSamples.each(function (idx, elm) {
898                      $(elm).find('br').each(function (idx, elm) {
899                        elm.parentNode.replaceChild(editor.getDoc().createTextNode('\n'), elm);
900                      });
901                      elm.contentEditable = false;
902                      elm.innerHTML = editor.dom.encode(elm.textContent);
903                      Prism.highlightElement(elm);
904                      elm.className = $.trim(elm.className);
905                    });
906                  });
907                }
908              });
909            };
910            var FilterContent = { setup: setup };
911        
912            var loadCss = function (editor, pluginUrl, addedInlineCss, addedCss) {
913              var linkElm;
914              var contentCss = Settings.getContentCss(editor);
915              if (editor.inline && addedInlineCss.get()) {
916                return;
917              }
918              if (!editor.inline && addedCss.get()) {
919                return;
920              }
921              if (editor.inline) {
922                addedInlineCss.set(true);
923              } else {
924                addedCss.set(true);
925              }
926              if (contentCss !== false) {
927                linkElm = editor.dom.create('link', {
928                  rel: 'stylesheet',
929                  href: contentCss ? contentCss : _tutorobject.tutor_pro_url + 'assets/lib/codesample/prism.css'
930                });
931                editor.getDoc().getElementsByTagName('head')[0].appendChild(linkElm);
932              }
933            };
934            var LoadCss = { loadCss: loadCss };
935        
936            var register$1 = function (editor) {
937              editor.addButton('codesample', {
938                cmd: 'codesample',
939                title: 'Insert/Edit code sample'
940              });
941              editor.addMenuItem('codesample', {
942                cmd: 'codesample',
943                text: 'Code sample',
944                icon: 'codesample'
945              });
946            };
947            var Buttons = { register: register$1 };
948        
949            var addedInlineCss = Cell(false);
950            global.add('codesample', function (editor, pluginUrl) {
951              var addedCss = Cell(false);
952              FilterContent.setup(editor);
953              Buttons.register(editor);
954              Commands.register(editor);
955              editor.on('init', function () {
956                LoadCss.loadCss(editor, pluginUrl, addedInlineCss, addedCss);
957              });
958              editor.on('dblclick', function (ev) {
959                if (Utils.isCodeSample(ev.target)) {
960                  Dialog.open(editor);
961                }
962              });
963            });
964            function Plugin () {
965            }
966        
967            return Plugin;
968        
969        }());
970    })

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.