History

Merge pull request #2535 from NasaGeek/tcllib

Add tcllib scraper

Simon Legner committed 1 year ago

Commit 59e990a2 parents 52b026e c1495239 files · +5486 −5777Browse files

Unified · Split

9 files
  1. assets/javascripts/news.json +4 −0
  2. assets/javascripts/vendor/prism.js +5373 −5779
  3. lib/docs/filters/tcllib/clean_html.rb +40 −0
  4. lib/docs/filters/tcllib/entries.rb +22 −0
  5. lib/docs/filters/tcllib/nop.rb +9 −0
  6. lib/docs/scrapers/tcllib.rb +39 −0
  7. public/icons/docs/tcllib/16.png +0 −0
  8. public/icons/docs/tcllib/16@2x.png +0 −0
  9. public/icons/docs/tcllib/SOURCE +1 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
11 [
2+ [
3+ "2025-07-14",
4+ "New documentation: <a href=\"/tcllib/\">Tcllib</a>"
5+ ],
26 [
37 "2025-06-27",
48 "New documentation: <a href=\"/zsh/\">Zsh</a>"
assets/javascripts/vendor/prism.js+5373−5779
@@ -1,14 +1,14 @@
1−/* PrismJS 1.29.0
2−https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+c+cpp+cmake+coffeescript+crystal+d+dart+diff+django+elixir+erlang+go+groovy+java+json+julia+kotlin+latex+lua+markdown+markup-templating+matlab+nginx+nim+nix+ocaml+perl+php+python+qml+r+jsx+ruby+rust+scss+scala+shell-session+sql+typescript+yaml+zig */
1+/* PrismJS 1.30.0
2+https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+c+cpp+cmake+coffeescript+crystal+d+dart+diff+django+elixir+erlang+go+groovy+java+json+julia+kotlin+latex+lua+markdown+markup-templating+matlab+nginx+nim+nix+ocaml+perl+php+python+qml+r+jsx+ruby+rust+scss+scala+shell-session+sql+tcl+typescript+yaml+zig */
33 /// <reference lib="WebWorker"/>
44
5−var _self =
6− typeof window !== "undefined"
7− ? window // if in browser
8− : typeof WorkerGlobalScope !== "undefined" &&
9− self instanceof WorkerGlobalScope
10− ? self // if in worker
11− : {}; // if in node js
5+var _self = (typeof window !== 'undefined')
6+ ? window // if in browser
7+ : (
8+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
9+ ? self // if in worker
10+ : {} // if in node js
11+ );
1212
1313 /**
1414 * Prism: Lightweight, robust, elegant syntax highlighting
@@ -19,1260 +19,1200 @@ var _self = · 4 unmodified lines
1919 * @public
2020 */
2121 var Prism = (function (_self) {
22− // Private helper vars
23− var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
24− var uniqueId = 0;
25−
26− // The grammar object for plaintext
27− var plainTextGrammar = {};
28−
29− var _ = {
30− /**
31− * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
32− * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
33− * additional languages or plugins yourself.
34− *
35− * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
36− *
37− * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
38− * empty Prism object into the global scope before loading the Prism script like this:
39− *
40− * ```js
41− * window.Prism = window.Prism || {};
42− * Prism.manual = true;
43− * // add a new <script> to load Prism's script
44− * ```
45− *
46− * @default false
47− * @type {boolean}
48− * @memberof Prism
49− * @public
50− */
51− manual: _self.Prism && _self.Prism.manual,
52− /**
53− * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
54− * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
55− * own worker, you don't want it to do this.
56− *
57− * By setting this value to `true`, Prism will not add its own listeners to the worker.
58− *
59− * You obviously have to change this value before Prism executes. To do this, you can add an
60− * empty Prism object into the global scope before loading the Prism script like this:
61− *
62− * ```js
63− * window.Prism = window.Prism || {};
64− * Prism.disableWorkerMessageHandler = true;
65− * // Load Prism's script
66− * ```
67− *
68− * @default false
69− * @type {boolean}
70− * @memberof Prism
71− * @public
72− */
73− disableWorkerMessageHandler:
74− _self.Prism && _self.Prism.disableWorkerMessageHandler,
75−
76− /**
77− * A namespace for utility methods.
78− *
79− * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
80− * change or disappear at any time.
81− *
82− * @namespace
83− * @memberof Prism
84− */
85− util: {
86− encode: function encode(tokens) {
87− if (tokens instanceof Token) {
88− return new Token(tokens.type, encode(tokens.content), tokens.alias);
89− } else if (Array.isArray(tokens)) {
90− return tokens.map(encode);
91− } else {
92− return tokens
93− .replace(/&/g, "&amp;")
94− .replace(/</g, "&lt;")
95− .replace(/\u00a0/g, " ");
96− }
97− },
98−
99− /**
100− * Returns the name of the type of the given value.
101− *
102− * @param {any} o
103− * @returns {string}
104− * @example
105− * type(null) === 'Null'
106− * type(undefined) === 'Undefined'
107− * type(123) === 'Number'
108− * type('foo') === 'String'
109− * type(true) === 'Boolean'
110− * type([1, 2]) === 'Array'
111− * type({}) === 'Object'
112− * type(String) === 'Function'
113− * type(/abc+/) === 'RegExp'
114− */
115− type: function (o) {
116− return Object.prototype.toString.call(o).slice(8, -1);
117− },
118−
119− /**
120− * Returns a unique number for the given object. Later calls will still return the same number.
121− *
122− * @param {Object} obj
123− * @returns {number}
124− */
125− objId: function (obj) {
126− if (!obj["__id"]) {
127− Object.defineProperty(obj, "__id", { value: ++uniqueId });
128− }
129− return obj["__id"];
130− },
131−
132− /**
133− * Creates a deep clone of the given object.
134− *
135− * The main intended use of this function is to clone language definitions.
136− *
137− * @param {T} o
138− * @param {Record<number, any>} [visited]
139− * @returns {T}
140− * @template T
141− */
142− clone: function deepClone(o, visited) {
143− visited = visited || {};
144−
145− var clone;
146− var id;
147− switch (_.util.type(o)) {
148− case "Object":
149− id = _.util.objId(o);
150− if (visited[id]) {
151− return visited[id];
152− }
153− clone = /** @type {Record<string, any>} */ ({});
154− visited[id] = clone;
155−
156− for (var key in o) {
157− if (o.hasOwnProperty(key)) {
158− clone[key] = deepClone(o[key], visited);
159− }
160− }
161−
162− return /** @type {any} */ (clone);
163−
164− case "Array":
165− id = _.util.objId(o);
166− if (visited[id]) {
167− return visited[id];
168− }
169− clone = [];
170− visited[id] = clone;
171−
172− /** @type {Array} */ (/** @type {any} */ (o)).forEach(
173− function (v, i) {
174− clone[i] = deepClone(v, visited);
175− },
176− );
177−
178− return /** @type {any} */ (clone);
179−
180− default:
181− return o;
182− }
183− },
184−
185− /**
186− * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
187− *
188− * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
189− *
190− * @param {Element} element
191− * @returns {string}
192− */
193− getLanguage: function (element) {
194− while (element) {
195− var m = lang.exec(element.className);
196− if (m) {
197− return m[1].toLowerCase();
198− }
199− element = element.parentElement;
200− }
201− return "none";
202− },
203−
204− /**
205− * Sets the Prism `language-xxxx` class of the given element.
206− *
207− * @param {Element} element
208− * @param {string} language
209− * @returns {void}
210− */
211− setLanguage: function (element, language) {
212− // remove all `language-xxxx` classes
213− // (this might leave behind a leading space)
214− element.className = element.className.replace(RegExp(lang, "gi"), "");
215−
216− // add the new `language-xxxx` class
217− // (using `classList` will automatically clean up spaces for us)
218− element.classList.add("language-" + language);
219− },
220−
221− /**
222− * Returns the script element that is currently executing.
223− *
224− * This does __not__ work for line script element.
225− *
226− * @returns {HTMLScriptElement | null}
227− */
228− currentScript: function () {
229− if (typeof document === "undefined") {
230− return null;
231− }
232− if (
233− "currentScript" in document &&
234− 1 < 2 /* hack to trip TS' flow analysis */
235− ) {
236− return /** @type {any} */ (document.currentScript);
237− }
238−
239− // IE11 workaround
240− // we'll get the src of the current script by parsing IE11's error stack trace
241− // this will not work for inline scripts
242−
243− try {
244− throw new Error();
245− } catch (err) {
246− // Get file src url from stack. Specifically works with the format of stack traces in IE.
247− // A stack will look like this:
248− //
249− // Error
250− // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
251− // at Global code (http://localhost/components/prism-core.js:606:1)
252−
253− var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) ||
254− [])[1];
255− if (src) {
256− var scripts = document.getElementsByTagName("script");
257− for (var i in scripts) {
258− if (scripts[i].src == src) {
259− return scripts[i];
260− }
261− }
262− }
263− return null;
264− }
265− },
266−
267− /**
268− * Returns whether a given class is active for `element`.
269− *
270− * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
271− * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
272− * given class is just the given class with a `no-` prefix.
273− *
274− * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
275− * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
276− * ancestors have the given class or the negated version of it, then the default activation will be returned.
277− *
278− * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
279− * version of it, the class is considered active.
280− *
281− * @param {Element} element
282− * @param {string} className
283− * @param {boolean} [defaultActivation=false]
284− * @returns {boolean}
285− */
286− isActive: function (element, className, defaultActivation) {
287− var no = "no-" + className;
288−
289− while (element) {
290− var classList = element.classList;
291− if (classList.contains(className)) {
292− return true;
293− }
294− if (classList.contains(no)) {
295− return false;
296− }
297− element = element.parentElement;
298− }
299− return !!defaultActivation;
300− },
301− },
302−
303− /**
304− * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
305− *
306− * @namespace
307− * @memberof Prism
308− * @public
309− */
310− languages: {
311− /**
312− * The grammar for plain, unformatted text.
313− */
314− plain: plainTextGrammar,
315− plaintext: plainTextGrammar,
316− text: plainTextGrammar,
317− txt: plainTextGrammar,
318−
319− /**
320− * Creates a deep copy of the language with the given id and appends the given tokens.
321− *
322− * If a token in `redef` also appears in the copied language, then the existing token in the copied language
323− * will be overwritten at its original position.
324− *
325− * ## Best practices
326− *
327− * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
328− * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
329− * understand the language definition because, normally, the order of tokens matters in Prism grammars.
330− *
331− * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
332− * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
333− *
334− * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
335− * @param {Grammar} redef The new tokens to append.
336− * @returns {Grammar} The new language created.
337− * @public
338− * @example
339− * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
340− * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
341− * // at its original position
342− * 'comment': { ... },
343− * // CSS doesn't have a 'color' token, so this token will be appended
344− * 'color': /\b(?:red|green|blue)\b/
345− * });
346− */
347− extend: function (id, redef) {
348− var lang = _.util.clone(_.languages[id]);
349−
350− for (var key in redef) {
351− lang[key] = redef[key];
352− }
353−
354− return lang;
355− },
356−
357− /**
358− * Inserts tokens _before_ another token in a language definition or any other grammar.
359− *
360− * ## Usage
361− *
362− * This helper method makes it easy to modify existing languages. For example, the CSS language definition
363− * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
364− * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
365− * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
366− * this:
367− *
368− * ```js
369− * Prism.languages.markup.style = {
370− * // token
371− * };
372− * ```
373− *
374− * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
375− * before existing tokens. For the CSS example above, you would use it like this:
376− *
377− * ```js
378− * Prism.languages.insertBefore('markup', 'cdata', {
379− * 'style': {
380− * // token
381− * }
382− * });
383− * ```
384− *
385− * ## Special cases
386− *
387− * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
388− * will be ignored.
389− *
390− * This behavior can be used to insert tokens after `before`:
391− *
392− * ```js
393− * Prism.languages.insertBefore('markup', 'comment', {
394− * 'comment': Prism.languages.markup.comment,
395− * // tokens after 'comment'
396− * });
397− * ```
398− *
399− * ## Limitations
400− *
401− * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
402− * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
403− * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
404− * deleting properties which is necessary to insert at arbitrary positions.
405− *
406− * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
407− * Instead, it will create a new object and replace all references to the target object with the new one. This
408− * can be done without temporarily deleting properties, so the iteration order is well-defined.
409− *
410− * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
411− * you hold the target object in a variable, then the value of the variable will not change.
412− *
413− * ```js
414− * var oldMarkup = Prism.languages.markup;
415− * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
416− *
417− * assert(oldMarkup !== Prism.languages.markup);
418− * assert(newMarkup === Prism.languages.markup);
419− * ```
420− *
421− * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
422− * object to be modified.
423− * @param {string} before The key to insert before.
424− * @param {Grammar} insert An object containing the key-value pairs to be inserted.
425− * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
426− * object to be modified.
427− *
428− * Defaults to `Prism.languages`.
429− * @returns {Grammar} The new grammar object.
430− * @public
431− */
432− insertBefore: function (inside, before, insert, root) {
433− root = root || /** @type {any} */ (_.languages);
434− var grammar = root[inside];
435− /** @type {Grammar} */
436− var ret = {};
437−
438− for (var token in grammar) {
439− if (grammar.hasOwnProperty(token)) {
440− if (token == before) {
441− for (var newToken in insert) {
442− if (insert.hasOwnProperty(newToken)) {
443− ret[newToken] = insert[newToken];
444− }
445− }
446− }
447−
448− // Do not insert token which also occur in insert. See #1525
449− if (!insert.hasOwnProperty(token)) {
450− ret[token] = grammar[token];
451− }
452− }
453− }
454−
455− var old = root[inside];
456− root[inside] = ret;
457−
458− // Update references in other language definitions
459− _.languages.DFS(_.languages, function (key, value) {
460− if (value === old && key != inside) {
461− this[key] = ret;
462− }
463− });
464−
465− return ret;
466− },
467−
468− // Traverse a language definition with Depth First Search
469− DFS: function DFS(o, callback, type, visited) {
470− visited = visited || {};
471−
472− var objId = _.util.objId;
473−
474− for (var i in o) {
475− if (o.hasOwnProperty(i)) {
476− callback.call(o, i, o[i], type || i);
477−
478− var property = o[i];
479− var propertyType = _.util.type(property);
480−
481− if (propertyType === "Object" && !visited[objId(property)]) {
482− visited[objId(property)] = true;
483− DFS(property, callback, null, visited);
484− } else if (propertyType === "Array" && !visited[objId(property)]) {
485− visited[objId(property)] = true;
486− DFS(property, callback, i, visited);
487− }
488− }
489− }
490− },
491− },
492−
493− plugins: {},
494−
495− /**
496− * This is the most high-level function in Prism’s API.
497− * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
498− * each one of them.
499− *
500− * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
501− *
502− * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
503− * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
504− * @memberof Prism
505− * @public
506− */
507− highlightAll: function (async, callback) {
508− _.highlightAllUnder(document, async, callback);
509− },
510−
511− /**
512− * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
513− * {@link Prism.highlightElement} on each one of them.
514− *
515− * The following hooks will be run:
516− * 1. `before-highlightall`
517− * 2. `before-all-elements-highlight`
518− * 3. All hooks of {@link Prism.highlightElement} for each element.
519− *
520− * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
521− * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
522− * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
523− * @memberof Prism
524− * @public
525− */
526− highlightAllUnder: function (container, async, callback) {
527− var env = {
528− callback: callback,
529− container: container,
530− selector:
531− 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code',
532− };
533−
534− _.hooks.run("before-highlightall", env);
535−
536− env.elements = Array.prototype.slice.apply(
537− env.container.querySelectorAll(env.selector),
538− );
539−
540− _.hooks.run("before-all-elements-highlight", env);
541−
542− for (var i = 0, element; (element = env.elements[i++]); ) {
543− _.highlightElement(element, async === true, env.callback);
544− }
545− },
546−
547− /**
548− * Highlights the code inside a single element.
549− *
550− * The following hooks will be run:
551− * 1. `before-sanity-check`
552− * 2. `before-highlight`
553− * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
554− * 4. `before-insert`
555− * 5. `after-highlight`
556− * 6. `complete`
557− *
558− * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
559− * the element's language.
560− *
561− * @param {Element} element The element containing the code.
562− * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
563− * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
564− * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
565− * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
566− *
567− * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
568− * asynchronous highlighting to work. You can build your own bundle on the
569− * [Download page](https://prismjs.com/download.html).
570− * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
571− * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
572− * @memberof Prism
573− * @public
574− */
575− highlightElement: function (element, async, callback) {
576− // Find language
577− var language = _.util.getLanguage(element);
578− var grammar = _.languages[language];
579−
580− // Set language on the element, if not present
581− _.util.setLanguage(element, language);
582−
583− // Set language on the parent, for styling
584− var parent = element.parentElement;
585− if (parent && parent.nodeName.toLowerCase() === "pre") {
586− _.util.setLanguage(parent, language);
587− }
588−
589− var code = element.textContent;
590−
591− var env = {
592− element: element,
593− language: language,
594− grammar: grammar,
595− code: code,
596− };
597−
598− function insertHighlightedCode(highlightedCode) {
599− env.highlightedCode = highlightedCode;
600−
601− _.hooks.run("before-insert", env);
602−
603− env.element.innerHTML = env.highlightedCode;
604−
605− _.hooks.run("after-highlight", env);
606− _.hooks.run("complete", env);
607− callback && callback.call(env.element);
608− }
609−
610− _.hooks.run("before-sanity-check", env);
611−
612− // plugins may change/add the parent/element
613− parent = env.element.parentElement;
614− if (
615− parent &&
616− parent.nodeName.toLowerCase() === "pre" &&
617− !parent.hasAttribute("tabindex")
618− ) {
619− parent.setAttribute("tabindex", "0");
620− }
621−
622− if (!env.code) {
623− _.hooks.run("complete", env);
624− callback && callback.call(env.element);
625− return;
626− }
627−
628− _.hooks.run("before-highlight", env);
629−
630− if (!env.grammar) {
631− insertHighlightedCode(_.util.encode(env.code));
632− return;
633− }
634−
635− if (async && _self.Worker) {
636− var worker = new Worker(_.filename);
637−
638− worker.onmessage = function (evt) {
639− insertHighlightedCode(evt.data);
640− };
641−
642− worker.postMessage(
643− JSON.stringify({
644− language: env.language,
645− code: env.code,
646− immediateClose: true,
647− }),
648− );
649− } else {
650− insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
651− }
652− },
653−
654− /**
655− * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
656− * and the language definitions to use, and returns a string with the HTML produced.
657− *
658− * The following hooks will be run:
659− * 1. `before-tokenize`
660− * 2. `after-tokenize`
661− * 3. `wrap`: On each {@link Token}.
662− *
663− * @param {string} text A string with the code to be highlighted.
664− * @param {Grammar} grammar An object containing the tokens to use.
665− *
666− * Usually a language definition like `Prism.languages.markup`.
667− * @param {string} language The name of the language definition passed to `grammar`.
668− * @returns {string} The highlighted HTML.
669− * @memberof Prism
670− * @public
671− * @example
672− * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
673− */
674− highlight: function (text, grammar, language) {
675− var env = {
676− code: text,
677− grammar: grammar,
678− language: language,
679− };
680− _.hooks.run("before-tokenize", env);
681− if (!env.grammar) {
682− throw new Error('The language "' + env.language + '" has no grammar.');
683− }
684− env.tokens = _.tokenize(env.code, env.grammar);
685− _.hooks.run("after-tokenize", env);
686− return Token.stringify(_.util.encode(env.tokens), env.language);
687− },
688−
689− /**
690− * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
691− * and the language definitions to use, and returns an array with the tokenized code.
692− *
693− * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
694− *
695− * This method could be useful in other contexts as well, as a very crude parser.
696− *
697− * @param {string} text A string with the code to be highlighted.
698− * @param {Grammar} grammar An object containing the tokens to use.
699− *
700− * Usually a language definition like `Prism.languages.markup`.
701− * @returns {TokenStream} An array of strings and tokens, a token stream.
702− * @memberof Prism
703− * @public
704− * @example
705− * let code = `var foo = 0;`;
706− * let tokens = Prism.tokenize(code, Prism.languages.javascript);
707− * tokens.forEach(token => {
708− * if (token instanceof Prism.Token && token.type === 'number') {
709− * console.log(`Found numeric literal: ${token.content}`);
710− * }
711− * });
712− */
713− tokenize: function (text, grammar) {
714− var rest = grammar.rest;
715− if (rest) {
716− for (var token in rest) {
717− grammar[token] = rest[token];
718− }
719−
720− delete grammar.rest;
721− }
722−
723− var tokenList = new LinkedList();
724− addAfter(tokenList, tokenList.head, text);
725−
726− matchGrammar(text, tokenList, grammar, tokenList.head, 0);
727−
728− return toArray(tokenList);
729− },
730−
731− /**
732− * @namespace
733− * @memberof Prism
734− * @public
735− */
736− hooks: {
737− all: {},
738−
739− /**
740− * Adds the given callback to the list of callbacks for the given hook.
741− *
742− * The callback will be invoked when the hook it is registered for is run.
743− * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
744− *
745− * One callback function can be registered to multiple hooks and the same hook multiple times.
746− *
747− * @param {string} name The name of the hook.
748− * @param {HookCallback} callback The callback function which is given environment variables.
749− * @public
750− */
751− add: function (name, callback) {
752− var hooks = _.hooks.all;
753−
754− hooks[name] = hooks[name] || [];
755−
756− hooks[name].push(callback);
757− },
758−
759− /**
760− * Runs a hook invoking all registered callbacks with the given environment variables.
761− *
762− * Callbacks will be invoked synchronously and in the order in which they were registered.
763− *
764− * @param {string} name The name of the hook.
765− * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
766− * @public
767− */
768− run: function (name, env) {
769− var callbacks = _.hooks.all[name];
770−
771− if (!callbacks || !callbacks.length) {
772− return;
773− }
774−
775− for (var i = 0, callback; (callback = callbacks[i++]); ) {
776− callback(env);
777− }
778− },
779− },
780−
781− Token: Token,
782− };
783− _self.Prism = _;
784−
785− // Typescript note:
786− // The following can be used to import the Token type in JSDoc:
787− //
788− // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
789−
790− /**
791− * Creates a new token.
792− *
793− * @param {string} type See {@link Token#type type}
794− * @param {string | TokenStream} content See {@link Token#content content}
795− * @param {string|string[]} [alias] The alias(es) of the token.
796− * @param {string} [matchedStr=""] A copy of the full string this token was created from.
797− * @class
798− * @global
799− * @public
800− */
801− function Token(type, content, alias, matchedStr) {
802− /**
803− * The type of the token.
804− *
805− * This is usually the key of a pattern in a {@link Grammar}.
806− *
807− * @type {string}
808− * @see GrammarToken
809− * @public
810− */
811− this.type = type;
812− /**
813− * The strings or tokens contained by this token.
814− *
815− * This will be a token stream if the pattern matched also defined an `inside` grammar.
816− *
817− * @type {string | TokenStream}
818− * @public
819− */
820− this.content = content;
821− /**
822− * The alias(es) of the token.
823− *
824− * @type {string|string[]}
825− * @see GrammarToken
826− * @public
827− */
828− this.alias = alias;
829− // Copy of the full string this token was created from
830− this.length = (matchedStr || "").length | 0;
831− }
832−
833− /**
834− * A token stream is an array of strings and {@link Token Token} objects.
835− *
836− * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
837− * them.
838− *
839− * 1. No adjacent strings.
840− * 2. No empty strings.
841− *
842− * The only exception here is the token stream that only contains the empty string and nothing else.
843− *
844− * @typedef {Array<string | Token>} TokenStream
845− * @global
846− * @public
847− */
848−
849− /**
850− * Converts the given token or token stream to an HTML representation.
851− *
852− * The following hooks will be run:
853− * 1. `wrap`: On each {@link Token}.
854− *
855− * @param {string | Token | TokenStream} o The token or token stream to be converted.
856− * @param {string} language The name of current language.
857− * @returns {string} The HTML representation of the token or token stream.
858− * @memberof Token
859− * @static
860− */
861− Token.stringify = function stringify(o, language) {
862− if (typeof o == "string") {
863− return o;
864− }
865− if (Array.isArray(o)) {
866− var s = "";
867− o.forEach(function (e) {
868− s += stringify(e, language);
869− });
870− return s;
871− }
872−
873− var env = {
874− type: o.type,
875− content: stringify(o.content, language),
876− tag: "span",
877− classes: ["token", o.type],
878− attributes: {},
879− language: language,
880− };
881−
882− var aliases = o.alias;
883− if (aliases) {
884− if (Array.isArray(aliases)) {
885− Array.prototype.push.apply(env.classes, aliases);
886− } else {
887− env.classes.push(aliases);
888− }
889− }
890−
891− _.hooks.run("wrap", env);
892−
893− var attributes = "";
894− for (var name in env.attributes) {
895− attributes +=
896− " " +
897− name +
898− '="' +
899− (env.attributes[name] || "").replace(/"/g, "&quot;") +
900− '"';
901− }
902−
903− return (
904− "<" +
905− env.tag +
906− ' class="' +
907− env.classes.join(" ") +
908− '"' +
909− attributes +
910− ">" +
911− env.content +
912− "</" +
913− env.tag +
914− ">"
915− );
916− };
917−
918− /**
919− * @param {RegExp} pattern
920− * @param {number} pos
921− * @param {string} text
922− * @param {boolean} lookbehind
923− * @returns {RegExpExecArray | null}
924− */
925− function matchPattern(pattern, pos, text, lookbehind) {
926− pattern.lastIndex = pos;
927− var match = pattern.exec(text);
928− if (match && lookbehind && match[1]) {
929− // change the match to remove the text matched by the Prism lookbehind group
930− var lookbehindLength = match[1].length;
931− match.index += lookbehindLength;
932− match[0] = match[0].slice(lookbehindLength);
933− }
934− return match;
935− }
936−
937− /**
938− * @param {string} text
939− * @param {LinkedList<string | Token>} tokenList
940− * @param {any} grammar
941− * @param {LinkedListNode<string | Token>} startNode
942− * @param {number} startPos
943− * @param {RematchOptions} [rematch]
944− * @returns {void}
945− * @private
946− *
947− * @typedef RematchOptions
948− * @property {string} cause
949− * @property {number} reach
950− */
951− function matchGrammar(
952− text,
953− tokenList,
954− grammar,
955− startNode,
956− startPos,
957− rematch,
958− ) {
959− for (var token in grammar) {
960− if (!grammar.hasOwnProperty(token) || !grammar[token]) {
961− continue;
962− }
963−
964− var patterns = grammar[token];
965− patterns = Array.isArray(patterns) ? patterns : [patterns];
966−
967− for (var j = 0; j < patterns.length; ++j) {
968− if (rematch && rematch.cause == token + "," + j) {
969− return;
970− }
971−
972− var patternObj = patterns[j];
973− var inside = patternObj.inside;
974− var lookbehind = !!patternObj.lookbehind;
975− var greedy = !!patternObj.greedy;
976− var alias = patternObj.alias;
977−
978− if (greedy && !patternObj.pattern.global) {
979− // Without the global flag, lastIndex won't work
980− var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
981− patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
982− }
983−
984− /** @type {RegExp} */
985− var pattern = patternObj.pattern || patternObj;
986−
987− for (
988− // iterate the token list and keep track of the current token/string position
989− var currentNode = startNode.next, pos = startPos;
990− currentNode !== tokenList.tail;
991− pos += currentNode.value.length, currentNode = currentNode.next
992− ) {
993− if (rematch && pos >= rematch.reach) {
994− break;
995− }
996−
997− var str = currentNode.value;
998−
999− if (tokenList.length > text.length) {
1000− // Something went terribly wrong, ABORT, ABORT!
1001− return;
1002− }
1003−
1004− if (str instanceof Token) {
1005− continue;
1006− }
1007−
1008− var removeCount = 1; // this is the to parameter of removeBetween
1009− var match;
1010−
1011− if (greedy) {
1012− match = matchPattern(pattern, pos, text, lookbehind);
1013− if (!match || match.index >= text.length) {
1014− break;
1015− }
1016−
1017− var from = match.index;
1018− var to = match.index + match[0].length;
1019− var p = pos;
1020−
1021− // find the node that contains the match
1022− p += currentNode.value.length;
1023− while (from >= p) {
1024− currentNode = currentNode.next;
1025− p += currentNode.value.length;
1026− }
1027− // adjust pos (and p)
1028− p -= currentNode.value.length;
1029− pos = p;
1030−
1031− // the current node is a Token, then the match starts inside another Token, which is invalid
1032− if (currentNode.value instanceof Token) {
1033− continue;
1034− }
1035−
1036− // find the last node which is affected by this match
1037− for (
1038− var k = currentNode;
1039− k !== tokenList.tail && (p < to || typeof k.value === "string");
1040− k = k.next
1041− ) {
1042− removeCount++;
1043− p += k.value.length;
1044− }
1045− removeCount--;
1046−
1047− // replace with the new match
1048− str = text.slice(pos, p);
1049− match.index -= pos;
1050− } else {
1051− match = matchPattern(pattern, 0, str, lookbehind);
1052− if (!match) {
1053− continue;
1054− }
1055− }
1056−
1057− // eslint-disable-next-line no-redeclare
1058− var from = match.index;
1059− var matchStr = match[0];
1060− var before = str.slice(0, from);
1061− var after = str.slice(from + matchStr.length);
1062−
1063− var reach = pos + str.length;
1064− if (rematch && reach > rematch.reach) {
1065− rematch.reach = reach;
1066− }
1067−
1068− var removeFrom = currentNode.prev;
1069−
1070− if (before) {
1071− removeFrom = addAfter(tokenList, removeFrom, before);
1072− pos += before.length;
1073− }
1074−
1075− removeRange(tokenList, removeFrom, removeCount);
1076−
1077− var wrapped = new Token(
1078− token,
1079− inside ? _.tokenize(matchStr, inside) : matchStr,
1080− alias,
1081− matchStr,
1082− );
1083− currentNode = addAfter(tokenList, removeFrom, wrapped);
1084−
1085− if (after) {
1086− addAfter(tokenList, currentNode, after);
1087− }
1088−
1089− if (removeCount > 1) {
1090− // at least one Token object was removed, so we have to do some rematching
1091− // this can only happen if the current pattern is greedy
1092−
1093− /** @type {RematchOptions} */
1094− var nestedRematch = {
1095− cause: token + "," + j,
1096− reach: reach,
1097− };
1098− matchGrammar(
1099− text,
1100− tokenList,
1101− grammar,
1102− currentNode.prev,
1103− pos,
1104− nestedRematch,
1105− );
1106−
1107− // the reach might have been extended because of the rematching
1108− if (rematch && nestedRematch.reach > rematch.reach) {
1109− rematch.reach = nestedRematch.reach;
1110− }
1111− }
1112− }
1113− }
1114− }
1115− }
1116−
1117− /**
1118− * @typedef LinkedListNode
1119− * @property {T} value
1120− * @property {LinkedListNode<T> | null} prev The previous node.
1121− * @property {LinkedListNode<T> | null} next The next node.
1122− * @template T
1123− * @private
1124− */
1125−
1126− /**
1127− * @template T
1128− * @private
1129− */
1130− function LinkedList() {
1131− /** @type {LinkedListNode<T>} */
1132− var head = { value: null, prev: null, next: null };
1133− /** @type {LinkedListNode<T>} */
1134− var tail = { value: null, prev: head, next: null };
1135− head.next = tail;
1136−
1137− /** @type {LinkedListNode<T>} */
1138− this.head = head;
1139− /** @type {LinkedListNode<T>} */
1140− this.tail = tail;
1141− this.length = 0;
1142− }
1143−
1144− /**
1145− * Adds a new node with the given value to the list.
1146− *
1147− * @param {LinkedList<T>} list
1148− * @param {LinkedListNode<T>} node
1149− * @param {T} value
1150− * @returns {LinkedListNode<T>} The added node.
1151− * @template T
1152− */
1153− function addAfter(list, node, value) {
1154− // assumes that node != list.tail && values.length >= 0
1155− var next = node.next;
1156−
1157− var newNode = { value: value, prev: node, next: next };
1158− node.next = newNode;
1159− next.prev = newNode;
1160− list.length++;
1161−
1162− return newNode;
1163− }
1164− /**
1165− * Removes `count` nodes after the given node. The given node will not be removed.
1166− *
1167− * @param {LinkedList<T>} list
1168− * @param {LinkedListNode<T>} node
1169− * @param {number} count
1170− * @template T
1171− */
1172− function removeRange(list, node, count) {
1173− var next = node.next;
1174− for (var i = 0; i < count && next !== list.tail; i++) {
1175− next = next.next;
1176− }
1177− node.next = next;
1178− next.prev = node;
1179− list.length -= i;
1180− }
1181− /**
1182− * @param {LinkedList<T>} list
1183− * @returns {T[]}
1184− * @template T
1185− */
1186− function toArray(list) {
1187− var array = [];
1188− var node = list.head.next;
1189− while (node !== list.tail) {
1190− array.push(node.value);
1191− node = node.next;
1192− }
1193− return array;
1194− }
1195−
1196− if (!_self.document) {
1197− if (!_self.addEventListener) {
1198− // in Node.js
1199− return _;
1200− }
1201−
1202− if (!_.disableWorkerMessageHandler) {
1203− // In worker
1204− _self.addEventListener(
1205− "message",
1206− function (evt) {
1207− var message = JSON.parse(evt.data);
1208− var lang = message.language;
1209− var code = message.code;
1210− var immediateClose = message.immediateClose;
1211−
1212− _self.postMessage(_.highlight(code, _.languages[lang], lang));
1213− if (immediateClose) {
1214− _self.close();
1215− }
1216− },
1217− false,
1218− );
1219− }
1220−
1221− return _;
1222− }
1223−
1224− // Get current script and highlight
1225− var script = _.util.currentScript();
1226−
1227− if (script) {
1228− _.filename = script.src;
1229−
1230− if (script.hasAttribute("data-manual")) {
1231− _.manual = true;
1232− }
1233− }
1234−
1235− function highlightAutomaticallyCallback() {
1236− if (!_.manual) {
1237− _.highlightAll();
1238− }
1239− }
1240−
1241− if (!_.manual) {
1242− // If the document state is "loading", then we'll use DOMContentLoaded.
1243− // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1244− // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1245− // might take longer one animation frame to execute which can create a race condition where only some plugins have
1246− // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1247− // See https://github.com/PrismJS/prism/issues/2102
1248− var readyState = document.readyState;
1249− if (
1250− readyState === "loading" ||
1251− (readyState === "interactive" && script && script.defer)
1252− ) {
1253− document.addEventListener(
1254− "DOMContentLoaded",
1255− highlightAutomaticallyCallback,
1256− );
1257− } else {
1258− if (requestAnimationFrame) {
1259− requestAnimationFrame(highlightAutomaticallyCallback);
1260− } else {
1261− window.setTimeout(highlightAutomaticallyCallback, 16);
1262− }
1263− }
1264− }
1265−
1266− return _;
1267−})(_self);
1268−
1269−if (typeof module !== "undefined" && module.exports) {
1270− module.exports = Prism;
22+
23+ // Private helper vars
24+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
25+ var uniqueId = 0;
26+
27+ // The grammar object for plaintext
28+ var plainTextGrammar = {};
29+
30+
31+ var _ = {
32+ /**
33+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
34+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
35+ * additional languages or plugins yourself.
36+ *
37+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
38+ *
39+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
40+ * empty Prism object into the global scope before loading the Prism script like this:
41+ *
42+ * ```js
43+ * window.Prism = window.Prism || {};
44+ * Prism.manual = true;
45+ * // add a new <script> to load Prism's script
46+ * ```
47+ *
48+ * @default false
49+ * @type {boolean}
50+ * @memberof Prism
51+ * @public
52+ */
53+ manual: _self.Prism && _self.Prism.manual,
54+ /**
55+ * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
56+ * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
57+ * own worker, you don't want it to do this.
58+ *
59+ * By setting this value to `true`, Prism will not add its own listeners to the worker.
60+ *
61+ * You obviously have to change this value before Prism executes. To do this, you can add an
62+ * empty Prism object into the global scope before loading the Prism script like this:
63+ *
64+ * ```js
65+ * window.Prism = window.Prism || {};
66+ * Prism.disableWorkerMessageHandler = true;
67+ * // Load Prism's script
68+ * ```
69+ *
70+ * @default false
71+ * @type {boolean}
72+ * @memberof Prism
73+ * @public
74+ */
75+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
76+
77+ /**
78+ * A namespace for utility methods.
79+ *
80+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
81+ * change or disappear at any time.
82+ *
83+ * @namespace
84+ * @memberof Prism
85+ */
86+ util: {
87+ encode: function encode(tokens) {
88+ if (tokens instanceof Token) {
89+ return new Token(tokens.type, encode(tokens.content), tokens.alias);
90+ } else if (Array.isArray(tokens)) {
91+ return tokens.map(encode);
92+ } else {
93+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
94+ }
95+ },
96+
97+ /**
98+ * Returns the name of the type of the given value.
99+ *
100+ * @param {any} o
101+ * @returns {string}
102+ * @example
103+ * type(null) === 'Null'
104+ * type(undefined) === 'Undefined'
105+ * type(123) === 'Number'
106+ * type('foo') === 'String'
107+ * type(true) === 'Boolean'
108+ * type([1, 2]) === 'Array'
109+ * type({}) === 'Object'
110+ * type(String) === 'Function'
111+ * type(/abc+/) === 'RegExp'
112+ */
113+ type: function (o) {
114+ return Object.prototype.toString.call(o).slice(8, -1);
115+ },
116+
117+ /**
118+ * Returns a unique number for the given object. Later calls will still return the same number.
119+ *
120+ * @param {Object} obj
121+ * @returns {number}
122+ */
123+ objId: function (obj) {
124+ if (!obj['__id']) {
125+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
126+ }
127+ return obj['__id'];
128+ },
129+
130+ /**
131+ * Creates a deep clone of the given object.
132+ *
133+ * The main intended use of this function is to clone language definitions.
134+ *
135+ * @param {T} o
136+ * @param {Record<number, any>} [visited]
137+ * @returns {T}
138+ * @template T
139+ */
140+ clone: function deepClone(o, visited) {
141+ visited = visited || {};
142+
143+ var clone; var id;
144+ switch (_.util.type(o)) {
145+ case 'Object':
146+ id = _.util.objId(o);
147+ if (visited[id]) {
148+ return visited[id];
149+ }
150+ clone = /** @type {Record<string, any>} */ ({});
151+ visited[id] = clone;
152+
153+ for (var key in o) {
154+ if (o.hasOwnProperty(key)) {
155+ clone[key] = deepClone(o[key], visited);
156+ }
157+ }
158+
159+ return /** @type {any} */ (clone);
160+
161+ case 'Array':
162+ id = _.util.objId(o);
163+ if (visited[id]) {
164+ return visited[id];
165+ }
166+ clone = [];
167+ visited[id] = clone;
168+
169+ (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
170+ clone[i] = deepClone(v, visited);
171+ });
172+
173+ return /** @type {any} */ (clone);
174+
175+ default:
176+ return o;
177+ }
178+ },
179+
180+ /**
181+ * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
182+ *
183+ * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
184+ *
185+ * @param {Element} element
186+ * @returns {string}
187+ */
188+ getLanguage: function (element) {
189+ while (element) {
190+ var m = lang.exec(element.className);
191+ if (m) {
192+ return m[1].toLowerCase();
193+ }
194+ element = element.parentElement;
195+ }
196+ return 'none';
197+ },
198+
199+ /**
200+ * Sets the Prism `language-xxxx` class of the given element.
201+ *
202+ * @param {Element} element
203+ * @param {string} language
204+ * @returns {void}
205+ */
206+ setLanguage: function (element, language) {
207+ // remove all `language-xxxx` classes
208+ // (this might leave behind a leading space)
209+ element.className = element.className.replace(RegExp(lang, 'gi'), '');
210+
211+ // add the new `language-xxxx` class
212+ // (using `classList` will automatically clean up spaces for us)
213+ element.classList.add('language-' + language);
214+ },
215+
216+ /**
217+ * Returns the script element that is currently executing.
218+ *
219+ * This does __not__ work for line script element.
220+ *
221+ * @returns {HTMLScriptElement | null}
222+ */
223+ currentScript: function () {
224+ if (typeof document === 'undefined') {
225+ return null;
226+ }
227+ if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
228+ return /** @type {any} */ (document.currentScript);
229+ }
230+
231+ // IE11 workaround
232+ // we'll get the src of the current script by parsing IE11's error stack trace
233+ // this will not work for inline scripts
234+
235+ try {
236+ throw new Error();
237+ } catch (err) {
238+ // Get file src url from stack. Specifically works with the format of stack traces in IE.
239+ // A stack will look like this:
240+ //
241+ // Error
242+ // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
243+ // at Global code (http://localhost/components/prism-core.js:606:1)
244+
245+ var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
246+ if (src) {
247+ var scripts = document.getElementsByTagName('script');
248+ for (var i in scripts) {
249+ if (scripts[i].src == src) {
250+ return scripts[i];
251+ }
252+ }
253+ }
254+ return null;
255+ }
256+ },
257+
258+ /**
259+ * Returns whether a given class is active for `element`.
260+ *
261+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
262+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
263+ * given class is just the given class with a `no-` prefix.
264+ *
265+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
266+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
267+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
268+ *
269+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
270+ * version of it, the class is considered active.
271+ *
272+ * @param {Element} element
273+ * @param {string} className
274+ * @param {boolean} [defaultActivation=false]
275+ * @returns {boolean}
276+ */
277+ isActive: function (element, className, defaultActivation) {
278+ var no = 'no-' + className;
279+
280+ while (element) {
281+ var classList = element.classList;
282+ if (classList.contains(className)) {
283+ return true;
284+ }
285+ if (classList.contains(no)) {
286+ return false;
287+ }
288+ element = element.parentElement;
289+ }
290+ return !!defaultActivation;
291+ }
292+ },
293+
294+ /**
295+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
296+ *
297+ * @namespace
298+ * @memberof Prism
299+ * @public
300+ */
301+ languages: {
302+ /**
303+ * The grammar for plain, unformatted text.
304+ */
305+ plain: plainTextGrammar,
306+ plaintext: plainTextGrammar,
307+ text: plainTextGrammar,
308+ txt: plainTextGrammar,
309+
310+ /**
311+ * Creates a deep copy of the language with the given id and appends the given tokens.
312+ *
313+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
314+ * will be overwritten at its original position.
315+ *
316+ * ## Best practices
317+ *
318+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
319+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
320+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
321+ *
322+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
323+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
324+ *
325+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
326+ * @param {Grammar} redef The new tokens to append.
327+ * @returns {Grammar} The new language created.
328+ * @public
329+ * @example
330+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
331+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
332+ * // at its original position
333+ * 'comment': { ... },
334+ * // CSS doesn't have a 'color' token, so this token will be appended
335+ * 'color': /\b(?:red|green|blue)\b/
336+ * });
337+ */
338+ extend: function (id, redef) {
339+ var lang = _.util.clone(_.languages[id]);
340+
341+ for (var key in redef) {
342+ lang[key] = redef[key];
343+ }
344+
345+ return lang;
346+ },
347+
348+ /**
349+ * Inserts tokens _before_ another token in a language definition or any other grammar.
350+ *
351+ * ## Usage
352+ *
353+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
354+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
355+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
356+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
357+ * this:
358+ *
359+ * ```js
360+ * Prism.languages.markup.style = {
361+ * // token
362+ * };
363+ * ```
364+ *
365+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
366+ * before existing tokens. For the CSS example above, you would use it like this:
367+ *
368+ * ```js
369+ * Prism.languages.insertBefore('markup', 'cdata', {
370+ * 'style': {
371+ * // token
372+ * }
373+ * });
374+ * ```
375+ *
376+ * ## Special cases
377+ *
378+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
379+ * will be ignored.
380+ *
381+ * This behavior can be used to insert tokens after `before`:
382+ *
383+ * ```js
384+ * Prism.languages.insertBefore('markup', 'comment', {
385+ * 'comment': Prism.languages.markup.comment,
386+ * // tokens after 'comment'
387+ * });
388+ * ```
389+ *
390+ * ## Limitations
391+ *
392+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
393+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
394+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
395+ * deleting properties which is necessary to insert at arbitrary positions.
396+ *
397+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
398+ * Instead, it will create a new object and replace all references to the target object with the new one. This
399+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
400+ *
401+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
402+ * you hold the target object in a variable, then the value of the variable will not change.
403+ *
404+ * ```js
405+ * var oldMarkup = Prism.languages.markup;
406+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
407+ *
408+ * assert(oldMarkup !== Prism.languages.markup);
409+ * assert(newMarkup === Prism.languages.markup);
410+ * ```
411+ *
412+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
413+ * object to be modified.
414+ * @param {string} before The key to insert before.
415+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
416+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
417+ * object to be modified.
418+ *
419+ * Defaults to `Prism.languages`.
420+ * @returns {Grammar} The new grammar object.
421+ * @public
422+ */
423+ insertBefore: function (inside, before, insert, root) {
424+ root = root || /** @type {any} */ (_.languages);
425+ var grammar = root[inside];
426+ /** @type {Grammar} */
427+ var ret = {};
428+
429+ for (var token in grammar) {
430+ if (grammar.hasOwnProperty(token)) {
431+
432+ if (token == before) {
433+ for (var newToken in insert) {
434+ if (insert.hasOwnProperty(newToken)) {
435+ ret[newToken] = insert[newToken];
436+ }
437+ }
438+ }
439+
440+ // Do not insert token which also occur in insert. See #1525
441+ if (!insert.hasOwnProperty(token)) {
442+ ret[token] = grammar[token];
443+ }
444+ }
445+ }
446+
447+ var old = root[inside];
448+ root[inside] = ret;
449+
450+ // Update references in other language definitions
451+ _.languages.DFS(_.languages, function (key, value) {
452+ if (value === old && key != inside) {
453+ this[key] = ret;
454+ }
455+ });
456+
457+ return ret;
458+ },
459+
460+ // Traverse a language definition with Depth First Search
461+ DFS: function DFS(o, callback, type, visited) {
462+ visited = visited || {};
463+
464+ var objId = _.util.objId;
465+
466+ for (var i in o) {
467+ if (o.hasOwnProperty(i)) {
468+ callback.call(o, i, o[i], type || i);
469+
470+ var property = o[i];
471+ var propertyType = _.util.type(property);
472+
473+ if (propertyType === 'Object' && !visited[objId(property)]) {
474+ visited[objId(property)] = true;
475+ DFS(property, callback, null, visited);
476+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
477+ visited[objId(property)] = true;
478+ DFS(property, callback, i, visited);
479+ }
480+ }
481+ }
482+ }
483+ },
484+
485+ plugins: {},
486+
487+ /**
488+ * This is the most high-level function in Prism’s API.
489+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
490+ * each one of them.
491+ *
492+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
493+ *
494+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
495+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
496+ * @memberof Prism
497+ * @public
498+ */
499+ highlightAll: function (async, callback) {
500+ _.highlightAllUnder(document, async, callback);
501+ },
502+
503+ /**
504+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
505+ * {@link Prism.highlightElement} on each one of them.
506+ *
507+ * The following hooks will be run:
508+ * 1. `before-highlightall`
509+ * 2. `before-all-elements-highlight`
510+ * 3. All hooks of {@link Prism.highlightElement} for each element.
511+ *
512+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
513+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
514+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
515+ * @memberof Prism
516+ * @public
517+ */
518+ highlightAllUnder: function (container, async, callback) {
519+ var env = {
520+ callback: callback,
521+ container: container,
522+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
523+ };
524+
525+ _.hooks.run('before-highlightall', env);
526+
527+ env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
528+
529+ _.hooks.run('before-all-elements-highlight', env);
530+
531+ for (var i = 0, element; (element = env.elements[i++]);) {
532+ _.highlightElement(element, async === true, env.callback);
533+ }
534+ },
535+
536+ /**
537+ * Highlights the code inside a single element.
538+ *
539+ * The following hooks will be run:
540+ * 1. `before-sanity-check`
541+ * 2. `before-highlight`
542+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
543+ * 4. `before-insert`
544+ * 5. `after-highlight`
545+ * 6. `complete`
546+ *
547+ * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
548+ * the element's language.
549+ *
550+ * @param {Element} element The element containing the code.
551+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
552+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
553+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
554+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
555+ *
556+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
557+ * asynchronous highlighting to work. You can build your own bundle on the
558+ * [Download page](https://prismjs.com/download.html).
559+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
560+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
561+ * @memberof Prism
562+ * @public
563+ */
564+ highlightElement: function (element, async, callback) {
565+ // Find language
566+ var language = _.util.getLanguage(element);
567+ var grammar = _.languages[language];
568+
569+ // Set language on the element, if not present
570+ _.util.setLanguage(element, language);
571+
572+ // Set language on the parent, for styling
573+ var parent = element.parentElement;
574+ if (parent && parent.nodeName.toLowerCase() === 'pre') {
575+ _.util.setLanguage(parent, language);
576+ }
577+
578+ var code = element.textContent;
579+
580+ var env = {
581+ element: element,
582+ language: language,
583+ grammar: grammar,
584+ code: code
585+ };
586+
587+ function insertHighlightedCode(highlightedCode) {
588+ env.highlightedCode = highlightedCode;
589+
590+ _.hooks.run('before-insert', env);
591+
592+ env.element.innerHTML = env.highlightedCode;
593+
594+ _.hooks.run('after-highlight', env);
595+ _.hooks.run('complete', env);
596+ callback && callback.call(env.element);
597+ }
598+
599+ _.hooks.run('before-sanity-check', env);
600+
601+ // plugins may change/add the parent/element
602+ parent = env.element.parentElement;
603+ if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
604+ parent.setAttribute('tabindex', '0');
605+ }
606+
607+ if (!env.code) {
608+ _.hooks.run('complete', env);
609+ callback && callback.call(env.element);
610+ return;
611+ }
612+
613+ _.hooks.run('before-highlight', env);
614+
615+ if (!env.grammar) {
616+ insertHighlightedCode(_.util.encode(env.code));
617+ return;
618+ }
619+
620+ if (async && _self.Worker) {
621+ var worker = new Worker(_.filename);
622+
623+ worker.onmessage = function (evt) {
624+ insertHighlightedCode(evt.data);
625+ };
626+
627+ worker.postMessage(JSON.stringify({
628+ language: env.language,
629+ code: env.code,
630+ immediateClose: true
631+ }));
632+ } else {
633+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
634+ }
635+ },
636+
637+ /**
638+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
639+ * and the language definitions to use, and returns a string with the HTML produced.
640+ *
641+ * The following hooks will be run:
642+ * 1. `before-tokenize`
643+ * 2. `after-tokenize`
644+ * 3. `wrap`: On each {@link Token}.
645+ *
646+ * @param {string} text A string with the code to be highlighted.
647+ * @param {Grammar} grammar An object containing the tokens to use.
648+ *
649+ * Usually a language definition like `Prism.languages.markup`.
650+ * @param {string} language The name of the language definition passed to `grammar`.
651+ * @returns {string} The highlighted HTML.
652+ * @memberof Prism
653+ * @public
654+ * @example
655+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
656+ */
657+ highlight: function (text, grammar, language) {
658+ var env = {
659+ code: text,
660+ grammar: grammar,
661+ language: language
662+ };
663+ _.hooks.run('before-tokenize', env);
664+ if (!env.grammar) {
665+ throw new Error('The language "' + env.language + '" has no grammar.');
666+ }
667+ env.tokens = _.tokenize(env.code, env.grammar);
668+ _.hooks.run('after-tokenize', env);
669+ return Token.stringify(_.util.encode(env.tokens), env.language);
670+ },
671+
672+ /**
673+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
674+ * and the language definitions to use, and returns an array with the tokenized code.
675+ *
676+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
677+ *
678+ * This method could be useful in other contexts as well, as a very crude parser.
679+ *
680+ * @param {string} text A string with the code to be highlighted.
681+ * @param {Grammar} grammar An object containing the tokens to use.
682+ *
683+ * Usually a language definition like `Prism.languages.markup`.
684+ * @returns {TokenStream} An array of strings and tokens, a token stream.
685+ * @memberof Prism
686+ * @public
687+ * @example
688+ * let code = `var foo = 0;`;
689+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
690+ * tokens.forEach(token => {
691+ * if (token instanceof Prism.Token && token.type === 'number') {
692+ * console.log(`Found numeric literal: ${token.content}`);
693+ * }
694+ * });
695+ */
696+ tokenize: function (text, grammar) {
697+ var rest = grammar.rest;
698+ if (rest) {
699+ for (var token in rest) {
700+ grammar[token] = rest[token];
701+ }
702+
703+ delete grammar.rest;
704+ }
705+
706+ var tokenList = new LinkedList();
707+ addAfter(tokenList, tokenList.head, text);
708+
709+ matchGrammar(text, tokenList, grammar, tokenList.head, 0);
710+
711+ return toArray(tokenList);
712+ },
713+
714+ /**
715+ * @namespace
716+ * @memberof Prism
717+ * @public
718+ */
719+ hooks: {
720+ all: {},
721+
722+ /**
723+ * Adds the given callback to the list of callbacks for the given hook.
724+ *
725+ * The callback will be invoked when the hook it is registered for is run.
726+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
727+ *
728+ * One callback function can be registered to multiple hooks and the same hook multiple times.
729+ *
730+ * @param {string} name The name of the hook.
731+ * @param {HookCallback} callback The callback function which is given environment variables.
732+ * @public
733+ */
734+ add: function (name, callback) {
735+ var hooks = _.hooks.all;
736+
737+ hooks[name] = hooks[name] || [];
738+
739+ hooks[name].push(callback);
740+ },
741+
742+ /**
743+ * Runs a hook invoking all registered callbacks with the given environment variables.
744+ *
745+ * Callbacks will be invoked synchronously and in the order in which they were registered.
746+ *
747+ * @param {string} name The name of the hook.
748+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
749+ * @public
750+ */
751+ run: function (name, env) {
752+ var callbacks = _.hooks.all[name];
753+
754+ if (!callbacks || !callbacks.length) {
755+ return;
756+ }
757+
758+ for (var i = 0, callback; (callback = callbacks[i++]);) {
759+ callback(env);
760+ }
761+ }
762+ },
763+
764+ Token: Token
765+ };
766+ _self.Prism = _;
767+
768+
769+ // Typescript note:
770+ // The following can be used to import the Token type in JSDoc:
771+ //
772+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
773+
774+ /**
775+ * Creates a new token.
776+ *
777+ * @param {string} type See {@link Token#type type}
778+ * @param {string | TokenStream} content See {@link Token#content content}
779+ * @param {string|string[]} [alias] The alias(es) of the token.
780+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
781+ * @class
782+ * @global
783+ * @public
784+ */
785+ function Token(type, content, alias, matchedStr) {
786+ /**
787+ * The type of the token.
788+ *
789+ * This is usually the key of a pattern in a {@link Grammar}.
790+ *
791+ * @type {string}
792+ * @see GrammarToken
793+ * @public
794+ */
795+ this.type = type;
796+ /**
797+ * The strings or tokens contained by this token.
798+ *
799+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
800+ *
801+ * @type {string | TokenStream}
802+ * @public
803+ */
804+ this.content = content;
805+ /**
806+ * The alias(es) of the token.
807+ *
808+ * @type {string|string[]}
809+ * @see GrammarToken
810+ * @public
811+ */
812+ this.alias = alias;
813+ // Copy of the full string this token was created from
814+ this.length = (matchedStr || '').length | 0;
815+ }
816+
817+ /**
818+ * A token stream is an array of strings and {@link Token Token} objects.
819+ *
820+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
821+ * them.
822+ *
823+ * 1. No adjacent strings.
824+ * 2. No empty strings.
825+ *
826+ * The only exception here is the token stream that only contains the empty string and nothing else.
827+ *
828+ * @typedef {Array<string | Token>} TokenStream
829+ * @global
830+ * @public
831+ */
832+
833+ /**
834+ * Converts the given token or token stream to an HTML representation.
835+ *
836+ * The following hooks will be run:
837+ * 1. `wrap`: On each {@link Token}.
838+ *
839+ * @param {string | Token | TokenStream} o The token or token stream to be converted.
840+ * @param {string} language The name of current language.
841+ * @returns {string} The HTML representation of the token or token stream.
842+ * @memberof Token
843+ * @static
844+ */
845+ Token.stringify = function stringify(o, language) {
846+ if (typeof o == 'string') {
847+ return o;
848+ }
849+ if (Array.isArray(o)) {
850+ var s = '';
851+ o.forEach(function (e) {
852+ s += stringify(e, language);
853+ });
854+ return s;
855+ }
856+
857+ var env = {
858+ type: o.type,
859+ content: stringify(o.content, language),
860+ tag: 'span',
861+ classes: ['token', o.type],
862+ attributes: {},
863+ language: language
864+ };
865+
866+ var aliases = o.alias;
867+ if (aliases) {
868+ if (Array.isArray(aliases)) {
869+ Array.prototype.push.apply(env.classes, aliases);
870+ } else {
871+ env.classes.push(aliases);
872+ }
873+ }
874+
875+ _.hooks.run('wrap', env);
876+
877+ var attributes = '';
878+ for (var name in env.attributes) {
879+ attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
880+ }
881+
882+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
883+ };
884+
885+ /**
886+ * @param {RegExp} pattern
887+ * @param {number} pos
888+ * @param {string} text
889+ * @param {boolean} lookbehind
890+ * @returns {RegExpExecArray | null}
891+ */
892+ function matchPattern(pattern, pos, text, lookbehind) {
893+ pattern.lastIndex = pos;
894+ var match = pattern.exec(text);
895+ if (match && lookbehind && match[1]) {
896+ // change the match to remove the text matched by the Prism lookbehind group
897+ var lookbehindLength = match[1].length;
898+ match.index += lookbehindLength;
899+ match[0] = match[0].slice(lookbehindLength);
900+ }
901+ return match;
902+ }
903+
904+ /**
905+ * @param {string} text
906+ * @param {LinkedList<string | Token>} tokenList
907+ * @param {any} grammar
908+ * @param {LinkedListNode<string | Token>} startNode
909+ * @param {number} startPos
910+ * @param {RematchOptions} [rematch]
911+ * @returns {void}
912+ * @private
913+ *
914+ * @typedef RematchOptions
915+ * @property {string} cause
916+ * @property {number} reach
917+ */
918+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
919+ for (var token in grammar) {
920+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
921+ continue;
922+ }
923+
924+ var patterns = grammar[token];
925+ patterns = Array.isArray(patterns) ? patterns : [patterns];
926+
927+ for (var j = 0; j < patterns.length; ++j) {
928+ if (rematch && rematch.cause == token + ',' + j) {
929+ return;
930+ }
931+
932+ var patternObj = patterns[j];
933+ var inside = patternObj.inside;
934+ var lookbehind = !!patternObj.lookbehind;
935+ var greedy = !!patternObj.greedy;
936+ var alias = patternObj.alias;
937+
938+ if (greedy && !patternObj.pattern.global) {
939+ // Without the global flag, lastIndex won't work
940+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
941+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
942+ }
943+
944+ /** @type {RegExp} */
945+ var pattern = patternObj.pattern || patternObj;
946+
947+ for ( // iterate the token list and keep track of the current token/string position
948+ var currentNode = startNode.next, pos = startPos;
949+ currentNode !== tokenList.tail;
950+ pos += currentNode.value.length, currentNode = currentNode.next
951+ ) {
952+
953+ if (rematch && pos >= rematch.reach) {
954+ break;
955+ }
956+
957+ var str = currentNode.value;
958+
959+ if (tokenList.length > text.length) {
960+ // Something went terribly wrong, ABORT, ABORT!
961+ return;
962+ }
963+
964+ if (str instanceof Token) {
965+ continue;
966+ }
967+
968+ var removeCount = 1; // this is the to parameter of removeBetween
969+ var match;
970+
971+ if (greedy) {
972+ match = matchPattern(pattern, pos, text, lookbehind);
973+ if (!match || match.index >= text.length) {
974+ break;
975+ }
976+
977+ var from = match.index;
978+ var to = match.index + match[0].length;
979+ var p = pos;
980+
981+ // find the node that contains the match
982+ p += currentNode.value.length;
983+ while (from >= p) {
984+ currentNode = currentNode.next;
985+ p += currentNode.value.length;
986+ }
987+ // adjust pos (and p)
988+ p -= currentNode.value.length;
989+ pos = p;
990+
991+ // the current node is a Token, then the match starts inside another Token, which is invalid
992+ if (currentNode.value instanceof Token) {
993+ continue;
994+ }
995+
996+ // find the last node which is affected by this match
997+ for (
998+ var k = currentNode;
999+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
1000+ k = k.next
1001+ ) {
1002+ removeCount++;
1003+ p += k.value.length;
1004+ }
1005+ removeCount--;
1006+
1007+ // replace with the new match
1008+ str = text.slice(pos, p);
1009+ match.index -= pos;
1010+ } else {
1011+ match = matchPattern(pattern, 0, str, lookbehind);
1012+ if (!match) {
1013+ continue;
1014+ }
1015+ }
1016+
1017+ // eslint-disable-next-line no-redeclare
1018+ var from = match.index;
1019+ var matchStr = match[0];
1020+ var before = str.slice(0, from);
1021+ var after = str.slice(from + matchStr.length);
1022+
1023+ var reach = pos + str.length;
1024+ if (rematch && reach > rematch.reach) {
1025+ rematch.reach = reach;
1026+ }
1027+
1028+ var removeFrom = currentNode.prev;
1029+
1030+ if (before) {
1031+ removeFrom = addAfter(tokenList, removeFrom, before);
1032+ pos += before.length;
1033+ }
1034+
1035+ removeRange(tokenList, removeFrom, removeCount);
1036+
1037+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1038+ currentNode = addAfter(tokenList, removeFrom, wrapped);
1039+
1040+ if (after) {
1041+ addAfter(tokenList, currentNode, after);
1042+ }
1043+
1044+ if (removeCount > 1) {
1045+ // at least one Token object was removed, so we have to do some rematching
1046+ // this can only happen if the current pattern is greedy
1047+
1048+ /** @type {RematchOptions} */
1049+ var nestedRematch = {
1050+ cause: token + ',' + j,
1051+ reach: reach
1052+ };
1053+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1054+
1055+ // the reach might have been extended because of the rematching
1056+ if (rematch && nestedRematch.reach > rematch.reach) {
1057+ rematch.reach = nestedRematch.reach;
1058+ }
1059+ }
1060+ }
1061+ }
1062+ }
1063+ }
1064+
1065+ /**
1066+ * @typedef LinkedListNode
1067+ * @property {T} value
1068+ * @property {LinkedListNode<T> | null} prev The previous node.
1069+ * @property {LinkedListNode<T> | null} next The next node.
1070+ * @template T
1071+ * @private
1072+ */
1073+
1074+ /**
1075+ * @template T
1076+ * @private
1077+ */
1078+ function LinkedList() {
1079+ /** @type {LinkedListNode<T>} */
1080+ var head = { value: null, prev: null, next: null };
1081+ /** @type {LinkedListNode<T>} */
1082+ var tail = { value: null, prev: head, next: null };
1083+ head.next = tail;
1084+
1085+ /** @type {LinkedListNode<T>} */
1086+ this.head = head;
1087+ /** @type {LinkedListNode<T>} */
1088+ this.tail = tail;
1089+ this.length = 0;
1090+ }
1091+
1092+ /**
1093+ * Adds a new node with the given value to the list.
1094+ *
1095+ * @param {LinkedList<T>} list
1096+ * @param {LinkedListNode<T>} node
1097+ * @param {T} value
1098+ * @returns {LinkedListNode<T>} The added node.
1099+ * @template T
1100+ */
1101+ function addAfter(list, node, value) {
1102+ // assumes that node != list.tail && values.length >= 0
1103+ var next = node.next;
1104+
1105+ var newNode = { value: value, prev: node, next: next };
1106+ node.next = newNode;
1107+ next.prev = newNode;
1108+ list.length++;
1109+
1110+ return newNode;
1111+ }
1112+ /**
1113+ * Removes `count` nodes after the given node. The given node will not be removed.
1114+ *
1115+ * @param {LinkedList<T>} list
1116+ * @param {LinkedListNode<T>} node
1117+ * @param {number} count
1118+ * @template T
1119+ */
1120+ function removeRange(list, node, count) {
1121+ var next = node.next;
1122+ for (var i = 0; i < count && next !== list.tail; i++) {
1123+ next = next.next;
1124+ }
1125+ node.next = next;
1126+ next.prev = node;
1127+ list.length -= i;
1128+ }
1129+ /**
1130+ * @param {LinkedList<T>} list
1131+ * @returns {T[]}
1132+ * @template T
1133+ */
1134+ function toArray(list) {
1135+ var array = [];
1136+ var node = list.head.next;
1137+ while (node !== list.tail) {
1138+ array.push(node.value);
1139+ node = node.next;
1140+ }
1141+ return array;
1142+ }
1143+
1144+
1145+ if (!_self.document) {
1146+ if (!_self.addEventListener) {
1147+ // in Node.js
1148+ return _;
1149+ }
1150+
1151+ if (!_.disableWorkerMessageHandler) {
1152+ // In worker
1153+ _self.addEventListener('message', function (evt) {
1154+ var message = JSON.parse(evt.data);
1155+ var lang = message.language;
1156+ var code = message.code;
1157+ var immediateClose = message.immediateClose;
1158+
1159+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
1160+ if (immediateClose) {
1161+ _self.close();
1162+ }
1163+ }, false);
1164+ }
1165+
1166+ return _;
1167+ }
1168+
1169+ // Get current script and highlight
1170+ var script = _.util.currentScript();
1171+
1172+ if (script) {
1173+ _.filename = script.src;
1174+
1175+ if (script.hasAttribute('data-manual')) {
1176+ _.manual = true;
1177+ }
1178+ }
1179+
1180+ function highlightAutomaticallyCallback() {
1181+ if (!_.manual) {
1182+ _.highlightAll();
1183+ }
1184+ }
1185+
1186+ if (!_.manual) {
1187+ // If the document state is "loading", then we'll use DOMContentLoaded.
1188+ // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1189+ // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1190+ // might take longer one animation frame to execute which can create a race condition where only some plugins have
1191+ // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1192+ // See https://github.com/PrismJS/prism/issues/2102
1193+ var readyState = document.readyState;
1194+ if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1195+ document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1196+ } else {
1197+ if (window.requestAnimationFrame) {
1198+ window.requestAnimationFrame(highlightAutomaticallyCallback);
1199+ } else {
1200+ window.setTimeout(highlightAutomaticallyCallback, 16);
1201+ }
1202+ }
1203+ }
1204+
1205+ return _;
1206+
1207+}(_self));
1208+
1209+if (typeof module !== 'undefined' && module.exports) {
1210+ module.exports = Prism;
12711211 }
12721212
12731213 // hack for components to work correctly in node.js
1274−if (typeof global !== "undefined") {
1275− global.Prism = Prism;
1214+if (typeof global !== 'undefined') {
1215+ global.Prism = Prism;
12761216 }
12771217
12781218 // some additional documentation/types
@@ -1323,1096 +1263,1007 @@ if (typeof global !== "undefined") { · 44 unmodified lines
13231263 * @global
13241264 * @public
13251265 */
1266+;
13261267 Prism.languages.markup = {
1327− comment: {
1328− pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1329− greedy: true,
1330− },
1331− prolog: {
1332− pattern: /<\?[\s\S]+?\?>/,
1333− greedy: true,
1334− },
1335− doctype: {
1336− // https://www.w3.org/TR/xml/#NT-doctypedecl
1337− pattern:
1338− /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1339− greedy: true,
1340− inside: {
1341− "internal-subset": {
1342− pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1343− lookbehind: true,
1344− greedy: true,
1345− inside: null, // see below
1346− },
1347− string: {
1348− pattern: /"[^"]*"|'[^']*'/,
1349− greedy: true,
1350− },
1351− punctuation: /^<!|>$|[[\]]/,
1352− "doctype-tag": /^DOCTYPE/i,
1353− name: /[^\s<>'"]+/,
1354− },
1355− },
1356− cdata: {
1357− pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1358− greedy: true,
1359− },
1360− tag: {
1361− pattern:
1362− /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1363− greedy: true,
1364− inside: {
1365− tag: {
1366− pattern: /^<\/?[^\s>\/]+/,
1367− inside: {
1368− punctuation: /^<\/?/,
1369− namespace: /^[^\s>\/:]+:/,
1370− },
1371− },
1372− "special-attr": [],
1373− "attr-value": {
1374− pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1375− inside: {
1376− punctuation: [
1377− {
1378− pattern: /^=/,
1379− alias: "attr-equals",
1380− },
1381− {
1382− pattern: /^(\s*)["']|["']$/,
1383− lookbehind: true,
1384− },
1385− ],
1386− },
1387− },
1388− punctuation: /\/?>/,
1389− "attr-name": {
1390− pattern: /[^\s>\/]+/,
1391− inside: {
1392− namespace: /^[^\s>\/:]+:/,
1393− },
1394− },
1395− },
1396− },
1397− entity: [
1398− {
1399− pattern: /&[\da-z]{1,8};/i,
1400− alias: "named-entity",
1401− },
1402− /&#x?[\da-f]{1,8};/i,
1403− ],
1268+ 'comment': {
1269+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1270+ greedy: true
1271+ },
1272+ 'prolog': {
1273+ pattern: /<\?[\s\S]+?\?>/,
1274+ greedy: true
1275+ },
1276+ 'doctype': {
1277+ // https://www.w3.org/TR/xml/#NT-doctypedecl
1278+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1279+ greedy: true,
1280+ inside: {
1281+ 'internal-subset': {
1282+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1283+ lookbehind: true,
1284+ greedy: true,
1285+ inside: null // see below
1286+ },
1287+ 'string': {
1288+ pattern: /"[^"]*"|'[^']*'/,
1289+ greedy: true
1290+ },
1291+ 'punctuation': /^<!|>$|[[\]]/,
1292+ 'doctype-tag': /^DOCTYPE/i,
1293+ 'name': /[^\s<>'"]+/
1294+ }
1295+ },
1296+ 'cdata': {
1297+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1298+ greedy: true
1299+ },
1300+ 'tag': {
1301+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1302+ greedy: true,
1303+ inside: {
1304+ 'tag': {
1305+ pattern: /^<\/?[^\s>\/]+/,
1306+ inside: {
1307+ 'punctuation': /^<\/?/,
1308+ 'namespace': /^[^\s>\/:]+:/
1309+ }
1310+ },
1311+ 'special-attr': [],
1312+ 'attr-value': {
1313+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1314+ inside: {
1315+ 'punctuation': [
1316+ {
1317+ pattern: /^=/,
1318+ alias: 'attr-equals'
1319+ },
1320+ {
1321+ pattern: /^(\s*)["']|["']$/,
1322+ lookbehind: true
1323+ }
1324+ ]
1325+ }
1326+ },
1327+ 'punctuation': /\/?>/,
1328+ 'attr-name': {
1329+ pattern: /[^\s>\/]+/,
1330+ inside: {
1331+ 'namespace': /^[^\s>\/:]+:/
1332+ }
1333+ }
1334+
1335+ }
1336+ },
1337+ 'entity': [
1338+ {
1339+ pattern: /&[\da-z]{1,8};/i,
1340+ alias: 'named-entity'
1341+ },
1342+ /&#x?[\da-f]{1,8};/i
1343+ ]
14041344 };
14051345
1406−Prism.languages.markup["tag"].inside["attr-value"].inside["entity"] =
1407− Prism.languages.markup["entity"];
1408−Prism.languages.markup["doctype"].inside["internal-subset"].inside =
1409− Prism.languages.markup;
1346+Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
1347+ Prism.languages.markup['entity'];
1348+Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
14101349
14111350 // Plugin to make entity title show the real entity, idea by Roman Komarov
1412−Prism.hooks.add("wrap", function (env) {
1413− if (env.type === "entity") {
1414− env.attributes["title"] = env.content.replace(/&amp;/, "&");
1415− }
1351+Prism.hooks.add('wrap', function (env) {
1352+
1353+ if (env.type === 'entity') {
1354+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
1355+ }
14161356 });
14171357
1418−Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
1419− /**
1420− * Adds an inlined language to markup.
1421− *
1422− * An example of an inlined language is CSS with `<style>` tags.
1423− *
1424− * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1425− * case insensitive.
1426− * @param {string} lang The language key.
1427− * @example
1428− * addInlined('style', 'css');
1429− */
1430− value: function addInlined(tagName, lang) {
1431− var includedCdataInside = {};
1432− includedCdataInside["language-" + lang] = {
1433− pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1434− lookbehind: true,
1435− inside: Prism.languages[lang],
1436− };
1437− includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
1438−
1439− var inside = {
1440− "included-cdata": {
1441− pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1442− inside: includedCdataInside,
1443− },
1444− };
1445− inside["language-" + lang] = {
1446− pattern: /[\s\S]+/,
1447− inside: Prism.languages[lang],
1448− };
1449−
1450− var def = {};
1451− def[tagName] = {
1452− pattern: RegExp(
1453− /(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(
1454− /__/g,
1455− function () {
1456− return tagName;
1457− },
1458− ),
1459− "i",
1460− ),
1461− lookbehind: true,
1462− greedy: true,
1463− inside: inside,
1464− };
1465−
1466− Prism.languages.insertBefore("markup", "cdata", def);
1467− },
1358+Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1359+ /**
1360+ * Adds an inlined language to markup.
1361+ *
1362+ * An example of an inlined language is CSS with `<style>` tags.
1363+ *
1364+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1365+ * case insensitive.
1366+ * @param {string} lang The language key.
1367+ * @example
1368+ * addInlined('style', 'css');
1369+ */
1370+ value: function addInlined(tagName, lang) {
1371+ var includedCdataInside = {};
1372+ includedCdataInside['language-' + lang] = {
1373+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1374+ lookbehind: true,
1375+ inside: Prism.languages[lang]
1376+ };
1377+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
1378+
1379+ var inside = {
1380+ 'included-cdata': {
1381+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1382+ inside: includedCdataInside
1383+ }
1384+ };
1385+ inside['language-' + lang] = {
1386+ pattern: /[\s\S]+/,
1387+ inside: Prism.languages[lang]
1388+ };
1389+
1390+ var def = {};
1391+ def[tagName] = {
1392+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
1393+ lookbehind: true,
1394+ greedy: true,
1395+ inside: inside
1396+ };
1397+
1398+ Prism.languages.insertBefore('markup', 'cdata', def);
1399+ }
14681400 });
1469−Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
1470− /**
1471− * Adds an pattern to highlight languages embedded in HTML attributes.
1472− *
1473− * An example of an inlined language is CSS with `style` attributes.
1474− *
1475− * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1476− * case insensitive.
1477− * @param {string} lang The language key.
1478− * @example
1479− * addAttribute('style', 'css');
1480− */
1481− value: function (attrName, lang) {
1482− Prism.languages.markup.tag.inside["special-attr"].push({
1483− pattern: RegExp(
1484− /(^|["'\s])/.source +
1485− "(?:" +
1486− attrName +
1487− ")" +
1488− /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1489− "i",
1490− ),
1491− lookbehind: true,
1492− inside: {
1493− "attr-name": /^[^\s=]+/,
1494− "attr-value": {
1495− pattern: /=[\s\S]+/,
1496− inside: {
1497− value: {
1498− pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1499− lookbehind: true,
1500− alias: [lang, "language-" + lang],
1501− inside: Prism.languages[lang],
1502− },
1503− punctuation: [
1504− {
1505− pattern: /^=/,
1506− alias: "attr-equals",
1507− },
1508− /"|'/,
1509− ],
1510− },
1511− },
1512− },
1513− });
1514− },
1401+Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
1402+ /**
1403+ * Adds an pattern to highlight languages embedded in HTML attributes.
1404+ *
1405+ * An example of an inlined language is CSS with `style` attributes.
1406+ *
1407+ * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1408+ * case insensitive.
1409+ * @param {string} lang The language key.
1410+ * @example
1411+ * addAttribute('style', 'css');
1412+ */
1413+ value: function (attrName, lang) {
1414+ Prism.languages.markup.tag.inside['special-attr'].push({
1415+ pattern: RegExp(
1416+ /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1417+ 'i'
1418+ ),
1419+ lookbehind: true,
1420+ inside: {
1421+ 'attr-name': /^[^\s=]+/,
1422+ 'attr-value': {
1423+ pattern: /=[\s\S]+/,
1424+ inside: {
1425+ 'value': {
1426+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1427+ lookbehind: true,
1428+ alias: [lang, 'language-' + lang],
1429+ inside: Prism.languages[lang]
1430+ },
1431+ 'punctuation': [
1432+ {
1433+ pattern: /^=/,
1434+ alias: 'attr-equals'
1435+ },
1436+ /"|'/
1437+ ]
1438+ }
1439+ }
1440+ }
1441+ });
1442+ }
15151443 });
15161444
15171445 Prism.languages.html = Prism.languages.markup;
15181446 Prism.languages.mathml = Prism.languages.markup;
15191447 Prism.languages.svg = Prism.languages.markup;
15201448
1521−Prism.languages.xml = Prism.languages.extend("markup", {});
1449+Prism.languages.xml = Prism.languages.extend('markup', {});
15221450 Prism.languages.ssml = Prism.languages.xml;
15231451 Prism.languages.atom = Prism.languages.xml;
15241452 Prism.languages.rss = Prism.languages.xml;
15251453
15261454 (function (Prism) {
1527− var string =
1528− /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1529−
1530− Prism.languages.css = {
1531− comment: /\/\*[\s\S]*?\*\//,
1532− atrule: {
1533− pattern: RegExp(
1534− "@[\\w-](?:" +
1535− /[^;{\s"']|\s+(?!\s)/.source +
1536− "|" +
1537− string.source +
1538− ")*?" +
1539− /(?:;|(?=\s*\{))/.source,
1540− ),
1541− inside: {
1542− rule: /^@[\w-]+/,
1543− "selector-function-argument": {
1544− pattern:
1545− /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1546− lookbehind: true,
1547− alias: "selector",
1548− },
1549− keyword: {
1550− pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1551− lookbehind: true,
1552− },
1553− // See rest below
1554− },
1555− },
1556− url: {
1557− // https://drafts.csswg.org/css-values-3/#urls
1558− pattern: RegExp(
1559− "\\burl\\((?:" +
1560− string.source +
1561− "|" +
1562− /(?:[^\\\r\n()"']|\\[\s\S])*/.source +
1563− ")\\)",
1564− "i",
1565− ),
1566− greedy: true,
1567− inside: {
1568− function: /^url/i,
1569− punctuation: /^\(|\)$/,
1570− string: {
1571− pattern: RegExp("^" + string.source + "$"),
1572− alias: "url",
1573− },
1574− },
1575− },
1576− selector: {
1577− pattern: RegExp(
1578− "(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|" +
1579− string.source +
1580− ")*(?=\\s*\\{)",
1581− ),
1582− lookbehind: true,
1583− },
1584− string: {
1585− pattern: string,
1586− greedy: true,
1587− },
1588− property: {
1589− pattern:
1590− /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1591− lookbehind: true,
1592− },
1593− important: /!important\b/i,
1594− function: {
1595− pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1596− lookbehind: true,
1597− },
1598− punctuation: /[(){};:,]/,
1599− };
1600−
1601− Prism.languages.css["atrule"].inside.rest = Prism.languages.css;
1602−
1603− var markup = Prism.languages.markup;
1604− if (markup) {
1605− markup.tag.addInlined("style", "css");
1606− markup.tag.addAttribute("style", "css");
1607− }
1608−})(Prism);
1455+
1456+ var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1457+
1458+ Prism.languages.css = {
1459+ 'comment': /\/\*[\s\S]*?\*\//,
1460+ 'atrule': {
1461+ pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
1462+ inside: {
1463+ 'rule': /^@[\w-]+/,
1464+ 'selector-function-argument': {
1465+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1466+ lookbehind: true,
1467+ alias: 'selector'
1468+ },
1469+ 'keyword': {
1470+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1471+ lookbehind: true
1472+ }
1473+ // See rest below
1474+ }
1475+ },
1476+ 'url': {
1477+ // https://drafts.csswg.org/css-values-3/#urls
1478+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1479+ greedy: true,
1480+ inside: {
1481+ 'function': /^url/i,
1482+ 'punctuation': /^\(|\)$/,
1483+ 'string': {
1484+ pattern: RegExp('^' + string.source + '$'),
1485+ alias: 'url'
1486+ }
1487+ }
1488+ },
1489+ 'selector': {
1490+ pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
1491+ lookbehind: true
1492+ },
1493+ 'string': {
1494+ pattern: string,
1495+ greedy: true
1496+ },
1497+ 'property': {
1498+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1499+ lookbehind: true
1500+ },
1501+ 'important': /!important\b/i,
1502+ 'function': {
1503+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1504+ lookbehind: true
1505+ },
1506+ 'punctuation': /[(){};:,]/
1507+ };
1508+
1509+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
1510+
1511+ var markup = Prism.languages.markup;
1512+ if (markup) {
1513+ markup.tag.addInlined('style', 'css');
1514+ markup.tag.addAttribute('style', 'css');
1515+ }
1516+
1517+}(Prism));
16091518
16101519 Prism.languages.clike = {
1611− comment: [
1612− {
1613− pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1614− lookbehind: true,
1615− greedy: true,
1616− },
1617− {
1618− pattern: /(^|[^\\:])\/\/.*/,
1619− lookbehind: true,
1620− greedy: true,
1621− },
1622− ],
1623− string: {
1624− pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1625− greedy: true,
1626− },
1627− "class-name": {
1628− pattern:
1629− /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1630− lookbehind: true,
1631− inside: {
1632− punctuation: /[.\\]/,
1633− },
1634− },
1635− keyword:
1636− /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1637− boolean: /\b(?:false|true)\b/,
1638− function: /\b\w+(?=\()/,
1639− number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1640− operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1641− punctuation: /[{}[\];(),.:]/,
1520+ 'comment': [
1521+ {
1522+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1523+ lookbehind: true,
1524+ greedy: true
1525+ },
1526+ {
1527+ pattern: /(^|[^\\:])\/\/.*/,
1528+ lookbehind: true,
1529+ greedy: true
1530+ }
1531+ ],
1532+ 'string': {
1533+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1534+ greedy: true
1535+ },
1536+ 'class-name': {
1537+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1538+ lookbehind: true,
1539+ inside: {
1540+ 'punctuation': /[.\\]/
1541+ }
1542+ },
1543+ 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1544+ 'boolean': /\b(?:false|true)\b/,
1545+ 'function': /\b\w+(?=\()/,
1546+ 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1547+ 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1548+ 'punctuation': /[{}[\];(),.:]/
16421549 };
16431550
1644−Prism.languages.javascript = Prism.languages.extend("clike", {
1645− "class-name": [
1646− Prism.languages.clike["class-name"],
1647− {
1648− pattern:
1649− /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1650− lookbehind: true,
1651− },
1652− ],
1653− keyword: [
1654− {
1655− pattern: /((?:^|\})\s*)catch\b/,
1656− lookbehind: true,
1657− },
1658− {
1659− pattern:
1660− /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1661− lookbehind: true,
1662− },
1663− ],
1664− // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1665− function:
1666− /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1667− number: {
1668− pattern: RegExp(
1669− /(^|[^\w$])/.source +
1670− "(?:" +
1671− // constant
1672− (/NaN|Infinity/.source +
1673− "|" +
1674− // binary integer
1675− /0[bB][01]+(?:_[01]+)*n?/.source +
1676− "|" +
1677− // octal integer
1678− /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
1679− "|" +
1680− // hexadecimal integer
1681− /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
1682− "|" +
1683− // decimal bigint
1684− /\d+(?:_\d+)*n/.source +
1685− "|" +
1686− // decimal number (integer or float) but no bigint
1687− /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/
1688− .source) +
1689− ")" +
1690− /(?![\w$])/.source,
1691− ),
1692− lookbehind: true,
1693− },
1694− operator:
1695− /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
1551+Prism.languages.javascript = Prism.languages.extend('clike', {
1552+ 'class-name': [
1553+ Prism.languages.clike['class-name'],
1554+ {
1555+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1556+ lookbehind: true
1557+ }
1558+ ],
1559+ 'keyword': [
1560+ {
1561+ pattern: /((?:^|\})\s*)catch\b/,
1562+ lookbehind: true
1563+ },
1564+ {
1565+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1566+ lookbehind: true
1567+ },
1568+ ],
1569+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1570+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1571+ 'number': {
1572+ pattern: RegExp(
1573+ /(^|[^\w$])/.source +
1574+ '(?:' +
1575+ (
1576+ // constant
1577+ /NaN|Infinity/.source +
1578+ '|' +
1579+ // binary integer
1580+ /0[bB][01]+(?:_[01]+)*n?/.source +
1581+ '|' +
1582+ // octal integer
1583+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
1584+ '|' +
1585+ // hexadecimal integer
1586+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
1587+ '|' +
1588+ // decimal bigint
1589+ /\d+(?:_\d+)*n/.source +
1590+ '|' +
1591+ // decimal number (integer or float) but no bigint
1592+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
1593+ ) +
1594+ ')' +
1595+ /(?![\w$])/.source
1596+ ),
1597+ lookbehind: true
1598+ },
1599+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
16961600 });
16971601
1698−Prism.languages.javascript["class-name"][0].pattern =
1699− /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1700−
1701−Prism.languages.insertBefore("javascript", "keyword", {
1702− regex: {
1703− pattern: RegExp(
1704− // lookbehind
1705− // eslint-disable-next-line regexp/no-dupe-characters-character-class
1706− /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
1707− // Regex pattern:
1708− // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1709− // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1710− // with the only syntax, so we have to define 2 different regex patterns.
1711− /\//.source +
1712− "(?:" +
1713− /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/
1714− .source +
1715− "|" +
1716− // `v` flag syntax. This supports 3 levels of nested character classes.
1717− /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/
1718− .source +
1719− ")" +
1720− // lookahead
1721− /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/
1722− .source,
1723− ),
1724− lookbehind: true,
1725− greedy: true,
1726− inside: {
1727− "regex-source": {
1728− pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1729− lookbehind: true,
1730− alias: "language-regex",
1731− inside: Prism.languages.regex,
1732− },
1733− "regex-delimiter": /^\/|\/$/,
1734− "regex-flags": /^[a-z]+$/,
1735− },
1736− },
1737− // This must be declared before keyword because we use "function" inside the look-forward
1738− "function-variable": {
1739− pattern:
1740− /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
1741− alias: "function",
1742− },
1743− parameter: [
1744− {
1745− pattern:
1746− /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1747− lookbehind: true,
1748− inside: Prism.languages.javascript,
1749− },
1750− {
1751− pattern:
1752− /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1753− lookbehind: true,
1754− inside: Prism.languages.javascript,
1755− },
1756− {
1757− pattern:
1758− /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1759− lookbehind: true,
1760− inside: Prism.languages.javascript,
1761− },
1762− {
1763− pattern:
1764− /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
1765− lookbehind: true,
1766− inside: Prism.languages.javascript,
1767− },
1768− ],
1769− constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/,
1602+Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1603+
1604+Prism.languages.insertBefore('javascript', 'keyword', {
1605+ 'regex': {
1606+ pattern: RegExp(
1607+ // lookbehind
1608+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
1609+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
1610+ // Regex pattern:
1611+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1612+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1613+ // with the only syntax, so we have to define 2 different regex patterns.
1614+ /\//.source +
1615+ '(?:' +
1616+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
1617+ '|' +
1618+ // `v` flag syntax. This supports 3 levels of nested character classes.
1619+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
1620+ ')' +
1621+ // lookahead
1622+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
1623+ ),
1624+ lookbehind: true,
1625+ greedy: true,
1626+ inside: {
1627+ 'regex-source': {
1628+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1629+ lookbehind: true,
1630+ alias: 'language-regex',
1631+ inside: Prism.languages.regex
1632+ },
1633+ 'regex-delimiter': /^\/|\/$/,
1634+ 'regex-flags': /^[a-z]+$/,
1635+ }
1636+ },
1637+ // This must be declared before keyword because we use "function" inside the look-forward
1638+ 'function-variable': {
1639+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
1640+ alias: 'function'
1641+ },
1642+ 'parameter': [
1643+ {
1644+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1645+ lookbehind: true,
1646+ inside: Prism.languages.javascript
1647+ },
1648+ {
1649+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1650+ lookbehind: true,
1651+ inside: Prism.languages.javascript
1652+ },
1653+ {
1654+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1655+ lookbehind: true,
1656+ inside: Prism.languages.javascript
1657+ },
1658+ {
1659+ pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
1660+ lookbehind: true,
1661+ inside: Prism.languages.javascript
1662+ }
1663+ ],
1664+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
17701665 });
17711666
1772−Prism.languages.insertBefore("javascript", "string", {
1773− hashbang: {
1774− pattern: /^#!.*/,
1775− greedy: true,
1776− alias: "comment",
1777− },
1778− "template-string": {
1779− pattern:
1780− /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1781− greedy: true,
1782− inside: {
1783− "template-punctuation": {
1784− pattern: /^`|`$/,
1785− alias: "string",
1786− },
1787− interpolation: {
1788− pattern:
1789− /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1790− lookbehind: true,
1791− inside: {
1792− "interpolation-punctuation": {
1793− pattern: /^\$\{|\}$/,
1794− alias: "punctuation",
1795− },
1796− rest: Prism.languages.javascript,
1797− },
1798− },
1799− string: /[\s\S]+/,
1800− },
1801− },
1802− "string-property": {
1803− pattern:
1804− /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1805− lookbehind: true,
1806− greedy: true,
1807− alias: "property",
1808− },
1667+Prism.languages.insertBefore('javascript', 'string', {
1668+ 'hashbang': {
1669+ pattern: /^#!.*/,
1670+ greedy: true,
1671+ alias: 'comment'
1672+ },
1673+ 'template-string': {
1674+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1675+ greedy: true,
1676+ inside: {
1677+ 'template-punctuation': {
1678+ pattern: /^`|`$/,
1679+ alias: 'string'
1680+ },
1681+ 'interpolation': {
1682+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1683+ lookbehind: true,
1684+ inside: {
1685+ 'interpolation-punctuation': {
1686+ pattern: /^\$\{|\}$/,
1687+ alias: 'punctuation'
1688+ },
1689+ rest: Prism.languages.javascript
1690+ }
1691+ },
1692+ 'string': /[\s\S]+/
1693+ }
1694+ },
1695+ 'string-property': {
1696+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1697+ lookbehind: true,
1698+ greedy: true,
1699+ alias: 'property'
1700+ }
18091701 });
18101702
1811−Prism.languages.insertBefore("javascript", "operator", {
1812− "literal-property": {
1813− pattern:
1814− /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1815− lookbehind: true,
1816− alias: "property",
1817− },
1703+Prism.languages.insertBefore('javascript', 'operator', {
1704+ 'literal-property': {
1705+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1706+ lookbehind: true,
1707+ alias: 'property'
1708+ },
18181709 });
18191710
18201711 if (Prism.languages.markup) {
1821− Prism.languages.markup.tag.addInlined("script", "javascript");
1822−
1823− // add attribute support for all DOM events.
1824− // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
1825− Prism.languages.markup.tag.addAttribute(
1826− /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/
1827− .source,
1828− "javascript",
1829− );
1712+ Prism.languages.markup.tag.addInlined('script', 'javascript');
1713+
1714+ // add attribute support for all DOM events.
1715+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
1716+ Prism.languages.markup.tag.addAttribute(
1717+ /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
1718+ 'javascript'
1719+ );
18301720 }
18311721
18321722 Prism.languages.js = Prism.languages.javascript;
18331723
18341724 (function (Prism) {
1835− // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
1836− // + LC_ALL, RANDOM, REPLY, SECONDS.
1837− // + make sure PS1..4 are here as they are not always set,
1838− // - some useless things.
1839− var envVars =
1840− "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b";
1841−
1842− var commandAfterHeredoc = {
1843− pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
1844− lookbehind: true,
1845− alias: "punctuation", // this looks reasonably well in all themes
1846− inside: null, // see below
1847− };
1848−
1849− var insideString = {
1850− bash: commandAfterHeredoc,
1851− environment: {
1852− pattern: RegExp("\\$" + envVars),
1853− alias: "constant",
1854− },
1855− variable: [
1856− // [0]: Arithmetic Environment
1857− {
1858− pattern: /\$?\(\([\s\S]+?\)\)/,
1859− greedy: true,
1860− inside: {
1861− // If there is a $ sign at the beginning highlight $(( and )) as variable
1862− variable: [
1863− {
1864− pattern: /(^\$\(\([\s\S]+)\)\)/,
1865− lookbehind: true,
1866− },
1867− /^\$\(\(/,
1868− ],
1869− number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
1870− // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
1871− operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
1872− // If there is no $ sign at the beginning highlight (( and )) as punctuation
1873− punctuation: /\(\(?|\)\)?|,|;/,
1874− },
1875− },
1876− // [1]: Command Substitution
1877− {
1878− pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
1879− greedy: true,
1880− inside: {
1881− variable: /^\$\(|^`|\)$|`$/,
1882− },
1883− },
1884− // [2]: Brace expansion
1885− {
1886− pattern: /\$\{[^}]+\}/,
1887− greedy: true,
1888− inside: {
1889− operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
1890− punctuation: /[\[\]]/,
1891− environment: {
1892− pattern: RegExp("(\\{)" + envVars),
1893− lookbehind: true,
1894− alias: "constant",
1895− },
1896− },
1897− },
1898− /\$(?:\w+|[#?*!@$])/,
1899− ],
1900− // Escape sequences from echo and printf's manuals, and escaped quotes.
1901− entity:
1902− /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/,
1903− };
1904−
1905− Prism.languages.bash = {
1906− shebang: {
1907− pattern: /^#!\s*\/.*/,
1908− alias: "important",
1909− },
1910− comment: {
1911− pattern: /(^|[^"{\\$])#.*/,
1912− lookbehind: true,
1913− },
1914− "function-name": [
1915− // a) function foo {
1916− // b) foo() {
1917− // c) function foo() {
1918− // but not “foo {”
1919− {
1920− // a) and c)
1921− pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
1922− lookbehind: true,
1923− alias: "function",
1924− },
1925− {
1926− // b)
1927− pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
1928− alias: "function",
1929− },
1930− ],
1931− // Highlight variable names as variables in for and select beginnings.
1932− "for-or-select": {
1933− pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
1934− alias: "variable",
1935− lookbehind: true,
1936− },
1937− // Highlight variable names as variables in the left-hand part
1938− // of assignments (“=” and “+=”).
1939− "assign-left": {
1940− pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
1941− inside: {
1942− environment: {
1943− pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
1944− lookbehind: true,
1945− alias: "constant",
1946− },
1947− },
1948− alias: "variable",
1949− lookbehind: true,
1950− },
1951− // Highlight parameter names as variables
1952− parameter: {
1953− pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
1954− alias: "variable",
1955− lookbehind: true,
1956− },
1957− string: [
1958− // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
1959− {
1960− pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
1961− lookbehind: true,
1962− greedy: true,
1963− inside: insideString,
1964− },
1965− // Here-document with quotes around the tag
1966− // → No expansion (so no “inside”).
1967− {
1968− pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
1969− lookbehind: true,
1970− greedy: true,
1971− inside: {
1972− bash: commandAfterHeredoc,
1973− },
1974− },
1975− // “Normal” string
1976− {
1977− // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
1978− pattern:
1979− /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
1980− lookbehind: true,
1981− greedy: true,
1982− inside: insideString,
1983− },
1984− {
1985− // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
1986− pattern: /(^|[^$\\])'[^']*'/,
1987− lookbehind: true,
1988− greedy: true,
1989− },
1990− {
1991− // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
1992− pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
1993− greedy: true,
1994− inside: {
1995− entity: insideString.entity,
1996− },
1997− },
1998− ],
1999− environment: {
2000− pattern: RegExp("\\$?" + envVars),
2001− alias: "constant",
2002− },
2003− variable: insideString.variable,
2004− function: {
2005− pattern:
2006− /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
2007− lookbehind: true,
2008− },
2009− keyword: {
2010− pattern:
2011− /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
2012− lookbehind: true,
2013− },
2014− // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
2015− builtin: {
2016− pattern:
2017− /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
2018− lookbehind: true,
2019− // Alias added to make those easier to distinguish from strings.
2020− alias: "class-name",
2021− },
2022− boolean: {
2023− pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
2024− lookbehind: true,
2025− },
2026− "file-descriptor": {
2027− pattern: /\B&\d\b/,
2028− alias: "important",
2029− },
2030− operator: {
2031− // Lots of redirections here, but not just that.
2032− pattern:
2033− /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
2034− inside: {
2035− "file-descriptor": {
2036− pattern: /^\d/,
2037− alias: "important",
2038− },
2039− },
2040− },
2041− punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
2042− number: {
2043− pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
2044− lookbehind: true,
2045− },
2046− };
2047−
2048− commandAfterHeredoc.inside = Prism.languages.bash;
2049−
2050− /* Patterns in command substitution. */
2051− var toBeCopied = [
2052− "comment",
2053− "function-name",
2054− "for-or-select",
2055− "assign-left",
2056− "parameter",
2057− "string",
2058− "environment",
2059− "function",
2060− "keyword",
2061− "builtin",
2062− "boolean",
2063− "file-descriptor",
2064− "operator",
2065− "punctuation",
2066− "number",
2067− ];
2068− var inside = insideString.variable[1].inside;
2069− for (var i = 0; i < toBeCopied.length; i++) {
2070− inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
2071− }
2072−
2073− Prism.languages.sh = Prism.languages.bash;
2074− Prism.languages.shell = Prism.languages.bash;
2075−})(Prism);
2076−
2077−Prism.languages.c = Prism.languages.extend("clike", {
2078− comment: {
2079− pattern:
2080− /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
2081− greedy: true,
2082− },
2083− string: {
2084− // https://en.cppreference.com/w/c/language/string_literal
2085− pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
2086− greedy: true,
2087− },
2088− "class-name": {
2089− pattern:
2090− /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
2091− lookbehind: true,
2092− },
2093− keyword:
2094− /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
2095− function: /\b[a-z_]\w*(?=\s*\()/i,
2096− number:
2097− /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
2098− operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
1725+ // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
1726+ // + LC_ALL, RANDOM, REPLY, SECONDS.
1727+ // + make sure PS1..4 are here as they are not always set,
1728+ // - some useless things.
1729+ var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
1730+
1731+ var commandAfterHeredoc = {
1732+ pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
1733+ lookbehind: true,
1734+ alias: 'punctuation', // this looks reasonably well in all themes
1735+ inside: null // see below
1736+ };
1737+
1738+ var insideString = {
1739+ 'bash': commandAfterHeredoc,
1740+ 'environment': {
1741+ pattern: RegExp('\\$' + envVars),
1742+ alias: 'constant'
1743+ },
1744+ 'variable': [
1745+ // [0]: Arithmetic Environment
1746+ {
1747+ pattern: /\$?\(\([\s\S]+?\)\)/,
1748+ greedy: true,
1749+ inside: {
1750+ // If there is a $ sign at the beginning highlight $(( and )) as variable
1751+ 'variable': [
1752+ {
1753+ pattern: /(^\$\(\([\s\S]+)\)\)/,
1754+ lookbehind: true
1755+ },
1756+ /^\$\(\(/
1757+ ],
1758+ 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
1759+ // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
1760+ 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
1761+ // If there is no $ sign at the beginning highlight (( and )) as punctuation
1762+ 'punctuation': /\(\(?|\)\)?|,|;/
1763+ }
1764+ },
1765+ // [1]: Command Substitution
1766+ {
1767+ pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
1768+ greedy: true,
1769+ inside: {
1770+ 'variable': /^\$\(|^`|\)$|`$/
1771+ }
1772+ },
1773+ // [2]: Brace expansion
1774+ {
1775+ pattern: /\$\{[^}]+\}/,
1776+ greedy: true,
1777+ inside: {
1778+ 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
1779+ 'punctuation': /[\[\]]/,
1780+ 'environment': {
1781+ pattern: RegExp('(\\{)' + envVars),
1782+ lookbehind: true,
1783+ alias: 'constant'
1784+ }
1785+ }
1786+ },
1787+ /\$(?:\w+|[#?*!@$])/
1788+ ],
1789+ // Escape sequences from echo and printf's manuals, and escaped quotes.
1790+ 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
1791+ };
1792+
1793+ Prism.languages.bash = {
1794+ 'shebang': {
1795+ pattern: /^#!\s*\/.*/,
1796+ alias: 'important'
1797+ },
1798+ 'comment': {
1799+ pattern: /(^|[^"{\\$])#.*/,
1800+ lookbehind: true
1801+ },
1802+ 'function-name': [
1803+ // a) function foo {
1804+ // b) foo() {
1805+ // c) function foo() {
1806+ // but not “foo {”
1807+ {
1808+ // a) and c)
1809+ pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
1810+ lookbehind: true,
1811+ alias: 'function'
1812+ },
1813+ {
1814+ // b)
1815+ pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
1816+ alias: 'function'
1817+ }
1818+ ],
1819+ // Highlight variable names as variables in for and select beginnings.
1820+ 'for-or-select': {
1821+ pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
1822+ alias: 'variable',
1823+ lookbehind: true
1824+ },
1825+ // Highlight variable names as variables in the left-hand part
1826+ // of assignments (“=” and “+=”).
1827+ 'assign-left': {
1828+ pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
1829+ inside: {
1830+ 'environment': {
1831+ pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
1832+ lookbehind: true,
1833+ alias: 'constant'
1834+ }
1835+ },
1836+ alias: 'variable',
1837+ lookbehind: true
1838+ },
1839+ // Highlight parameter names as variables
1840+ 'parameter': {
1841+ pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
1842+ alias: 'variable',
1843+ lookbehind: true
1844+ },
1845+ 'string': [
1846+ // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
1847+ {
1848+ pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
1849+ lookbehind: true,
1850+ greedy: true,
1851+ inside: insideString
1852+ },
1853+ // Here-document with quotes around the tag
1854+ // → No expansion (so no “inside”).
1855+ {
1856+ pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
1857+ lookbehind: true,
1858+ greedy: true,
1859+ inside: {
1860+ 'bash': commandAfterHeredoc
1861+ }
1862+ },
1863+ // “Normal” string
1864+ {
1865+ // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
1866+ pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
1867+ lookbehind: true,
1868+ greedy: true,
1869+ inside: insideString
1870+ },
1871+ {
1872+ // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
1873+ pattern: /(^|[^$\\])'[^']*'/,
1874+ lookbehind: true,
1875+ greedy: true
1876+ },
1877+ {
1878+ // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
1879+ pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
1880+ greedy: true,
1881+ inside: {
1882+ 'entity': insideString.entity
1883+ }
1884+ }
1885+ ],
1886+ 'environment': {
1887+ pattern: RegExp('\\$?' + envVars),
1888+ alias: 'constant'
1889+ },
1890+ 'variable': insideString.variable,
1891+ 'function': {
1892+ pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1893+ lookbehind: true
1894+ },
1895+ 'keyword': {
1896+ pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
1897+ lookbehind: true
1898+ },
1899+ // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
1900+ 'builtin': {
1901+ pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
1902+ lookbehind: true,
1903+ // Alias added to make those easier to distinguish from strings.
1904+ alias: 'class-name'
1905+ },
1906+ 'boolean': {
1907+ pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
1908+ lookbehind: true
1909+ },
1910+ 'file-descriptor': {
1911+ pattern: /\B&\d\b/,
1912+ alias: 'important'
1913+ },
1914+ 'operator': {
1915+ // Lots of redirections here, but not just that.
1916+ pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
1917+ inside: {
1918+ 'file-descriptor': {
1919+ pattern: /^\d/,
1920+ alias: 'important'
1921+ }
1922+ }
1923+ },
1924+ 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
1925+ 'number': {
1926+ pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
1927+ lookbehind: true
1928+ }
1929+ };
1930+
1931+ commandAfterHeredoc.inside = Prism.languages.bash;
1932+
1933+ /* Patterns in command substitution. */
1934+ var toBeCopied = [
1935+ 'comment',
1936+ 'function-name',
1937+ 'for-or-select',
1938+ 'assign-left',
1939+ 'parameter',
1940+ 'string',
1941+ 'environment',
1942+ 'function',
1943+ 'keyword',
1944+ 'builtin',
1945+ 'boolean',
1946+ 'file-descriptor',
1947+ 'operator',
1948+ 'punctuation',
1949+ 'number'
1950+ ];
1951+ var inside = insideString.variable[1].inside;
1952+ for (var i = 0; i < toBeCopied.length; i++) {
1953+ inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
1954+ }
1955+
1956+ Prism.languages.sh = Prism.languages.bash;
1957+ Prism.languages.shell = Prism.languages.bash;
1958+}(Prism));
1959+
1960+Prism.languages.c = Prism.languages.extend('clike', {
1961+ 'comment': {
1962+ pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
1963+ greedy: true
1964+ },
1965+ 'string': {
1966+ // https://en.cppreference.com/w/c/language/string_literal
1967+ pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
1968+ greedy: true
1969+ },
1970+ 'class-name': {
1971+ pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
1972+ lookbehind: true
1973+ },
1974+ 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
1975+ 'function': /\b[a-z_]\w*(?=\s*\()/i,
1976+ 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
1977+ 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
20991978 });
21001979
2101−Prism.languages.insertBefore("c", "string", {
2102− char: {
2103− // https://en.cppreference.com/w/c/language/character_constant
2104− pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
2105− greedy: true,
2106− },
1980+Prism.languages.insertBefore('c', 'string', {
1981+ 'char': {
1982+ // https://en.cppreference.com/w/c/language/character_constant
1983+ pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
1984+ greedy: true
1985+ }
21071986 });
21081987
2109−Prism.languages.insertBefore("c", "string", {
2110− macro: {
2111− // allow for multiline macro definitions
2112− // spaces after the # character compile fine with gcc
2113− pattern:
2114− /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
2115− lookbehind: true,
2116− greedy: true,
2117− alias: "property",
2118− inside: {
2119− string: [
2120− {
2121− // highlight the path of the include statement as a string
2122− pattern: /^(#\s*include\s*)<[^>]+>/,
2123− lookbehind: true,
2124− },
2125− Prism.languages.c["string"],
2126− ],
2127− char: Prism.languages.c["char"],
2128− comment: Prism.languages.c["comment"],
2129− "macro-name": [
2130− {
2131− pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
2132− lookbehind: true,
2133− },
2134− {
2135− pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
2136− lookbehind: true,
2137− alias: "function",
2138− },
2139− ],
2140− // highlight macro directives as keywords
2141− directive: {
2142− pattern: /^(#\s*)[a-z]+/,
2143− lookbehind: true,
2144− alias: "keyword",
2145− },
2146− "directive-hash": /^#/,
2147− punctuation: /##|\\(?=[\r\n])/,
2148− expression: {
2149− pattern: /\S[\s\S]*/,
2150− inside: Prism.languages.c,
2151− },
2152− },
2153− },
1988+Prism.languages.insertBefore('c', 'string', {
1989+ 'macro': {
1990+ // allow for multiline macro definitions
1991+ // spaces after the # character compile fine with gcc
1992+ pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
1993+ lookbehind: true,
1994+ greedy: true,
1995+ alias: 'property',
1996+ inside: {
1997+ 'string': [
1998+ {
1999+ // highlight the path of the include statement as a string
2000+ pattern: /^(#\s*include\s*)<[^>]+>/,
2001+ lookbehind: true
2002+ },
2003+ Prism.languages.c['string']
2004+ ],
2005+ 'char': Prism.languages.c['char'],
2006+ 'comment': Prism.languages.c['comment'],
2007+ 'macro-name': [
2008+ {
2009+ pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
2010+ lookbehind: true
2011+ },
2012+ {
2013+ pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
2014+ lookbehind: true,
2015+ alias: 'function'
2016+ }
2017+ ],
2018+ // highlight macro directives as keywords
2019+ 'directive': {
2020+ pattern: /^(#\s*)[a-z]+/,
2021+ lookbehind: true,
2022+ alias: 'keyword'
2023+ },
2024+ 'directive-hash': /^#/,
2025+ 'punctuation': /##|\\(?=[\r\n])/,
2026+ 'expression': {
2027+ pattern: /\S[\s\S]*/,
2028+ inside: Prism.languages.c
2029+ }
2030+ }
2031+ }
21542032 });
21552033
2156−Prism.languages.insertBefore("c", "function", {
2157− // highlight predefined macros as constants
2158− constant:
2159− /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/,
2034+Prism.languages.insertBefore('c', 'function', {
2035+ // highlight predefined macros as constants
2036+ 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
21602037 });
21612038
2162−delete Prism.languages.c["boolean"];
2039+delete Prism.languages.c['boolean'];
21632040
21642041 (function (Prism) {
2165− var keyword =
2166− /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
2167− var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(
2168− /<keyword>/g,
2169− function () {
2170− return keyword.source;
2171− },
2172− );
2173−
2174− Prism.languages.cpp = Prism.languages.extend("c", {
2175− "class-name": [
2176− {
2177− pattern: RegExp(
2178− /(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(
2179− /<keyword>/g,
2180− function () {
2181− return keyword.source;
2182− },
2183− ),
2184− ),
2185− lookbehind: true,
2186− },
2187− // This is intended to capture the class name of method implementations like:
2188− // void foo::bar() const {}
2189− // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
2190− // it starts with an uppercase letter. This approximation should give decent results.
2191− /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
2192− // This will capture the class name before destructors like:
2193− // Foo::~Foo() {}
2194− /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
2195− // This also intends to capture the class name of method implementations but here the class has template
2196− // parameters, so it can't be a namespace (until C++ adds generic namespaces).
2197− /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/,
2198− ],
2199− keyword: keyword,
2200− number: {
2201− pattern:
2202− /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
2203− greedy: true,
2204− },
2205− operator:
2206− />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
2207− boolean: /\b(?:false|true)\b/,
2208− });
2209−
2210− Prism.languages.insertBefore("cpp", "string", {
2211− module: {
2212− // https://en.cppreference.com/w/cpp/language/modules
2213− pattern: RegExp(
2214− /(\b(?:import|module)\s+)/.source +
2215− "(?:" +
2216− // header-name
2217− /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source +
2218− "|" +
2219− // module name or partition or both
2220− /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(
2221− /<mod-name>/g,
2222− function () {
2223− return modName;
2224− },
2225− ) +
2226− ")",
2227− ),
2228− lookbehind: true,
2229− greedy: true,
2230− inside: {
2231− string: /^[<"][\s\S]+/,
2232− operator: /:/,
2233− punctuation: /\./,
2234− },
2235− },
2236− "raw-string": {
2237− pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
2238− alias: "string",
2239− greedy: true,
2240− },
2241− });
2242−
2243− Prism.languages.insertBefore("cpp", "keyword", {
2244− "generic-function": {
2245− pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
2246− inside: {
2247− function: /^\w+/,
2248− generic: {
2249− pattern: /<[\s\S]+/,
2250− alias: "class-name",
2251− inside: Prism.languages.cpp,
2252− },
2253− },
2254− },
2255− });
2256−
2257− Prism.languages.insertBefore("cpp", "operator", {
2258− "double-colon": {
2259− pattern: /::/,
2260− alias: "punctuation",
2261− },
2262− });
2263−
2264− Prism.languages.insertBefore("cpp", "class-name", {
2265− // the base clause is an optional list of parent classes
2266− // https://en.cppreference.com/w/cpp/language/class
2267− "base-clause": {
2268− pattern:
2269− /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
2270− lookbehind: true,
2271− greedy: true,
2272− inside: Prism.languages.extend("cpp", {}),
2273− },
2274− });
2275−
2276− Prism.languages.insertBefore(
2277− "inside",
2278− "double-colon",
2279− {
2280− // All untokenized words that are not namespaces should be class names
2281− "class-name": /\b[a-z_]\w*\b(?!\s*::)/i,
2282− },
2283− Prism.languages.cpp["base-clause"],
2284− );
2285−})(Prism);
2042+
2043+ var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
2044+ var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; });
2045+
2046+ Prism.languages.cpp = Prism.languages.extend('c', {
2047+ 'class-name': [
2048+ {
2049+ pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
2050+ .replace(/<keyword>/g, function () { return keyword.source; })),
2051+ lookbehind: true
2052+ },
2053+ // This is intended to capture the class name of method implementations like:
2054+ // void foo::bar() const {}
2055+ // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
2056+ // it starts with an uppercase letter. This approximation should give decent results.
2057+ /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
2058+ // This will capture the class name before destructors like:
2059+ // Foo::~Foo() {}
2060+ /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
2061+ // This also intends to capture the class name of method implementations but here the class has template
2062+ // parameters, so it can't be a namespace (until C++ adds generic namespaces).
2063+ /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
2064+ ],
2065+ 'keyword': keyword,
2066+ 'number': {
2067+ pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
2068+ greedy: true
2069+ },
2070+ 'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
2071+ 'boolean': /\b(?:false|true)\b/
2072+ });
2073+
2074+ Prism.languages.insertBefore('cpp', 'string', {
2075+ 'module': {
2076+ // https://en.cppreference.com/w/cpp/language/modules
2077+ pattern: RegExp(
2078+ /(\b(?:import|module)\s+)/.source +
2079+ '(?:' +
2080+ // header-name
2081+ /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source +
2082+ '|' +
2083+ // module name or partition or both
2084+ /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () { return modName; }) +
2085+ ')'
2086+ ),
2087+ lookbehind: true,
2088+ greedy: true,
2089+ inside: {
2090+ 'string': /^[<"][\s\S]+/,
2091+ 'operator': /:/,
2092+ 'punctuation': /\./
2093+ }
2094+ },
2095+ 'raw-string': {
2096+ pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
2097+ alias: 'string',
2098+ greedy: true
2099+ }
2100+ });
2101+
2102+ Prism.languages.insertBefore('cpp', 'keyword', {
2103+ 'generic-function': {
2104+ pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
2105+ inside: {
2106+ 'function': /^\w+/,
2107+ 'generic': {
2108+ pattern: /<[\s\S]+/,
2109+ alias: 'class-name',
2110+ inside: Prism.languages.cpp
2111+ }
2112+ }
2113+ }
2114+ });
2115+
2116+ Prism.languages.insertBefore('cpp', 'operator', {
2117+ 'double-colon': {
2118+ pattern: /::/,
2119+ alias: 'punctuation'
2120+ }
2121+ });
2122+
2123+ Prism.languages.insertBefore('cpp', 'class-name', {
2124+ // the base clause is an optional list of parent classes
2125+ // https://en.cppreference.com/w/cpp/language/class
2126+ 'base-clause': {
2127+ pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
2128+ lookbehind: true,
2129+ greedy: true,
2130+ inside: Prism.languages.extend('cpp', {})
2131+ }
2132+ });
2133+
2134+ Prism.languages.insertBefore('inside', 'double-colon', {
2135+ // All untokenized words that are not namespaces should be class names
2136+ 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
2137+ }, Prism.languages.cpp['base-clause']);
2138+
2139+}(Prism));
22862140
22872141 Prism.languages.cmake = {
2288− comment: /#.*/,
2289− string: {
2290− pattern: /"(?:[^\\"]|\\.)*"/,
2291− greedy: true,
2292− inside: {
2293− interpolation: {
2294− pattern: /\$\{(?:[^{}$]|\$\{[^{}$]*\})*\}/,
2295− inside: {
2296− punctuation: /\$\{|\}/,
2297− variable: /\w+/,
2298− },
2299− },
2300− },
2301− },
2302− variable:
2303− /\b(?:CMAKE_\w+|\w+_(?:(?:BINARY|SOURCE)_DIR|DESCRIPTION|HOMEPAGE_URL|ROOT|VERSION(?:_MAJOR|_MINOR|_PATCH|_TWEAK)?)|(?:ANDROID|APPLE|BORLAND|BUILD_SHARED_LIBS|CACHE|CPACK_(?:ABSOLUTE_DESTINATION_FILES|COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY|ERROR_ON_ABSOLUTE_INSTALL_DESTINATION|INCLUDE_TOPLEVEL_DIRECTORY|INSTALL_DEFAULT_DIRECTORY_PERMISSIONS|INSTALL_SCRIPT|PACKAGING_INSTALL_PREFIX|SET_DESTDIR|WARN_ON_ABSOLUTE_INSTALL_DESTINATION)|CTEST_(?:BINARY_DIRECTORY|BUILD_COMMAND|BUILD_NAME|BZR_COMMAND|BZR_UPDATE_OPTIONS|CHANGE_ID|CHECKOUT_COMMAND|CONFIGURATION_TYPE|CONFIGURE_COMMAND|COVERAGE_COMMAND|COVERAGE_EXTRA_FLAGS|CURL_OPTIONS|CUSTOM_(?:COVERAGE_EXCLUDE|ERROR_EXCEPTION|ERROR_MATCH|ERROR_POST_CONTEXT|ERROR_PRE_CONTEXT|MAXIMUM_FAILED_TEST_OUTPUT_SIZE|MAXIMUM_NUMBER_OF_(?:ERRORS|WARNINGS)|MAXIMUM_PASSED_TEST_OUTPUT_SIZE|MEMCHECK_IGNORE|POST_MEMCHECK|POST_TEST|PRE_MEMCHECK|PRE_TEST|TESTS_IGNORE|WARNING_EXCEPTION|WARNING_MATCH)|CVS_CHECKOUT|CVS_COMMAND|CVS_UPDATE_OPTIONS|DROP_LOCATION|DROP_METHOD|DROP_SITE|DROP_SITE_CDASH|DROP_SITE_PASSWORD|DROP_SITE_USER|EXTRA_COVERAGE_GLOB|GIT_COMMAND|GIT_INIT_SUBMODULES|GIT_UPDATE_CUSTOM|GIT_UPDATE_OPTIONS|HG_COMMAND|HG_UPDATE_OPTIONS|LABELS_FOR_SUBPROJECTS|MEMORYCHECK_(?:COMMAND|COMMAND_OPTIONS|SANITIZER_OPTIONS|SUPPRESSIONS_FILE|TYPE)|NIGHTLY_START_TIME|P4_CLIENT|P4_COMMAND|P4_OPTIONS|P4_UPDATE_OPTIONS|RUN_CURRENT_SCRIPT|SCP_COMMAND|SITE|SOURCE_DIRECTORY|SUBMIT_URL|SVN_COMMAND|SVN_OPTIONS|SVN_UPDATE_OPTIONS|TEST_LOAD|TEST_TIMEOUT|TRIGGER_SITE|UPDATE_COMMAND|UPDATE_OPTIONS|UPDATE_VERSION_ONLY|USE_LAUNCHERS)|CYGWIN|ENV|EXECUTABLE_OUTPUT_PATH|GHS-MULTI|IOS|LIBRARY_OUTPUT_PATH|MINGW|MSVC(?:10|11|12|14|60|70|71|80|90|_IDE|_TOOLSET_VERSION|_VERSION)?|MSYS|PROJECT_NAME|UNIX|WIN32|WINCE|WINDOWS_PHONE|WINDOWS_STORE|XCODE))\b/,
2304− property:
2305− /\b(?:cxx_\w+|(?:ARCHIVE_OUTPUT_(?:DIRECTORY|NAME)|COMPILE_DEFINITIONS|COMPILE_PDB_NAME|COMPILE_PDB_OUTPUT_DIRECTORY|EXCLUDE_FROM_DEFAULT_BUILD|IMPORTED_(?:IMPLIB|LIBNAME|LINK_DEPENDENT_LIBRARIES|LINK_INTERFACE_LANGUAGES|LINK_INTERFACE_LIBRARIES|LINK_INTERFACE_MULTIPLICITY|LOCATION|NO_SONAME|OBJECTS|SONAME)|INTERPROCEDURAL_OPTIMIZATION|LIBRARY_OUTPUT_DIRECTORY|LIBRARY_OUTPUT_NAME|LINK_FLAGS|LINK_INTERFACE_LIBRARIES|LINK_INTERFACE_MULTIPLICITY|LOCATION|MAP_IMPORTED_CONFIG|OSX_ARCHITECTURES|OUTPUT_NAME|PDB_NAME|PDB_OUTPUT_DIRECTORY|RUNTIME_OUTPUT_DIRECTORY|RUNTIME_OUTPUT_NAME|STATIC_LIBRARY_FLAGS|VS_CSHARP|VS_DOTNET_REFERENCEPROP|VS_DOTNET_REFERENCE|VS_GLOBAL_SECTION_POST|VS_GLOBAL_SECTION_PRE|VS_GLOBAL|XCODE_ATTRIBUTE)_\w+|\w+_(?:CLANG_TIDY|COMPILER_LAUNCHER|CPPCHECK|CPPLINT|INCLUDE_WHAT_YOU_USE|OUTPUT_NAME|POSTFIX|VISIBILITY_PRESET)|ABSTRACT|ADDITIONAL_MAKE_CLEAN_FILES|ADVANCED|ALIASED_TARGET|ALLOW_DUPLICATE_CUSTOM_TARGETS|ANDROID_(?:ANT_ADDITIONAL_OPTIONS|API|API_MIN|ARCH|ASSETS_DIRECTORIES|GUI|JAR_DEPENDENCIES|NATIVE_LIB_DEPENDENCIES|NATIVE_LIB_DIRECTORIES|PROCESS_MAX|PROGUARD|PROGUARD_CONFIG_PATH|SECURE_PROPS_PATH|SKIP_ANT_STEP|STL_TYPE)|ARCHIVE_OUTPUT_DIRECTORY|ATTACHED_FILES|ATTACHED_FILES_ON_FAIL|AUTOGEN_(?:BUILD_DIR|ORIGIN_DEPENDS|PARALLEL|SOURCE_GROUP|TARGETS_FOLDER|TARGET_DEPENDS)|AUTOMOC|AUTOMOC_(?:COMPILER_PREDEFINES|DEPEND_FILTERS|EXECUTABLE|MACRO_NAMES|MOC_OPTIONS|SOURCE_GROUP|TARGETS_FOLDER)|AUTORCC|AUTORCC_EXECUTABLE|AUTORCC_OPTIONS|AUTORCC_SOURCE_GROUP|AUTOUIC|AUTOUIC_EXECUTABLE|AUTOUIC_OPTIONS|AUTOUIC_SEARCH_PATHS|BINARY_DIR|BUILDSYSTEM_TARGETS|BUILD_RPATH|BUILD_RPATH_USE_ORIGIN|BUILD_WITH_INSTALL_NAME_DIR|BUILD_WITH_INSTALL_RPATH|BUNDLE|BUNDLE_EXTENSION|CACHE_VARIABLES|CLEAN_NO_CUSTOM|COMMON_LANGUAGE_RUNTIME|COMPATIBLE_INTERFACE_(?:BOOL|NUMBER_MAX|NUMBER_MIN|STRING)|COMPILE_(?:DEFINITIONS|FEATURES|FLAGS|OPTIONS|PDB_NAME|PDB_OUTPUT_DIRECTORY)|COST|CPACK_DESKTOP_SHORTCUTS|CPACK_NEVER_OVERWRITE|CPACK_PERMANENT|CPACK_STARTUP_SHORTCUTS|CPACK_START_MENU_SHORTCUTS|CPACK_WIX_ACL|CROSSCOMPILING_EMULATOR|CUDA_EXTENSIONS|CUDA_PTX_COMPILATION|CUDA_RESOLVE_DEVICE_SYMBOLS|CUDA_SEPARABLE_COMPILATION|CUDA_STANDARD|CUDA_STANDARD_REQUIRED|CXX_EXTENSIONS|CXX_STANDARD|CXX_STANDARD_REQUIRED|C_EXTENSIONS|C_STANDARD|C_STANDARD_REQUIRED|DEBUG_CONFIGURATIONS|DEFINE_SYMBOL|DEFINITIONS|DEPENDS|DEPLOYMENT_ADDITIONAL_FILES|DEPLOYMENT_REMOTE_DIRECTORY|DISABLED|DISABLED_FEATURES|ECLIPSE_EXTRA_CPROJECT_CONTENTS|ECLIPSE_EXTRA_NATURES|ENABLED_FEATURES|ENABLED_LANGUAGES|ENABLE_EXPORTS|ENVIRONMENT|EXCLUDE_FROM_ALL|EXCLUDE_FROM_DEFAULT_BUILD|EXPORT_NAME|EXPORT_PROPERTIES|EXTERNAL_OBJECT|EchoString|FAIL_REGULAR_EXPRESSION|FIND_LIBRARY_USE_LIB32_PATHS|FIND_LIBRARY_USE_LIB64_PATHS|FIND_LIBRARY_USE_LIBX32_PATHS|FIND_LIBRARY_USE_OPENBSD_VERSIONING|FIXTURES_CLEANUP|FIXTURES_REQUIRED|FIXTURES_SETUP|FOLDER|FRAMEWORK|Fortran_FORMAT|Fortran_MODULE_DIRECTORY|GENERATED|GENERATOR_FILE_NAME|GENERATOR_IS_MULTI_CONFIG|GHS_INTEGRITY_APP|GHS_NO_SOURCE_GROUP_FILE|GLOBAL_DEPENDS_DEBUG_MODE|GLOBAL_DEPENDS_NO_CYCLES|GNUtoMS|HAS_CXX|HEADER_FILE_ONLY|HELPSTRING|IMPLICIT_DEPENDS_INCLUDE_TRANSFORM|IMPORTED|IMPORTED_(?:COMMON_LANGUAGE_RUNTIME|CONFIGURATIONS|GLOBAL|IMPLIB|LIBNAME|LINK_DEPENDENT_LIBRARIES|LINK_INTERFACE_(?:LANGUAGES|LIBRARIES|MULTIPLICITY)|LOCATION|NO_SONAME|OBJECTS|SONAME)|IMPORT_PREFIX|IMPORT_SUFFIX|INCLUDE_DIRECTORIES|INCLUDE_REGULAR_EXPRESSION|INSTALL_NAME_DIR|INSTALL_RPATH|INSTALL_RPATH_USE_LINK_PATH|INTERFACE_(?:AUTOUIC_OPTIONS|COMPILE_DEFINITIONS|COMPILE_FEATURES|COMPILE_OPTIONS|INCLUDE_DIRECTORIES|LINK_DEPENDS|LINK_DIRECTORIES|LINK_LIBRARIES|LINK_OPTIONS|POSITION_INDEPENDENT_CODE|SOURCES|SYSTEM_INCLUDE_DIRECTORIES)|INTERPROCEDURAL_OPTIMIZATION|IN_TRY_COMPILE|IOS_INSTALL_COMBINED|JOB_POOLS|JOB_POOL_COMPILE|JOB_POOL_LINK|KEEP_EXTENSION|LABELS|LANGUAGE|LIBRARY_OUTPUT_DIRECTORY|LINKER_LANGUAGE|LINK_(?:DEPENDS|DEPENDS_NO_SHARED|DIRECTORIES|FLAGS|INTERFACE_LIBRARIES|INTERFACE_MULTIPLICITY|LIBRARIES|OPTIONS|SEARCH_END_STATIC|SEARCH_START_STATIC|WHAT_YOU_USE)|LISTFILE_STACK|LOCATION|MACOSX_BUNDLE|MACOSX_BUNDLE_INFO_PLIST|MACOSX_FRAMEWORK_INFO_PLIST|MACOSX_PACKAGE_LOCATION|MACOSX_RPATH|MACROS|MANUALLY_ADDED_DEPENDENCIES|MEASUREMENT|MODIFIED|NAME|NO_SONAME|NO_SYSTEM_FROM_IMPORTED|OBJECT_DEPENDS|OBJECT_OUTPUTS|OSX_ARCHITECTURES|OUTPUT_NAME|PACKAGES_FOUND|PACKAGES_NOT_FOUND|PARENT_DIRECTORY|PASS_REGULAR_EXPRESSION|PDB_NAME|PDB_OUTPUT_DIRECTORY|POSITION_INDEPENDENT_CODE|POST_INSTALL_SCRIPT|PREDEFINED_TARGETS_FOLDER|PREFIX|PRE_INSTALL_SCRIPT|PRIVATE_HEADER|PROCESSORS|PROCESSOR_AFFINITY|PROJECT_LABEL|PUBLIC_HEADER|REPORT_UNDEFINED_PROPERTIES|REQUIRED_FILES|RESOURCE|RESOURCE_LOCK|RULE_LAUNCH_COMPILE|RULE_LAUNCH_CUSTOM|RULE_LAUNCH_LINK|RULE_MESSAGES|RUNTIME_OUTPUT_DIRECTORY|RUN_SERIAL|SKIP_AUTOGEN|SKIP_AUTOMOC|SKIP_AUTORCC|SKIP_AUTOUIC|SKIP_BUILD_RPATH|SKIP_RETURN_CODE|SOURCES|SOURCE_DIR|SOVERSION|STATIC_LIBRARY_FLAGS|STATIC_LIBRARY_OPTIONS|STRINGS|SUBDIRECTORIES|SUFFIX|SYMBOLIC|TARGET_ARCHIVES_MAY_BE_SHARED_LIBS|TARGET_MESSAGES|TARGET_SUPPORTS_SHARED_LIBS|TESTS|TEST_INCLUDE_FILE|TEST_INCLUDE_FILES|TIMEOUT|TIMEOUT_AFTER_MATCH|TYPE|USE_FOLDERS|VALUE|VARIABLES|VERSION|VISIBILITY_INLINES_HIDDEN|VS_(?:CONFIGURATION_TYPE|COPY_TO_OUT_DIR|DEBUGGER_(?:COMMAND|COMMAND_ARGUMENTS|ENVIRONMENT|WORKING_DIRECTORY)|DEPLOYMENT_CONTENT|DEPLOYMENT_LOCATION|DOTNET_REFERENCES|DOTNET_REFERENCES_COPY_LOCAL|INCLUDE_IN_VSIX|IOT_STARTUP_TASK|KEYWORD|RESOURCE_GENERATOR|SCC_AUXPATH|SCC_LOCALPATH|SCC_PROJECTNAME|SCC_PROVIDER|SDK_REFERENCES|SHADER_(?:DISABLE_OPTIMIZATIONS|ENABLE_DEBUG|ENTRYPOINT|FLAGS|MODEL|OBJECT_FILE_NAME|OUTPUT_HEADER_FILE|TYPE|VARIABLE_NAME)|STARTUP_PROJECT|TOOL_OVERRIDE|USER_PROPS|WINRT_COMPONENT|WINRT_EXTENSIONS|WINRT_REFERENCES|XAML_TYPE)|WILL_FAIL|WIN32_EXECUTABLE|WINDOWS_EXPORT_ALL_SYMBOLS|WORKING_DIRECTORY|WRAP_EXCLUDE|XCODE_(?:EMIT_EFFECTIVE_PLATFORM_NAME|EXPLICIT_FILE_TYPE|FILE_ATTRIBUTES|LAST_KNOWN_FILE_TYPE|PRODUCT_TYPE|SCHEME_(?:ADDRESS_SANITIZER|ADDRESS_SANITIZER_USE_AFTER_RETURN|ARGUMENTS|DISABLE_MAIN_THREAD_CHECKER|DYNAMIC_LIBRARY_LOADS|DYNAMIC_LINKER_API_USAGE|ENVIRONMENT|EXECUTABLE|GUARD_MALLOC|MAIN_THREAD_CHECKER_STOP|MALLOC_GUARD_EDGES|MALLOC_SCRIBBLE|MALLOC_STACK|THREAD_SANITIZER(?:_STOP)?|UNDEFINED_BEHAVIOUR_SANITIZER(?:_STOP)?|ZOMBIE_OBJECTS))|XCTEST)\b/,
2306− keyword:
2307− /\b(?:add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|break|build_command|build_name|cmake_host_system_information|cmake_minimum_required|cmake_parse_arguments|cmake_policy|configure_file|continue|create_test_sourcelist|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload|define_property|else|elseif|enable_language|enable_testing|endforeach|endfunction|endif|endmacro|endwhile|exec_program|execute_process|export|export_library_dependencies|file|find_file|find_library|find_package|find_path|find_program|fltk_wrap_ui|foreach|function|get_cmake_property|get_directory_property|get_filename_component|get_property|get_source_file_property|get_target_property|get_test_property|if|include|include_directories|include_external_msproject|include_guard|include_regular_expression|install|install_files|install_programs|install_targets|link_directories|link_libraries|list|load_cache|load_command|macro|make_directory|mark_as_advanced|math|message|option|output_required_files|project|qt_wrap_cpp|qt_wrap_ui|remove|remove_definitions|return|separate_arguments|set|set_directory_properties|set_property|set_source_files_properties|set_target_properties|set_tests_properties|site_name|source_group|string|subdir_depends|subdirs|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_sources|try_compile|try_run|unset|use_mangled_mesa|utility_source|variable_requires|variable_watch|while|write_file)(?=\s*\()\b/,
2308− boolean: /\b(?:FALSE|OFF|ON|TRUE)\b/,
2309− namespace:
2310− /\b(?:INTERFACE|PRIVATE|PROPERTIES|PUBLIC|SHARED|STATIC|TARGET_OBJECTS)\b/,
2311− operator:
2312− /\b(?:AND|DEFINED|EQUAL|GREATER|LESS|MATCHES|NOT|OR|STREQUAL|STRGREATER|STRLESS|VERSION_EQUAL|VERSION_GREATER|VERSION_LESS)\b/,
2313− inserted: {
2314− pattern: /\b\w+::\w+\b/,
2315− alias: "class-name",
2316− },
2317− number: /\b\d+(?:\.\d+)*\b/,
2318− function: /\b[a-z_]\w*(?=\s*\()\b/i,
2319− punctuation: /[()>}]|\$[<{]/,
2142+ 'comment': /#.*/,
2143+ 'string': {
2144+ pattern: /"(?:[^\\"]|\\.)*"/,
2145+ greedy: true,
2146+ inside: {
2147+ 'interpolation': {
2148+ pattern: /\$\{(?:[^{}$]|\$\{[^{}$]*\})*\}/,
2149+ inside: {
2150+ 'punctuation': /\$\{|\}/,
2151+ 'variable': /\w+/
2152+ }
2153+ }
2154+ }
2155+ },
2156+ 'variable': /\b(?:CMAKE_\w+|\w+_(?:(?:BINARY|SOURCE)_DIR|DESCRIPTION|HOMEPAGE_URL|ROOT|VERSION(?:_MAJOR|_MINOR|_PATCH|_TWEAK)?)|(?:ANDROID|APPLE|BORLAND|BUILD_SHARED_LIBS|CACHE|CPACK_(?:ABSOLUTE_DESTINATION_FILES|COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY|ERROR_ON_ABSOLUTE_INSTALL_DESTINATION|INCLUDE_TOPLEVEL_DIRECTORY|INSTALL_DEFAULT_DIRECTORY_PERMISSIONS|INSTALL_SCRIPT|PACKAGING_INSTALL_PREFIX|SET_DESTDIR|WARN_ON_ABSOLUTE_INSTALL_DESTINATION)|CTEST_(?:BINARY_DIRECTORY|BUILD_COMMAND|BUILD_NAME|BZR_COMMAND|BZR_UPDATE_OPTIONS|CHANGE_ID|CHECKOUT_COMMAND|CONFIGURATION_TYPE|CONFIGURE_COMMAND|COVERAGE_COMMAND|COVERAGE_EXTRA_FLAGS|CURL_OPTIONS|CUSTOM_(?:COVERAGE_EXCLUDE|ERROR_EXCEPTION|ERROR_MATCH|ERROR_POST_CONTEXT|ERROR_PRE_CONTEXT|MAXIMUM_FAILED_TEST_OUTPUT_SIZE|MAXIMUM_NUMBER_OF_(?:ERRORS|WARNINGS)|MAXIMUM_PASSED_TEST_OUTPUT_SIZE|MEMCHECK_IGNORE|POST_MEMCHECK|POST_TEST|PRE_MEMCHECK|PRE_TEST|TESTS_IGNORE|WARNING_EXCEPTION|WARNING_MATCH)|CVS_CHECKOUT|CVS_COMMAND|CVS_UPDATE_OPTIONS|DROP_LOCATION|DROP_METHOD|DROP_SITE|DROP_SITE_CDASH|DROP_SITE_PASSWORD|DROP_SITE_USER|EXTRA_COVERAGE_GLOB|GIT_COMMAND|GIT_INIT_SUBMODULES|GIT_UPDATE_CUSTOM|GIT_UPDATE_OPTIONS|HG_COMMAND|HG_UPDATE_OPTIONS|LABELS_FOR_SUBPROJECTS|MEMORYCHECK_(?:COMMAND|COMMAND_OPTIONS|SANITIZER_OPTIONS|SUPPRESSIONS_FILE|TYPE)|NIGHTLY_START_TIME|P4_CLIENT|P4_COMMAND|P4_OPTIONS|P4_UPDATE_OPTIONS|RUN_CURRENT_SCRIPT|SCP_COMMAND|SITE|SOURCE_DIRECTORY|SUBMIT_URL|SVN_COMMAND|SVN_OPTIONS|SVN_UPDATE_OPTIONS|TEST_LOAD|TEST_TIMEOUT|TRIGGER_SITE|UPDATE_COMMAND|UPDATE_OPTIONS|UPDATE_VERSION_ONLY|USE_LAUNCHERS)|CYGWIN|ENV|EXECUTABLE_OUTPUT_PATH|GHS-MULTI|IOS|LIBRARY_OUTPUT_PATH|MINGW|MSVC(?:10|11|12|14|60|70|71|80|90|_IDE|_TOOLSET_VERSION|_VERSION)?|MSYS|PROJECT_NAME|UNIX|WIN32|WINCE|WINDOWS_PHONE|WINDOWS_STORE|XCODE))\b/,
2157+ 'property': /\b(?:cxx_\w+|(?:ARCHIVE_OUTPUT_(?:DIRECTORY|NAME)|COMPILE_DEFINITIONS|COMPILE_PDB_NAME|COMPILE_PDB_OUTPUT_DIRECTORY|EXCLUDE_FROM_DEFAULT_BUILD|IMPORTED_(?:IMPLIB|LIBNAME|LINK_DEPENDENT_LIBRARIES|LINK_INTERFACE_LANGUAGES|LINK_INTERFACE_LIBRARIES|LINK_INTERFACE_MULTIPLICITY|LOCATION|NO_SONAME|OBJECTS|SONAME)|INTERPROCEDURAL_OPTIMIZATION|LIBRARY_OUTPUT_DIRECTORY|LIBRARY_OUTPUT_NAME|LINK_FLAGS|LINK_INTERFACE_LIBRARIES|LINK_INTERFACE_MULTIPLICITY|LOCATION|MAP_IMPORTED_CONFIG|OSX_ARCHITECTURES|OUTPUT_NAME|PDB_NAME|PDB_OUTPUT_DIRECTORY|RUNTIME_OUTPUT_DIRECTORY|RUNTIME_OUTPUT_NAME|STATIC_LIBRARY_FLAGS|VS_CSHARP|VS_DOTNET_REFERENCEPROP|VS_DOTNET_REFERENCE|VS_GLOBAL_SECTION_POST|VS_GLOBAL_SECTION_PRE|VS_GLOBAL|XCODE_ATTRIBUTE)_\w+|\w+_(?:CLANG_TIDY|COMPILER_LAUNCHER|CPPCHECK|CPPLINT|INCLUDE_WHAT_YOU_USE|OUTPUT_NAME|POSTFIX|VISIBILITY_PRESET)|ABSTRACT|ADDITIONAL_MAKE_CLEAN_FILES|ADVANCED|ALIASED_TARGET|ALLOW_DUPLICATE_CUSTOM_TARGETS|ANDROID_(?:ANT_ADDITIONAL_OPTIONS|API|API_MIN|ARCH|ASSETS_DIRECTORIES|GUI|JAR_DEPENDENCIES|NATIVE_LIB_DEPENDENCIES|NATIVE_LIB_DIRECTORIES|PROCESS_MAX|PROGUARD|PROGUARD_CONFIG_PATH|SECURE_PROPS_PATH|SKIP_ANT_STEP|STL_TYPE)|ARCHIVE_OUTPUT_DIRECTORY|ATTACHED_FILES|ATTACHED_FILES_ON_FAIL|AUTOGEN_(?:BUILD_DIR|ORIGIN_DEPENDS|PARALLEL|SOURCE_GROUP|TARGETS_FOLDER|TARGET_DEPENDS)|AUTOMOC|AUTOMOC_(?:COMPILER_PREDEFINES|DEPEND_FILTERS|EXECUTABLE|MACRO_NAMES|MOC_OPTIONS|SOURCE_GROUP|TARGETS_FOLDER)|AUTORCC|AUTORCC_EXECUTABLE|AUTORCC_OPTIONS|AUTORCC_SOURCE_GROUP|AUTOUIC|AUTOUIC_EXECUTABLE|AUTOUIC_OPTIONS|AUTOUIC_SEARCH_PATHS|BINARY_DIR|BUILDSYSTEM_TARGETS|BUILD_RPATH|BUILD_RPATH_USE_ORIGIN|BUILD_WITH_INSTALL_NAME_DIR|BUILD_WITH_INSTALL_RPATH|BUNDLE|BUNDLE_EXTENSION|CACHE_VARIABLES|CLEAN_NO_CUSTOM|COMMON_LANGUAGE_RUNTIME|COMPATIBLE_INTERFACE_(?:BOOL|NUMBER_MAX|NUMBER_MIN|STRING)|COMPILE_(?:DEFINITIONS|FEATURES|FLAGS|OPTIONS|PDB_NAME|PDB_OUTPUT_DIRECTORY)|COST|CPACK_DESKTOP_SHORTCUTS|CPACK_NEVER_OVERWRITE|CPACK_PERMANENT|CPACK_STARTUP_SHORTCUTS|CPACK_START_MENU_SHORTCUTS|CPACK_WIX_ACL|CROSSCOMPILING_EMULATOR|CUDA_EXTENSIONS|CUDA_PTX_COMPILATION|CUDA_RESOLVE_DEVICE_SYMBOLS|CUDA_SEPARABLE_COMPILATION|CUDA_STANDARD|CUDA_STANDARD_REQUIRED|CXX_EXTENSIONS|CXX_STANDARD|CXX_STANDARD_REQUIRED|C_EXTENSIONS|C_STANDARD|C_STANDARD_REQUIRED|DEBUG_CONFIGURATIONS|DEFINE_SYMBOL|DEFINITIONS|DEPENDS|DEPLOYMENT_ADDITIONAL_FILES|DEPLOYMENT_REMOTE_DIRECTORY|DISABLED|DISABLED_FEATURES|ECLIPSE_EXTRA_CPROJECT_CONTENTS|ECLIPSE_EXTRA_NATURES|ENABLED_FEATURES|ENABLED_LANGUAGES|ENABLE_EXPORTS|ENVIRONMENT|EXCLUDE_FROM_ALL|EXCLUDE_FROM_DEFAULT_BUILD|EXPORT_NAME|EXPORT_PROPERTIES|EXTERNAL_OBJECT|EchoString|FAIL_REGULAR_EXPRESSION|FIND_LIBRARY_USE_LIB32_PATHS|FIND_LIBRARY_USE_LIB64_PATHS|FIND_LIBRARY_USE_LIBX32_PATHS|FIND_LIBRARY_USE_OPENBSD_VERSIONING|FIXTURES_CLEANUP|FIXTURES_REQUIRED|FIXTURES_SETUP|FOLDER|FRAMEWORK|Fortran_FORMAT|Fortran_MODULE_DIRECTORY|GENERATED|GENERATOR_FILE_NAME|GENERATOR_IS_MULTI_CONFIG|GHS_INTEGRITY_APP|GHS_NO_SOURCE_GROUP_FILE|GLOBAL_DEPENDS_DEBUG_MODE|GLOBAL_DEPENDS_NO_CYCLES|GNUtoMS|HAS_CXX|HEADER_FILE_ONLY|HELPSTRING|IMPLICIT_DEPENDS_INCLUDE_TRANSFORM|IMPORTED|IMPORTED_(?:COMMON_LANGUAGE_RUNTIME|CONFIGURATIONS|GLOBAL|IMPLIB|LIBNAME|LINK_DEPENDENT_LIBRARIES|LINK_INTERFACE_(?:LANGUAGES|LIBRARIES|MULTIPLICITY)|LOCATION|NO_SONAME|OBJECTS|SONAME)|IMPORT_PREFIX|IMPORT_SUFFIX|INCLUDE_DIRECTORIES|INCLUDE_REGULAR_EXPRESSION|INSTALL_NAME_DIR|INSTALL_RPATH|INSTALL_RPATH_USE_LINK_PATH|INTERFACE_(?:AUTOUIC_OPTIONS|COMPILE_DEFINITIONS|COMPILE_FEATURES|COMPILE_OPTIONS|INCLUDE_DIRECTORIES|LINK_DEPENDS|LINK_DIRECTORIES|LINK_LIBRARIES|LINK_OPTIONS|POSITION_INDEPENDENT_CODE|SOURCES|SYSTEM_INCLUDE_DIRECTORIES)|INTERPROCEDURAL_OPTIMIZATION|IN_TRY_COMPILE|IOS_INSTALL_COMBINED|JOB_POOLS|JOB_POOL_COMPILE|JOB_POOL_LINK|KEEP_EXTENSION|LABELS|LANGUAGE|LIBRARY_OUTPUT_DIRECTORY|LINKER_LANGUAGE|LINK_(?:DEPENDS|DEPENDS_NO_SHARED|DIRECTORIES|FLAGS|INTERFACE_LIBRARIES|INTERFACE_MULTIPLICITY|LIBRARIES|OPTIONS|SEARCH_END_STATIC|SEARCH_START_STATIC|WHAT_YOU_USE)|LISTFILE_STACK|LOCATION|MACOSX_BUNDLE|MACOSX_BUNDLE_INFO_PLIST|MACOSX_FRAMEWORK_INFO_PLIST|MACOSX_PACKAGE_LOCATION|MACOSX_RPATH|MACROS|MANUALLY_ADDED_DEPENDENCIES|MEASUREMENT|MODIFIED|NAME|NO_SONAME|NO_SYSTEM_FROM_IMPORTED|OBJECT_DEPENDS|OBJECT_OUTPUTS|OSX_ARCHITECTURES|OUTPUT_NAME|PACKAGES_FOUND|PACKAGES_NOT_FOUND|PARENT_DIRECTORY|PASS_REGULAR_EXPRESSION|PDB_NAME|PDB_OUTPUT_DIRECTORY|POSITION_INDEPENDENT_CODE|POST_INSTALL_SCRIPT|PREDEFINED_TARGETS_FOLDER|PREFIX|PRE_INSTALL_SCRIPT|PRIVATE_HEADER|PROCESSORS|PROCESSOR_AFFINITY|PROJECT_LABEL|PUBLIC_HEADER|REPORT_UNDEFINED_PROPERTIES|REQUIRED_FILES|RESOURCE|RESOURCE_LOCK|RULE_LAUNCH_COMPILE|RULE_LAUNCH_CUSTOM|RULE_LAUNCH_LINK|RULE_MESSAGES|RUNTIME_OUTPUT_DIRECTORY|RUN_SERIAL|SKIP_AUTOGEN|SKIP_AUTOMOC|SKIP_AUTORCC|SKIP_AUTOUIC|SKIP_BUILD_RPATH|SKIP_RETURN_CODE|SOURCES|SOURCE_DIR|SOVERSION|STATIC_LIBRARY_FLAGS|STATIC_LIBRARY_OPTIONS|STRINGS|SUBDIRECTORIES|SUFFIX|SYMBOLIC|TARGET_ARCHIVES_MAY_BE_SHARED_LIBS|TARGET_MESSAGES|TARGET_SUPPORTS_SHARED_LIBS|TESTS|TEST_INCLUDE_FILE|TEST_INCLUDE_FILES|TIMEOUT|TIMEOUT_AFTER_MATCH|TYPE|USE_FOLDERS|VALUE|VARIABLES|VERSION|VISIBILITY_INLINES_HIDDEN|VS_(?:CONFIGURATION_TYPE|COPY_TO_OUT_DIR|DEBUGGER_(?:COMMAND|COMMAND_ARGUMENTS|ENVIRONMENT|WORKING_DIRECTORY)|DEPLOYMENT_CONTENT|DEPLOYMENT_LOCATION|DOTNET_REFERENCES|DOTNET_REFERENCES_COPY_LOCAL|INCLUDE_IN_VSIX|IOT_STARTUP_TASK|KEYWORD|RESOURCE_GENERATOR|SCC_AUXPATH|SCC_LOCALPATH|SCC_PROJECTNAME|SCC_PROVIDER|SDK_REFERENCES|SHADER_(?:DISABLE_OPTIMIZATIONS|ENABLE_DEBUG|ENTRYPOINT|FLAGS|MODEL|OBJECT_FILE_NAME|OUTPUT_HEADER_FILE|TYPE|VARIABLE_NAME)|STARTUP_PROJECT|TOOL_OVERRIDE|USER_PROPS|WINRT_COMPONENT|WINRT_EXTENSIONS|WINRT_REFERENCES|XAML_TYPE)|WILL_FAIL|WIN32_EXECUTABLE|WINDOWS_EXPORT_ALL_SYMBOLS|WORKING_DIRECTORY|WRAP_EXCLUDE|XCODE_(?:EMIT_EFFECTIVE_PLATFORM_NAME|EXPLICIT_FILE_TYPE|FILE_ATTRIBUTES|LAST_KNOWN_FILE_TYPE|PRODUCT_TYPE|SCHEME_(?:ADDRESS_SANITIZER|ADDRESS_SANITIZER_USE_AFTER_RETURN|ARGUMENTS|DISABLE_MAIN_THREAD_CHECKER|DYNAMIC_LIBRARY_LOADS|DYNAMIC_LINKER_API_USAGE|ENVIRONMENT|EXECUTABLE|GUARD_MALLOC|MAIN_THREAD_CHECKER_STOP|MALLOC_GUARD_EDGES|MALLOC_SCRIBBLE|MALLOC_STACK|THREAD_SANITIZER(?:_STOP)?|UNDEFINED_BEHAVIOUR_SANITIZER(?:_STOP)?|ZOMBIE_OBJECTS))|XCTEST)\b/,
2158+ 'keyword': /\b(?:add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|break|build_command|build_name|cmake_host_system_information|cmake_minimum_required|cmake_parse_arguments|cmake_policy|configure_file|continue|create_test_sourcelist|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload|define_property|else|elseif|enable_language|enable_testing|endforeach|endfunction|endif|endmacro|endwhile|exec_program|execute_process|export|export_library_dependencies|file|find_file|find_library|find_package|find_path|find_program|fltk_wrap_ui|foreach|function|get_cmake_property|get_directory_property|get_filename_component|get_property|get_source_file_property|get_target_property|get_test_property|if|include|include_directories|include_external_msproject|include_guard|include_regular_expression|install|install_files|install_programs|install_targets|link_directories|link_libraries|list|load_cache|load_command|macro|make_directory|mark_as_advanced|math|message|option|output_required_files|project|qt_wrap_cpp|qt_wrap_ui|remove|remove_definitions|return|separate_arguments|set|set_directory_properties|set_property|set_source_files_properties|set_target_properties|set_tests_properties|site_name|source_group|string|subdir_depends|subdirs|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_sources|try_compile|try_run|unset|use_mangled_mesa|utility_source|variable_requires|variable_watch|while|write_file)(?=\s*\()\b/,
2159+ 'boolean': /\b(?:FALSE|OFF|ON|TRUE)\b/,
2160+ 'namespace': /\b(?:INTERFACE|PRIVATE|PROPERTIES|PUBLIC|SHARED|STATIC|TARGET_OBJECTS)\b/,
2161+ 'operator': /\b(?:AND|DEFINED|EQUAL|GREATER|LESS|MATCHES|NOT|OR|STREQUAL|STRGREATER|STRLESS|VERSION_EQUAL|VERSION_GREATER|VERSION_LESS)\b/,
2162+ 'inserted': {
2163+ pattern: /\b\w+::\w+\b/,
2164+ alias: 'class-name'
2165+ },
2166+ 'number': /\b\d+(?:\.\d+)*\b/,
2167+ 'function': /\b[a-z_]\w*(?=\s*\()\b/i,
2168+ 'punctuation': /[()>}]|\$[<{]/
23202169 };
23212170
23222171 (function (Prism) {
2323− // Ignore comments starting with { to privilege string interpolation highlighting
2324− var comment = /#(?!\{).+/;
2325− var interpolation = {
2326− pattern: /#\{[^}]+\}/,
2327− alias: "variable",
2328− };
2329−
2330− Prism.languages.coffeescript = Prism.languages.extend("javascript", {
2331− comment: comment,
2332− string: [
2333− // Strings are multiline
2334− {
2335− pattern: /'(?:\\[\s\S]|[^\\'])*'/,
2336− greedy: true,
2337− },
2338−
2339− {
2340− // Strings are multiline
2341− pattern: /"(?:\\[\s\S]|[^\\"])*"/,
2342− greedy: true,
2343− inside: {
2344− interpolation: interpolation,
2345− },
2346− },
2347− ],
2348− keyword:
2349− /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
2350− "class-member": {
2351− pattern: /@(?!\d)\w+/,
2352− alias: "variable",
2353− },
2354− });
2355−
2356− Prism.languages.insertBefore("coffeescript", "comment", {
2357− "multiline-comment": {
2358− pattern: /###[\s\S]+?###/,
2359− alias: "comment",
2360− },
2361−
2362− // Block regexp can contain comments and interpolation
2363− "block-regex": {
2364− pattern: /\/{3}[\s\S]*?\/{3}/,
2365− alias: "regex",
2366− inside: {
2367− comment: comment,
2368− interpolation: interpolation,
2369− },
2370− },
2371− });
2372−
2373− Prism.languages.insertBefore("coffeescript", "string", {
2374− "inline-javascript": {
2375− pattern: /`(?:\\[\s\S]|[^\\`])*`/,
2376− inside: {
2377− delimiter: {
2378− pattern: /^`|`$/,
2379− alias: "punctuation",
2380− },
2381− script: {
2382− pattern: /[\s\S]+/,
2383− alias: "language-javascript",
2384− inside: Prism.languages.javascript,
2385− },
2386− },
2387− },
2388−
2389− // Block strings
2390− "multiline-string": [
2391− {
2392− pattern: /'''[\s\S]*?'''/,
2393− greedy: true,
2394− alias: "string",
2395− },
2396− {
2397− pattern: /"""[\s\S]*?"""/,
2398− greedy: true,
2399− alias: "string",
2400− inside: {
2401− interpolation: interpolation,
2402− },
2403− },
2404− ],
2405− });
2406−
2407− Prism.languages.insertBefore("coffeescript", "keyword", {
2408− // Object property
2409− property: /(?!\d)\w+(?=\s*:(?!:))/,
2410− });
2411−
2412− delete Prism.languages.coffeescript["template-string"];
2413−
2414− Prism.languages.coffee = Prism.languages.coffeescript;
2415−})(Prism);
2172+
2173+ // Ignore comments starting with { to privilege string interpolation highlighting
2174+ var comment = /#(?!\{).+/;
2175+ var interpolation = {
2176+ pattern: /#\{[^}]+\}/,
2177+ alias: 'variable'
2178+ };
2179+
2180+ Prism.languages.coffeescript = Prism.languages.extend('javascript', {
2181+ 'comment': comment,
2182+ 'string': [
2183+
2184+ // Strings are multiline
2185+ {
2186+ pattern: /'(?:\\[\s\S]|[^\\'])*'/,
2187+ greedy: true
2188+ },
2189+
2190+ {
2191+ // Strings are multiline
2192+ pattern: /"(?:\\[\s\S]|[^\\"])*"/,
2193+ greedy: true,
2194+ inside: {
2195+ 'interpolation': interpolation
2196+ }
2197+ }
2198+ ],
2199+ 'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
2200+ 'class-member': {
2201+ pattern: /@(?!\d)\w+/,
2202+ alias: 'variable'
2203+ }
2204+ });
2205+
2206+ Prism.languages.insertBefore('coffeescript', 'comment', {
2207+ 'multiline-comment': {
2208+ pattern: /###[\s\S]+?###/,
2209+ alias: 'comment'
2210+ },
2211+
2212+ // Block regexp can contain comments and interpolation
2213+ 'block-regex': {
2214+ pattern: /\/{3}[\s\S]*?\/{3}/,
2215+ alias: 'regex',
2216+ inside: {
2217+ 'comment': comment,
2218+ 'interpolation': interpolation
2219+ }
2220+ }
2221+ });
2222+
2223+ Prism.languages.insertBefore('coffeescript', 'string', {
2224+ 'inline-javascript': {
2225+ pattern: /`(?:\\[\s\S]|[^\\`])*`/,
2226+ inside: {
2227+ 'delimiter': {
2228+ pattern: /^`|`$/,
2229+ alias: 'punctuation'
2230+ },
2231+ 'script': {
2232+ pattern: /[\s\S]+/,
2233+ alias: 'language-javascript',
2234+ inside: Prism.languages.javascript
2235+ }
2236+ }
2237+ },
2238+
2239+ // Block strings
2240+ 'multiline-string': [
2241+ {
2242+ pattern: /'''[\s\S]*?'''/,
2243+ greedy: true,
2244+ alias: 'string'
2245+ },
2246+ {
2247+ pattern: /"""[\s\S]*?"""/,
2248+ greedy: true,
2249+ alias: 'string',
2250+ inside: {
2251+ interpolation: interpolation
2252+ }
2253+ }
2254+ ]
2255+
2256+ });
2257+
2258+ Prism.languages.insertBefore('coffeescript', 'keyword', {
2259+ // Object property
2260+ 'property': /(?!\d)\w+(?=\s*:(?!:))/
2261+ });
2262+
2263+ delete Prism.languages.coffeescript['template-string'];
2264+
2265+ Prism.languages.coffee = Prism.languages.coffeescript;
2266+}(Prism));
24162267
24172268 /**
24182269 * Original by Samuel Flores
@@ -2421,1968 +2272,1833 @@ Prism.languages.cmake = { · 2 unmodified lines
24212272 * constant, builtin, variable, symbol, regex
24222273 */
24232274 (function (Prism) {
2424− Prism.languages.ruby = Prism.languages.extend("clike", {
2425− comment: {
2426− pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
2427− greedy: true,
2428− },
2429− "class-name": {
2430− pattern:
2431− /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
2432− lookbehind: true,
2433− inside: {
2434− punctuation: /[.\\]/,
2435− },
2436− },
2437− keyword:
2438− /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
2439− operator:
2440− /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
2441− punctuation: /[(){}[\].,;]/,
2442− });
2443−
2444− Prism.languages.insertBefore("ruby", "operator", {
2445− "double-colon": {
2446− pattern: /::/,
2447− alias: "punctuation",
2448− },
2449− });
2450−
2451− var interpolation = {
2452− pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
2453− lookbehind: true,
2454− inside: {
2455− content: {
2456− pattern: /^(#\{)[\s\S]+(?=\}$)/,
2457− lookbehind: true,
2458− inside: Prism.languages.ruby,
2459− },
2460− delimiter: {
2461− pattern: /^#\{|\}$/,
2462− alias: "punctuation",
2463− },
2464− },
2465− };
2466−
2467− delete Prism.languages.ruby.function;
2468−
2469− var percentExpression =
2470− "(?:" +
2471− [
2472− /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
2473− /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
2474− /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
2475− /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
2476− /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source,
2477− ].join("|") +
2478− ")";
2479−
2480− var symbolName =
2481− /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/
2482− .source;
2483−
2484− Prism.languages.insertBefore("ruby", "keyword", {
2485− "regex-literal": [
2486− {
2487− pattern: RegExp(
2488− /%r/.source + percentExpression + /[egimnosux]{0,6}/.source,
2489− ),
2490− greedy: true,
2491− inside: {
2492− interpolation: interpolation,
2493− regex: /[\s\S]+/,
2494− },
2495− },
2496− {
2497− pattern:
2498− /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
2499− lookbehind: true,
2500− greedy: true,
2501− inside: {
2502− interpolation: interpolation,
2503− regex: /[\s\S]+/,
2504− },
2505− },
2506− ],
2507− variable: /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
2508− symbol: [
2509− {
2510− pattern: RegExp(/(^|[^:]):/.source + symbolName),
2511− lookbehind: true,
2512− greedy: true,
2513− },
2514− {
2515− pattern: RegExp(
2516− /([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source,
2517− ),
2518− lookbehind: true,
2519− greedy: true,
2520− },
2521− ],
2522− "method-definition": {
2523− pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
2524− lookbehind: true,
2525− inside: {
2526− function: /\b\w+$/,
2527− keyword: /^self\b/,
2528− "class-name": /^\w+/,
2529− punctuation: /\./,
2530− },
2531− },
2532− });
2533−
2534− Prism.languages.insertBefore("ruby", "string", {
2535− "string-literal": [
2536− {
2537− pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
2538− greedy: true,
2539− inside: {
2540− interpolation: interpolation,
2541− string: /[\s\S]+/,
2542− },
2543− },
2544− {
2545− pattern:
2546− /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
2547− greedy: true,
2548− inside: {
2549− interpolation: interpolation,
2550− string: /[\s\S]+/,
2551− },
2552− },
2553− {
2554− pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2555− alias: "heredoc-string",
2556− greedy: true,
2557− inside: {
2558− delimiter: {
2559− pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
2560− inside: {
2561− symbol: /\b\w+/,
2562− punctuation: /^<<[-~]?/,
2563− },
2564− },
2565− interpolation: interpolation,
2566− string: /[\s\S]+/,
2567− },
2568− },
2569− {
2570− pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2571− alias: "heredoc-string",
2572− greedy: true,
2573− inside: {
2574− delimiter: {
2575− pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
2576− inside: {
2577− symbol: /\b\w+/,
2578− punctuation: /^<<[-~]?'|'$/,
2579− },
2580− },
2581− string: /[\s\S]+/,
2582− },
2583− },
2584− ],
2585− "command-literal": [
2586− {
2587− pattern: RegExp(/%x/.source + percentExpression),
2588− greedy: true,
2589− inside: {
2590− interpolation: interpolation,
2591− command: {
2592− pattern: /[\s\S]+/,
2593− alias: "string",
2594− },
2595− },
2596− },
2597− {
2598− pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
2599− greedy: true,
2600− inside: {
2601− interpolation: interpolation,
2602− command: {
2603− pattern: /[\s\S]+/,
2604− alias: "string",
2605− },
2606− },
2607− },
2608− ],
2609− });
2610−
2611− delete Prism.languages.ruby.string;
2612−
2613− Prism.languages.insertBefore("ruby", "number", {
2614− builtin:
2615− /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
2616− constant: /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/,
2617− });
2618−
2619− Prism.languages.rb = Prism.languages.ruby;
2620−})(Prism);
2275+ Prism.languages.ruby = Prism.languages.extend('clike', {
2276+ 'comment': {
2277+ pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
2278+ greedy: true
2279+ },
2280+ 'class-name': {
2281+ pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
2282+ lookbehind: true,
2283+ inside: {
2284+ 'punctuation': /[.\\]/
2285+ }
2286+ },
2287+ 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
2288+ 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
2289+ 'punctuation': /[(){}[\].,;]/,
2290+ });
2291+
2292+ Prism.languages.insertBefore('ruby', 'operator', {
2293+ 'double-colon': {
2294+ pattern: /::/,
2295+ alias: 'punctuation'
2296+ },
2297+ });
2298+
2299+ var interpolation = {
2300+ pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
2301+ lookbehind: true,
2302+ inside: {
2303+ 'content': {
2304+ pattern: /^(#\{)[\s\S]+(?=\}$)/,
2305+ lookbehind: true,
2306+ inside: Prism.languages.ruby
2307+ },
2308+ 'delimiter': {
2309+ pattern: /^#\{|\}$/,
2310+ alias: 'punctuation'
2311+ }
2312+ }
2313+ };
2314+
2315+ delete Prism.languages.ruby.function;
2316+
2317+ var percentExpression = '(?:' + [
2318+ /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
2319+ /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
2320+ /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
2321+ /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
2322+ /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
2323+ ].join('|') + ')';
2324+
2325+ var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
2326+
2327+ Prism.languages.insertBefore('ruby', 'keyword', {
2328+ 'regex-literal': [
2329+ {
2330+ pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
2331+ greedy: true,
2332+ inside: {
2333+ 'interpolation': interpolation,
2334+ 'regex': /[\s\S]+/
2335+ }
2336+ },
2337+ {
2338+ pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
2339+ lookbehind: true,
2340+ greedy: true,
2341+ inside: {
2342+ 'interpolation': interpolation,
2343+ 'regex': /[\s\S]+/
2344+ }
2345+ }
2346+ ],
2347+ 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
2348+ 'symbol': [
2349+ {
2350+ pattern: RegExp(/(^|[^:]):/.source + symbolName),
2351+ lookbehind: true,
2352+ greedy: true
2353+ },
2354+ {
2355+ pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
2356+ lookbehind: true,
2357+ greedy: true
2358+ },
2359+ ],
2360+ 'method-definition': {
2361+ pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
2362+ lookbehind: true,
2363+ inside: {
2364+ 'function': /\b\w+$/,
2365+ 'keyword': /^self\b/,
2366+ 'class-name': /^\w+/,
2367+ 'punctuation': /\./
2368+ }
2369+ }
2370+ });
2371+
2372+ Prism.languages.insertBefore('ruby', 'string', {
2373+ 'string-literal': [
2374+ {
2375+ pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
2376+ greedy: true,
2377+ inside: {
2378+ 'interpolation': interpolation,
2379+ 'string': /[\s\S]+/
2380+ }
2381+ },
2382+ {
2383+ pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
2384+ greedy: true,
2385+ inside: {
2386+ 'interpolation': interpolation,
2387+ 'string': /[\s\S]+/
2388+ }
2389+ },
2390+ {
2391+ pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2392+ alias: 'heredoc-string',
2393+ greedy: true,
2394+ inside: {
2395+ 'delimiter': {
2396+ pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
2397+ inside: {
2398+ 'symbol': /\b\w+/,
2399+ 'punctuation': /^<<[-~]?/
2400+ }
2401+ },
2402+ 'interpolation': interpolation,
2403+ 'string': /[\s\S]+/
2404+ }
2405+ },
2406+ {
2407+ pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2408+ alias: 'heredoc-string',
2409+ greedy: true,
2410+ inside: {
2411+ 'delimiter': {
2412+ pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
2413+ inside: {
2414+ 'symbol': /\b\w+/,
2415+ 'punctuation': /^<<[-~]?'|'$/,
2416+ }
2417+ },
2418+ 'string': /[\s\S]+/
2419+ }
2420+ }
2421+ ],
2422+ 'command-literal': [
2423+ {
2424+ pattern: RegExp(/%x/.source + percentExpression),
2425+ greedy: true,
2426+ inside: {
2427+ 'interpolation': interpolation,
2428+ 'command': {
2429+ pattern: /[\s\S]+/,
2430+ alias: 'string'
2431+ }
2432+ }
2433+ },
2434+ {
2435+ pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
2436+ greedy: true,
2437+ inside: {
2438+ 'interpolation': interpolation,
2439+ 'command': {
2440+ pattern: /[\s\S]+/,
2441+ alias: 'string'
2442+ }
2443+ }
2444+ }
2445+ ]
2446+ });
2447+
2448+ delete Prism.languages.ruby.string;
2449+
2450+ Prism.languages.insertBefore('ruby', 'number', {
2451+ 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
2452+ 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
2453+ });
2454+
2455+ Prism.languages.rb = Prism.languages.ruby;
2456+}(Prism));
26212457
26222458 (function (Prism) {
2623− Prism.languages.crystal = Prism.languages.extend("ruby", {
2624− keyword: [
2625− /\b(?:__DIR__|__END_LINE__|__FILE__|__LINE__|abstract|alias|annotation|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|ifdef|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|ptr|require|rescue|return|select|self|sizeof|struct|super|then|type|typeof|undef|uninitialized|union|unless|until|when|while|with|yield)\b/,
2626− {
2627− pattern: /(\.\s*)(?:is_a|responds_to)\?/,
2628− lookbehind: true,
2629− },
2630− ],
2631− number:
2632− /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/,
2633− operator: [/->/, Prism.languages.ruby.operator],
2634− punctuation: /[(){}[\].,;\\]/,
2635− });
2636−
2637− Prism.languages.insertBefore("crystal", "string-literal", {
2638− attribute: {
2639− pattern: /@\[.*?\]/,
2640− inside: {
2641− delimiter: {
2642− pattern: /^@\[|\]$/,
2643− alias: "punctuation",
2644− },
2645− attribute: {
2646− pattern: /^(\s*)\w+/,
2647− lookbehind: true,
2648− alias: "class-name",
2649− },
2650− args: {
2651− pattern: /\S(?:[\s\S]*\S)?/,
2652− inside: Prism.languages.crystal,
2653− },
2654− },
2655− },
2656− expansion: {
2657− pattern: /\{(?:\{.*?\}|%.*?%)\}/,
2658− inside: {
2659− content: {
2660− pattern: /^(\{.)[\s\S]+(?=.\}$)/,
2661− lookbehind: true,
2662− inside: Prism.languages.crystal,
2663− },
2664− delimiter: {
2665− pattern: /^\{[\{%]|[\}%]\}$/,
2666− alias: "operator",
2667− },
2668− },
2669− },
2670− char: {
2671− pattern:
2672− /'(?:[^\\\r\n]{1,2}|\\(?:.|u(?:[A-Fa-f0-9]{1,4}|\{[A-Fa-f0-9]{1,6}\})))'/,
2673− greedy: true,
2674− },
2675− });
2676−})(Prism);
2677−
2678−Prism.languages.d = Prism.languages.extend("clike", {
2679− comment: [
2680− {
2681− // Shebang
2682− pattern: /^\s*#!.+/,
2683− greedy: true,
2684− },
2685− {
2686− pattern: RegExp(
2687− /(^|[^\\])/.source +
2688− "(?:" +
2689− [
2690− // /+ comment +/
2691− // Allow one level of nesting
2692− /\/\+(?:\/\+(?:[^+]|\+(?!\/))*\+\/|(?!\/\+)[\s\S])*?\+\//.source,
2693− // // comment
2694− /\/\/.*/.source,
2695− // /* comment */
2696− /\/\*[\s\S]*?\*\//.source,
2697− ].join("|") +
2698− ")",
2699− ),
2700− lookbehind: true,
2701− greedy: true,
2702− },
2703− ],
2704− string: [
2705− {
2706− pattern: RegExp(
2707− [
2708− // r"", x""
2709− /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/.source,
2710−
2711− // q"[]", q"()", q"<>", q"{}"
2712− /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/.source,
2713−
2714− // q"IDENT
2715− // ...

6352 more lines aren’t shown here.

lib/docs/filters/tcllib/clean_html.rb+40−0
@@ -0,0 +1,40 @@
1+module Docs
2+ class Tcllib
3+ class CleanHtmlFilter < Filter
4+ def call
5+ css("hr").remove()
6+ xpath("./div/text()").remove() # Navigation text content e.g. [ | | | ]
7+ css("div.markdown > a").remove() # Navigation links
8+
9+
10+ # Fix up ToC links
11+ css('a[name]').each do |node|
12+ node.parent['id'] = node['name']
13+ node.before(node.children).remove unless node['href']
14+ end
15+
16+ # Relies on the above ToC fixup
17+ keywords = at_css('#keywords')
18+ if !keywords.nil?
19+ keywords.next_sibling.remove()
20+ keywords.remove()
21+ css('a[href="#keywords"]').remove()
22+ end
23+
24+ # Downrank headings for styling
25+ css('h2').each do |node|
26+ node.name = 'h3'
27+ end
28+ css('h1').each do |node|
29+ node.name = 'h2'
30+ end
31+
32+ css('pre').each do |node|
33+ node['data-language'] = 'tcl'
34+ end
35+
36+ doc
37+ end
38+ end
39+ end
40+end
lib/docs/filters/tcllib/entries.rb+22−0
@@ -0,0 +1,22 @@
1+module Docs
2+ class Tcllib
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ # The first word after the `NAME` heading
6+ name = at_css('h1 + p')
7+ return name.content.strip.split[0]
8+ end
9+
10+ def get_type
11+ # The types are the categories as indicated on each page (and on the
12+ # root page, toc0.md)
13+ category = at_css('a[name="category"]')
14+ if !category.nil?
15+ return category.parent.next.next.content
16+ end
17+ return 'Unfiled'
18+ end
19+ end
20+ end
21+end
22+
lib/docs/filters/tcllib/nop.rb+9−0
@@ -0,0 +1,9 @@
1+module Docs
2+ class Tcllib
3+ class NopFilter < Filter
4+ def call
5+ doc
6+ end
7+ end
8+ end
9+end
lib/docs/scrapers/tcllib.rb+39−0
@@ -0,0 +1,39 @@
1+module Docs
2+ class Tcllib < UrlScraper
3+ self.name = 'Tcllib'
4+ self.type = 'simple'
5+ self.slug = 'tcllib'
6+ self.release = '2.0'
7+ self.base_url = 'https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/'
8+ self.root_path = 'toc0.md'
9+ self.links = {
10+ home: 'https://core.tcl-lang.org/tcllib/doc/trunk/embedded/index.md',
11+ code: 'https://sourceforge.net/projects/tcllib/files/tcllib/'
12+ }
13+
14+ html_filters.push 'tcllib/entries', 'tcllib/clean_html', 'title'
15+ # The docs have incorrect <base> elements, so we should just skip that
16+ html_filters.replace('apply_base_url', 'tcllib/nop')
17+
18+ options[:root_title] = 'Tcllib Documentation'
19+ options[:container] = '.content'
20+ options[:skip] = [
21+ # Full of broken links, path improperly duplicates "tcllib" segment
22+ 'tcllib/toc.md',
23+ # The other ones aren't terribly useful
24+ 'toc.md', 'toc1.md', 'toc2.md',
25+ # Keyword index
26+ 'index.md'
27+ ]
28+
29+ options[:attribution] = <<-HTML
30+ Licensed under the <a href="https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/devdoc/tcllib_license.md">BSD license</a>
31+ HTML
32+
33+
34+ def get_latest_version(opts)
35+ doc = fetch_doc('https://core.tcl-lang.org/tcllib/doc/trunk/embedded/index.md', opts)
36+ doc.at_css('strong').content.scan(/([0-9.]+)/)[0][0]
37+ end
38+ end
39+end
public/icons/docs/tcllib/16.png+0−0

Binary file not shown.

public/icons/docs/tcllib/16@2x.png+0−0

Binary file not shown.

public/icons/docs/tcllib/SOURCE+1−0
@@ -0,0 +1 @@
1+https://commons.wikimedia.org/wiki/File:Tcl.svg