UNPKG

316 kBJavaScriptView Raw
1/*
2 Highlight.js 10.5.0 (af20048d)
3 License: BSD-3-Clause
4 Copyright (c) 2006-2020, Ivan Sagalaev
5*/
6var hljs = (function () {
7 'use strict';
8
9 function deepFreeze(obj) {
10 if (obj instanceof Map) {
11 obj.clear = obj.delete = obj.set = function () {
12 throw new Error('map is read-only');
13 };
14 } else if (obj instanceof Set) {
15 obj.add = obj.clear = obj.delete = function () {
16 throw new Error('set is read-only');
17 };
18 }
19
20 // Freeze self
21 Object.freeze(obj);
22
23 Object.getOwnPropertyNames(obj).forEach(function (name) {
24 var prop = obj[name];
25
26 // Freeze prop if it is an object
27 if (typeof prop == 'object' && !Object.isFrozen(prop)) {
28 deepFreeze(prop);
29 }
30 });
31
32 return obj;
33 }
34
35 var deepFreezeEs6 = deepFreeze;
36 var _default = deepFreeze;
37 deepFreezeEs6.default = _default;
38
39 class Response {
40
41 constructor(mode) {
42 // eslint-disable-next-line no-undefined
43 if (mode.data === undefined) mode.data = {};
44
45 this.data = mode.data;
46 }
47
48 ignoreMatch() {
49 this.ignore = true;
50 }
51 }
52
53 /**
54 * @param {string} value
55 * @returns {string}
56 */
57 function escapeHTML(value) {
58 return value
59 .replace(/&/g, '&')
60 .replace(/</g, '&lt;')
61 .replace(/>/g, '&gt;')
62 .replace(/"/g, '&quot;')
63 .replace(/'/g, '&#x27;');
64 }
65
66 /**
67 * performs a shallow merge of multiple objects into one
68 *
69 * @template T
70 * @param {T} original
71 * @param {Record<string,any>[]} objects
72 * @returns {T} a single new object
73 */
74 function inherit(original, ...objects) {
75 /** @type Record<string,any> */
76 const result = Object.create(null);
77
78 for (const key in original) {
79 result[key] = original[key];
80 }
81 objects.forEach(function(obj) {
82 for (const key in obj) {
83 result[key] = obj[key];
84 }
85 });
86 return /** @type {T} */ (result);
87 }
88
89 /**
90 * @typedef {object} Renderer
91 * @property {(text: string) => void} addText
92 * @property {(node: Node) => void} openNode
93 * @property {(node: Node) => void} closeNode
94 * @property {() => string} value
95 */
96
97 /** @typedef {{kind?: string, sublanguage?: boolean}} Node */
98 /** @typedef {{walk: (r: Renderer) => void}} Tree */
99 /** */
100
101 const SPAN_CLOSE = '</span>';
102
103 /**
104 * Determines if a node needs to be wrapped in <span>
105 *
106 * @param {Node} node */
107 const emitsWrappingTags = (node) => {
108 return !!node.kind;
109 };
110
111 /** @type {Renderer} */
112 class HTMLRenderer {
113 /**
114 * Creates a new HTMLRenderer
115 *
116 * @param {Tree} parseTree - the parse tree (must support `walk` API)
117 * @param {{classPrefix: string}} options
118 */
119 constructor(parseTree, options) {
120 this.buffer = "";
121 this.classPrefix = options.classPrefix;
122 parseTree.walk(this);
123 }
124
125 /**
126 * Adds texts to the output stream
127 *
128 * @param {string} text */
129 addText(text) {
130 this.buffer += escapeHTML(text);
131 }
132
133 /**
134 * Adds a node open to the output stream (if needed)
135 *
136 * @param {Node} node */
137 openNode(node) {
138 if (!emitsWrappingTags(node)) return;
139
140 let className = node.kind;
141 if (!node.sublanguage) {
142 className = `${this.classPrefix}${className}`;
143 }
144 this.span(className);
145 }
146
147 /**
148 * Adds a node close to the output stream (if needed)
149 *
150 * @param {Node} node */
151 closeNode(node) {
152 if (!emitsWrappingTags(node)) return;
153
154 this.buffer += SPAN_CLOSE;
155 }
156
157 /**
158 * returns the accumulated buffer
159 */
160 value() {
161 return this.buffer;
162 }
163
164 // helpers
165
166 /**
167 * Builds a span element
168 *
169 * @param {string} className */
170 span(className) {
171 this.buffer += `<span class="${className}">`;
172 }
173 }
174
175 /** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} | string} Node */
176 /** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} } DataNode */
177 /** */
178
179 class TokenTree {
180 constructor() {
181 /** @type DataNode */
182 this.rootNode = { children: [] };
183 this.stack = [this.rootNode];
184 }
185
186 get top() {
187 return this.stack[this.stack.length - 1];
188 }
189
190 get root() { return this.rootNode; }
191
192 /** @param {Node} node */
193 add(node) {
194 this.top.children.push(node);
195 }
196
197 /** @param {string} kind */
198 openNode(kind) {
199 /** @type Node */
200 const node = { kind, children: [] };
201 this.add(node);
202 this.stack.push(node);
203 }
204
205 closeNode() {
206 if (this.stack.length > 1) {
207 return this.stack.pop();
208 }
209 // eslint-disable-next-line no-undefined
210 return undefined;
211 }
212
213 closeAllNodes() {
214 while (this.closeNode());
215 }
216
217 toJSON() {
218 return JSON.stringify(this.rootNode, null, 4);
219 }
220
221 /**
222 * @typedef { import("./html_renderer").Renderer } Renderer
223 * @param {Renderer} builder
224 */
225 walk(builder) {
226 // this does not
227 return this.constructor._walk(builder, this.rootNode);
228 // this works
229 // return TokenTree._walk(builder, this.rootNode);
230 }
231
232 /**
233 * @param {Renderer} builder
234 * @param {Node} node
235 */
236 static _walk(builder, node) {
237 if (typeof node === "string") {
238 builder.addText(node);
239 } else if (node.children) {
240 builder.openNode(node);
241 node.children.forEach((child) => this._walk(builder, child));
242 builder.closeNode(node);
243 }
244 return builder;
245 }
246
247 /**
248 * @param {Node} node
249 */
250 static _collapse(node) {
251 if (typeof node === "string") return;
252 if (!node.children) return;
253
254 if (node.children.every(el => typeof el === "string")) {
255 // node.text = node.children.join("");
256 // delete node.children;
257 node.children = [node.children.join("")];
258 } else {
259 node.children.forEach((child) => {
260 TokenTree._collapse(child);
261 });
262 }
263 }
264 }
265
266 /**
267 Currently this is all private API, but this is the minimal API necessary
268 that an Emitter must implement to fully support the parser.
269
270 Minimal interface:
271
272 - addKeyword(text, kind)
273 - addText(text)
274 - addSublanguage(emitter, subLanguageName)
275 - finalize()
276 - openNode(kind)
277 - closeNode()
278 - closeAllNodes()
279 - toHTML()
280
281 */
282
283 /**
284 * @implements {Emitter}
285 */
286 class TokenTreeEmitter extends TokenTree {
287 /**
288 * @param {*} options
289 */
290 constructor(options) {
291 super();
292 this.options = options;
293 }
294
295 /**
296 * @param {string} text
297 * @param {string} kind
298 */
299 addKeyword(text, kind) {
300 if (text === "") { return; }
301
302 this.openNode(kind);
303 this.addText(text);
304 this.closeNode();
305 }
306
307 /**
308 * @param {string} text
309 */
310 addText(text) {
311 if (text === "") { return; }
312
313 this.add(text);
314 }
315
316 /**
317 * @param {Emitter & {root: DataNode}} emitter
318 * @param {string} name
319 */
320 addSublanguage(emitter, name) {
321 /** @type DataNode */
322 const node = emitter.root;
323 node.kind = name;
324 node.sublanguage = true;
325 this.add(node);
326 }
327
328 toHTML() {
329 const renderer = new HTMLRenderer(this, this.options);
330 return renderer.value();
331 }
332
333 finalize() {
334 return true;
335 }
336 }
337
338 /**
339 * @param {string} value
340 * @returns {RegExp}
341 * */
342 function escape(value) {
343 return new RegExp(value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'm');
344 }
345
346 /**
347 * @param {RegExp | string } re
348 * @returns {string}
349 */
350 function source(re) {
351 if (!re) return null;
352 if (typeof re === "string") return re;
353
354 return re.source;
355 }
356
357 /**
358 * @param {...(RegExp | string) } args
359 * @returns {string}
360 */
361 function concat(...args) {
362 const joined = args.map((x) => source(x)).join("");
363 return joined;
364 }
365
366 /**
367 * Any of the passed expresssions may match
368 *
369 * Creates a huge this | this | that | that match
370 * @param {(RegExp | string)[] } args
371 * @returns {string}
372 */
373 function either(...args) {
374 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
375 return joined;
376 }
377
378 /**
379 * @param {RegExp} re
380 * @returns {number}
381 */
382 function countMatchGroups(re) {
383 return (new RegExp(re.toString() + '|')).exec('').length - 1;
384 }
385
386 /**
387 * Does lexeme start with a regular expression match at the beginning
388 * @param {RegExp} re
389 * @param {string} lexeme
390 */
391 function startsWith(re, lexeme) {
392 const match = re && re.exec(lexeme);
393 return match && match.index === 0;
394 }
395
396 // join logically computes regexps.join(separator), but fixes the
397 // backreferences so they continue to match.
398 // it also places each individual regular expression into it's own
399 // match group, keeping track of the sequencing of those match groups
400 // is currently an exercise for the caller. :-)
401 /**
402 * @param {(string | RegExp)[]} regexps
403 * @param {string} separator
404 * @returns {string}
405 */
406 function join(regexps, separator = "|") {
407 // backreferenceRe matches an open parenthesis or backreference. To avoid
408 // an incorrect parse, it additionally matches the following:
409 // - [...] elements, where the meaning of parentheses and escapes change
410 // - other escape sequences, so we do not misparse escape sequences as
411 // interesting elements
412 // - non-matching or lookahead parentheses, which do not capture. These
413 // follow the '(' with a '?'.
414 const backreferenceRe = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
415 let numCaptures = 0;
416 let ret = '';
417 for (let i = 0; i < regexps.length; i++) {
418 numCaptures += 1;
419 const offset = numCaptures;
420 let re = source(regexps[i]);
421 if (i > 0) {
422 ret += separator;
423 }
424 ret += "(";
425 while (re.length > 0) {
426 const match = backreferenceRe.exec(re);
427 if (match == null) {
428 ret += re;
429 break;
430 }
431 ret += re.substring(0, match.index);
432 re = re.substring(match.index + match[0].length);
433 if (match[0][0] === '\\' && match[1]) {
434 // Adjust the backreference.
435 ret += '\\' + String(Number(match[1]) + offset);
436 } else {
437 ret += match[0];
438 if (match[0] === '(') {
439 numCaptures++;
440 }
441 }
442 }
443 ret += ")";
444 }
445 return ret;
446 }
447
448 // Common regexps
449 const IDENT_RE = '[a-zA-Z]\\w*';
450 const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
451 const NUMBER_RE = '\\b\\d+(\\.\\d+)?';
452 const C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
453 const BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
454 const RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
455
456 /**
457 * @param { Partial<Mode> & {binary?: string | RegExp} } opts
458 */
459 const SHEBANG = (opts = {}) => {
460 const beginShebang = /^#![ ]*\//;
461 if (opts.binary) {
462 opts.begin = concat(
463 beginShebang,
464 /.*\b/,
465 opts.binary,
466 /\b.*/);
467 }
468 return inherit({
469 className: 'meta',
470 begin: beginShebang,
471 end: /$/,
472 relevance: 0,
473 /** @type {ModeCallback} */
474 "on:begin": (m, resp) => {
475 if (m.index !== 0) resp.ignoreMatch();
476 }
477 }, opts);
478 };
479
480 // Common modes
481 const BACKSLASH_ESCAPE = {
482 begin: '\\\\[\\s\\S]', relevance: 0
483 };
484 const APOS_STRING_MODE = {
485 className: 'string',
486 begin: '\'',
487 end: '\'',
488 illegal: '\\n',
489 contains: [BACKSLASH_ESCAPE]
490 };
491 const QUOTE_STRING_MODE = {
492 className: 'string',
493 begin: '"',
494 end: '"',
495 illegal: '\\n',
496 contains: [BACKSLASH_ESCAPE]
497 };
498 const PHRASAL_WORDS_MODE = {
499 begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
500 };
501 /**
502 * Creates a comment mode
503 *
504 * @param {string | RegExp} begin
505 * @param {string | RegExp} end
506 * @param {Mode | {}} [modeOptions]
507 * @returns {Partial<Mode>}
508 */
509 const COMMENT = function(begin, end, modeOptions = {}) {
510 const mode = inherit(
511 {
512 className: 'comment',
513 begin,
514 end,
515 contains: []
516 },
517 modeOptions
518 );
519 mode.contains.push(PHRASAL_WORDS_MODE);
520 mode.contains.push({
521 className: 'doctag',
522 begin: '(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):',
523 relevance: 0
524 });
525 return mode;
526 };
527 const C_LINE_COMMENT_MODE = COMMENT('//', '$');
528 const C_BLOCK_COMMENT_MODE = COMMENT('/\\*', '\\*/');
529 const HASH_COMMENT_MODE = COMMENT('#', '$');
530 const NUMBER_MODE = {
531 className: 'number',
532 begin: NUMBER_RE,
533 relevance: 0
534 };
535 const C_NUMBER_MODE = {
536 className: 'number',
537 begin: C_NUMBER_RE,
538 relevance: 0
539 };
540 const BINARY_NUMBER_MODE = {
541 className: 'number',
542 begin: BINARY_NUMBER_RE,
543 relevance: 0
544 };
545 const CSS_NUMBER_MODE = {
546 className: 'number',
547 begin: NUMBER_RE + '(' +
548 '%|em|ex|ch|rem' +
549 '|vw|vh|vmin|vmax' +
550 '|cm|mm|in|pt|pc|px' +
551 '|deg|grad|rad|turn' +
552 '|s|ms' +
553 '|Hz|kHz' +
554 '|dpi|dpcm|dppx' +
555 ')?',
556 relevance: 0
557 };
558 const REGEXP_MODE = {
559 // this outer rule makes sure we actually have a WHOLE regex and not simply
560 // an expression such as:
561 //
562 // 3 / something
563 //
564 // (which will then blow up when regex's `illegal` sees the newline)
565 begin: /(?=\/[^/\n]*\/)/,
566 contains: [{
567 className: 'regexp',
568 begin: /\//,
569 end: /\/[gimuy]*/,
570 illegal: /\n/,
571 contains: [
572 BACKSLASH_ESCAPE,
573 {
574 begin: /\[/,
575 end: /\]/,
576 relevance: 0,
577 contains: [BACKSLASH_ESCAPE]
578 }
579 ]
580 }]
581 };
582 const TITLE_MODE = {
583 className: 'title',
584 begin: IDENT_RE,
585 relevance: 0
586 };
587 const UNDERSCORE_TITLE_MODE = {
588 className: 'title',
589 begin: UNDERSCORE_IDENT_RE,
590 relevance: 0
591 };
592 const METHOD_GUARD = {
593 // excludes method names from keyword processing
594 begin: '\\.\\s*' + UNDERSCORE_IDENT_RE,
595 relevance: 0
596 };
597
598 /**
599 * Adds end same as begin mechanics to a mode
600 *
601 * Your mode must include at least a single () match group as that first match
602 * group is what is used for comparison
603 * @param {Partial<Mode>} mode
604 */
605 const END_SAME_AS_BEGIN = function(mode) {
606 return Object.assign(mode,
607 {
608 /** @type {ModeCallback} */
609 'on:begin': (m, resp) => { resp.data._beginMatch = m[1]; },
610 /** @type {ModeCallback} */
611 'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); }
612 });
613 };
614
615 var MODES = /*#__PURE__*/Object.freeze({
616 __proto__: null,
617 IDENT_RE: IDENT_RE,
618 UNDERSCORE_IDENT_RE: UNDERSCORE_IDENT_RE,
619 NUMBER_RE: NUMBER_RE,
620 C_NUMBER_RE: C_NUMBER_RE,
621 BINARY_NUMBER_RE: BINARY_NUMBER_RE,
622 RE_STARTERS_RE: RE_STARTERS_RE,
623 SHEBANG: SHEBANG,
624 BACKSLASH_ESCAPE: BACKSLASH_ESCAPE,
625 APOS_STRING_MODE: APOS_STRING_MODE,
626 QUOTE_STRING_MODE: QUOTE_STRING_MODE,
627 PHRASAL_WORDS_MODE: PHRASAL_WORDS_MODE,
628 COMMENT: COMMENT,
629 C_LINE_COMMENT_MODE: C_LINE_COMMENT_MODE,
630 C_BLOCK_COMMENT_MODE: C_BLOCK_COMMENT_MODE,
631 HASH_COMMENT_MODE: HASH_COMMENT_MODE,
632 NUMBER_MODE: NUMBER_MODE,
633 C_NUMBER_MODE: C_NUMBER_MODE,
634 BINARY_NUMBER_MODE: BINARY_NUMBER_MODE,
635 CSS_NUMBER_MODE: CSS_NUMBER_MODE,
636 REGEXP_MODE: REGEXP_MODE,
637 TITLE_MODE: TITLE_MODE,
638 UNDERSCORE_TITLE_MODE: UNDERSCORE_TITLE_MODE,
639 METHOD_GUARD: METHOD_GUARD,
640 END_SAME_AS_BEGIN: END_SAME_AS_BEGIN
641 });
642
643 // Grammar extensions / plugins
644 // See: https://github.com/highlightjs/highlight.js/issues/2833
645
646 // Grammar extensions allow "syntactic sugar" to be added to the grammar modes
647 // without requiring any underlying changes to the compiler internals.
648
649 // `compileMatch` being the perfect small example of now allowing a grammar
650 // author to write `match` when they desire to match a single expression rather
651 // than being forced to use `begin`. The extension then just moves `match` into
652 // `begin` when it runs. Ie, no features have been added, but we've just made
653 // the experience of writing (and reading grammars) a little bit nicer.
654
655 // ------
656
657 // TODO: We need negative look-behind support to do this properly
658 /**
659 * Skip a match if it has a preceding dot
660 *
661 * This is used for `beginKeywords` to prevent matching expressions such as
662 * `bob.keyword.do()`. The mode compiler automatically wires this up as a
663 * special _internal_ 'on:begin' callback for modes with `beginKeywords`
664 * @param {RegExpMatchArray} match
665 * @param {CallbackResponse} response
666 */
667 function skipIfhasPrecedingDot(match, response) {
668 const before = match.input[match.index - 1];
669 if (before === ".") {
670 response.ignoreMatch();
671 }
672 }
673
674
675 /**
676 * `beginKeywords` syntactic sugar
677 * @type {CompilerExt}
678 */
679 function beginKeywords(mode, parent) {
680 if (!parent) return;
681 if (!mode.beginKeywords) return;
682
683 // for languages with keywords that include non-word characters checking for
684 // a word boundary is not sufficient, so instead we check for a word boundary
685 // or whitespace - this does no harm in any case since our keyword engine
686 // doesn't allow spaces in keywords anyways and we still check for the boundary
687 // first
688 mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)';
689 mode.__beforeBegin = skipIfhasPrecedingDot;
690 mode.keywords = mode.keywords || mode.beginKeywords;
691 delete mode.beginKeywords;
692 }
693
694 /**
695 * Allow `illegal` to contain an array of illegal values
696 * @type {CompilerExt}
697 */
698 function compileIllegal(mode, _parent) {
699 if (!Array.isArray(mode.illegal)) return;
700
701 mode.illegal = either(...mode.illegal);
702 }
703
704 /**
705 * `match` to match a single expression for readability
706 * @type {CompilerExt}
707 */
708 function compileMatch(mode, _parent) {
709 if (!mode.match) return;
710 if (mode.begin || mode.end) throw new Error("begin & end are not supported with match");
711
712 mode.begin = mode.match;
713 delete mode.match;
714 }
715
716 /**
717 * provides the default 1 relevance to all modes
718 * @type {CompilerExt}
719 */
720 function compileRelevance(mode, _parent) {
721 // eslint-disable-next-line no-undefined
722 if (mode.relevance === undefined) mode.relevance = 1;
723 }
724
725 // keywords that should have no default relevance value
726 const COMMON_KEYWORDS = [
727 'of',
728 'and',
729 'for',
730 'in',
731 'not',
732 'or',
733 'if',
734 'then',
735 'parent', // common variable name
736 'list', // common variable name
737 'value' // common variable name
738 ];
739
740 /**
741 * Given raw keywords from a language definition, compile them.
742 *
743 * @param {string | Record<string,string>} rawKeywords
744 * @param {boolean} caseInsensitive
745 */
746 function compileKeywords(rawKeywords, caseInsensitive) {
747 /** @type KeywordDict */
748 const compiledKeywords = {};
749
750 if (typeof rawKeywords === 'string') { // string
751 splitAndCompile('keyword', rawKeywords);
752 } else {
753 Object.keys(rawKeywords).forEach(function(className) {
754 splitAndCompile(className, rawKeywords[className]);
755 });
756 }
757 return compiledKeywords;
758
759 // ---
760
761 /**
762 * Compiles an individual list of keywords
763 *
764 * Ex: "for if when while|5"
765 *
766 * @param {string} className
767 * @param {string} keywordList
768 */
769 function splitAndCompile(className, keywordList) {
770 if (caseInsensitive) {
771 keywordList = keywordList.toLowerCase();
772 }
773 keywordList.split(' ').forEach(function(keyword) {
774 const pair = keyword.split('|');
775 compiledKeywords[pair[0]] = [className, scoreForKeyword(pair[0], pair[1])];
776 });
777 }
778 }
779
780 /**
781 * Returns the proper score for a given keyword
782 *
783 * Also takes into account comment keywords, which will be scored 0 UNLESS
784 * another score has been manually assigned.
785 * @param {string} keyword
786 * @param {string} [providedScore]
787 */
788 function scoreForKeyword(keyword, providedScore) {
789 // manual scores always win over common keywords
790 // so you can force a score of 1 if you really insist
791 if (providedScore) {
792 return Number(providedScore);
793 }
794
795 return commonKeyword(keyword) ? 0 : 1;
796 }
797
798 /**
799 * Determines if a given keyword is common or not
800 *
801 * @param {string} keyword */
802 function commonKeyword(keyword) {
803 return COMMON_KEYWORDS.includes(keyword.toLowerCase());
804 }
805
806 // compilation
807
808 /**
809 * Compiles a language definition result
810 *
811 * Given the raw result of a language definition (Language), compiles this so
812 * that it is ready for highlighting code.
813 * @param {Language} language
814 * @param {{plugins: HLJSPlugin[]}} opts
815 * @returns {CompiledLanguage}
816 */
817 function compileLanguage(language, { plugins }) {
818 /**
819 * Builds a regex with the case sensativility of the current language
820 *
821 * @param {RegExp | string} value
822 * @param {boolean} [global]
823 */
824 function langRe(value, global) {
825 return new RegExp(
826 source(value),
827 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '')
828 );
829 }
830
831 /**
832 Stores multiple regular expressions and allows you to quickly search for
833 them all in a string simultaneously - returning the first match. It does
834 this by creating a huge (a|b|c) regex - each individual item wrapped with ()
835 and joined by `|` - using match groups to track position. When a match is
836 found checking which position in the array has content allows us to figure
837 out which of the original regexes / match groups triggered the match.
838
839 The match object itself (the result of `Regex.exec`) is returned but also
840 enhanced by merging in any meta-data that was registered with the regex.
841 This is how we keep track of which mode matched, and what type of rule
842 (`illegal`, `begin`, end, etc).
843 */
844 class MultiRegex {
845 constructor() {
846 this.matchIndexes = {};
847 // @ts-ignore
848 this.regexes = [];
849 this.matchAt = 1;
850 this.position = 0;
851 }
852
853 // @ts-ignore
854 addRule(re, opts) {
855 opts.position = this.position++;
856 // @ts-ignore
857 this.matchIndexes[this.matchAt] = opts;
858 this.regexes.push([opts, re]);
859 this.matchAt += countMatchGroups(re) + 1;
860 }
861
862 compile() {
863 if (this.regexes.length === 0) {
864 // avoids the need to check length every time exec is called
865 // @ts-ignore
866 this.exec = () => null;
867 }
868 const terminators = this.regexes.map(el => el[1]);
869 this.matcherRe = langRe(join(terminators), true);
870 this.lastIndex = 0;
871 }
872
873 /** @param {string} s */
874 exec(s) {
875 this.matcherRe.lastIndex = this.lastIndex;
876 const match = this.matcherRe.exec(s);
877 if (!match) { return null; }
878
879 // eslint-disable-next-line no-undefined
880 const i = match.findIndex((el, i) => i > 0 && el !== undefined);
881 // @ts-ignore
882 const matchData = this.matchIndexes[i];
883 // trim off any earlier non-relevant match groups (ie, the other regex
884 // match groups that make up the multi-matcher)
885 match.splice(0, i);
886
887 return Object.assign(match, matchData);
888 }
889 }
890
891 /*
892 Created to solve the key deficiently with MultiRegex - there is no way to
893 test for multiple matches at a single location. Why would we need to do
894 that? In the future a more dynamic engine will allow certain matches to be
895 ignored. An example: if we matched say the 3rd regex in a large group but
896 decided to ignore it - we'd need to started testing again at the 4th
897 regex... but MultiRegex itself gives us no real way to do that.
898
899 So what this class creates MultiRegexs on the fly for whatever search
900 position they are needed.
901
902 NOTE: These additional MultiRegex objects are created dynamically. For most
903 grammars most of the time we will never actually need anything more than the
904 first MultiRegex - so this shouldn't have too much overhead.
905
906 Say this is our search group, and we match regex3, but wish to ignore it.
907
908 regex1 | regex2 | regex3 | regex4 | regex5 ' ie, startAt = 0
909
910 What we need is a new MultiRegex that only includes the remaining
911 possibilities:
912
913 regex4 | regex5 ' ie, startAt = 3
914
915 This class wraps all that complexity up in a simple API... `startAt` decides
916 where in the array of expressions to start doing the matching. It
917 auto-increments, so if a match is found at position 2, then startAt will be
918 set to 3. If the end is reached startAt will return to 0.
919
920 MOST of the time the parser will be setting startAt manually to 0.
921 */
922 class ResumableMultiRegex {
923 constructor() {
924 // @ts-ignore
925 this.rules = [];
926 // @ts-ignore
927 this.multiRegexes = [];
928 this.count = 0;
929
930 this.lastIndex = 0;
931 this.regexIndex = 0;
932 }
933
934 // @ts-ignore
935 getMatcher(index) {
936 if (this.multiRegexes[index]) return this.multiRegexes[index];
937
938 const matcher = new MultiRegex();
939 this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
940 matcher.compile();
941 this.multiRegexes[index] = matcher;
942 return matcher;
943 }
944
945 resumingScanAtSamePosition() {
946 return this.regexIndex !== 0;
947 }
948
949 considerAll() {
950 this.regexIndex = 0;
951 }
952
953 // @ts-ignore
954 addRule(re, opts) {
955 this.rules.push([re, opts]);
956 if (opts.type === "begin") this.count++;
957 }
958
959 /** @param {string} s */
960 exec(s) {
961 const m = this.getMatcher(this.regexIndex);
962 m.lastIndex = this.lastIndex;
963 let result = m.exec(s);
964
965 // The following is because we have no easy way to say "resume scanning at the
966 // existing position but also skip the current rule ONLY". What happens is
967 // all prior rules are also skipped which can result in matching the wrong
968 // thing. Example of matching "booger":
969
970 // our matcher is [string, "booger", number]
971 //
972 // ....booger....
973
974 // if "booger" is ignored then we'd really need a regex to scan from the
975 // SAME position for only: [string, number] but ignoring "booger" (if it
976 // was the first match), a simple resume would scan ahead who knows how
977 // far looking only for "number", ignoring potential string matches (or
978 // future "booger" matches that might be valid.)
979
980 // So what we do: We execute two matchers, one resuming at the same
981 // position, but the second full matcher starting at the position after:
982
983 // /--- resume first regex match here (for [number])
984 // |/---- full match here for [string, "booger", number]
985 // vv
986 // ....booger....
987
988 // Which ever results in a match first is then used. So this 3-4 step
989 // process essentially allows us to say "match at this position, excluding
990 // a prior rule that was ignored".
991 //
992 // 1. Match "booger" first, ignore. Also proves that [string] does non match.
993 // 2. Resume matching for [number]
994 // 3. Match at index + 1 for [string, "booger", number]
995 // 4. If #2 and #3 result in matches, which came first?
996 if (this.resumingScanAtSamePosition()) {
997 if (result && result.index === this.lastIndex) ; else { // use the second matcher result
998 const m2 = this.getMatcher(0);
999 m2.lastIndex = this.lastIndex + 1;
1000 result = m2.exec(s);
1001 }
1002 }
1003
1004 if (result) {
1005 this.regexIndex += result.position + 1;
1006 if (this.regexIndex === this.count) {
1007 // wrap-around to considering all matches again
1008 this.considerAll();
1009 }
1010 }
1011
1012 return result;
1013 }
1014 }
1015
1016 /**
1017 * Given a mode, builds a huge ResumableMultiRegex that can be used to walk
1018 * the content and find matches.
1019 *
1020 * @param {CompiledMode} mode
1021 * @returns {ResumableMultiRegex}
1022 */
1023 function buildModeRegex(mode) {
1024 const mm = new ResumableMultiRegex();
1025
1026 mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type: "begin" }));
1027
1028 if (mode.terminatorEnd) {
1029 mm.addRule(mode.terminatorEnd, { type: "end" });
1030 }
1031 if (mode.illegal) {
1032 mm.addRule(mode.illegal, { type: "illegal" });
1033 }
1034
1035 return mm;
1036 }
1037
1038 /** skip vs abort vs ignore
1039 *
1040 * @skip - The mode is still entered and exited normally (and contains rules apply),
1041 * but all content is held and added to the parent buffer rather than being
1042 * output when the mode ends. Mostly used with `sublanguage` to build up
1043 * a single large buffer than can be parsed by sublanguage.
1044 *
1045 * - The mode begin ands ends normally.
1046 * - Content matched is added to the parent mode buffer.
1047 * - The parser cursor is moved forward normally.
1048 *
1049 * @abort - A hack placeholder until we have ignore. Aborts the mode (as if it
1050 * never matched) but DOES NOT continue to match subsequent `contains`
1051 * modes. Abort is bad/suboptimal because it can result in modes
1052 * farther down not getting applied because an earlier rule eats the
1053 * content but then aborts.
1054 *
1055 * - The mode does not begin.
1056 * - Content matched by `begin` is added to the mode buffer.
1057 * - The parser cursor is moved forward accordingly.
1058 *
1059 * @ignore - Ignores the mode (as if it never matched) and continues to match any
1060 * subsequent `contains` modes. Ignore isn't technically possible with
1061 * the current parser implementation.
1062 *
1063 * - The mode does not begin.
1064 * - Content matched by `begin` is ignored.
1065 * - The parser cursor is not moved forward.
1066 */
1067
1068 /**
1069 * Compiles an individual mode
1070 *
1071 * This can raise an error if the mode contains certain detectable known logic
1072 * issues.
1073 * @param {Mode} mode
1074 * @param {CompiledMode | null} [parent]
1075 * @returns {CompiledMode | never}
1076 */
1077 function compileMode(mode, parent) {
1078 const cmode = /** @type CompiledMode */ (mode);
1079 if (mode.compiled) return cmode;
1080
1081 [
1082 // do this early so compiler extensions generally don't have to worry about
1083 // the distinction between match/begin
1084 compileMatch
1085 ].forEach(ext => ext(mode, parent));
1086
1087 language.compilerExtensions.forEach(ext => ext(mode, parent));
1088
1089 // __beforeBegin is considered private API, internal use only
1090 mode.__beforeBegin = null;
1091
1092 [
1093 beginKeywords,
1094 // do this later so compiler extensions that come earlier have access to the
1095 // raw array if they wanted to perhaps manipulate it, etc.
1096 compileIllegal,
1097 // default to 1 relevance if not specified
1098 compileRelevance
1099 ].forEach(ext => ext(mode, parent));
1100
1101 mode.compiled = true;
1102
1103 let keywordPattern = null;
1104 if (typeof mode.keywords === "object") {
1105 keywordPattern = mode.keywords.$pattern;
1106 delete mode.keywords.$pattern;
1107 }
1108
1109 if (mode.keywords) {
1110 mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
1111 }
1112
1113 // both are not allowed
1114 if (mode.lexemes && keywordPattern) {
1115 throw new Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ");
1116 }
1117
1118 // `mode.lexemes` was the old standard before we added and now recommend
1119 // using `keywords.$pattern` to pass the keyword pattern
1120 keywordPattern = keywordPattern || mode.lexemes || /\w+/;
1121 cmode.keywordPatternRe = langRe(keywordPattern, true);
1122
1123 if (parent) {
1124 if (!mode.begin) mode.begin = /\B|\b/;
1125 cmode.beginRe = langRe(mode.begin);
1126 if (mode.endSameAsBegin) mode.end = mode.begin;
1127 if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
1128 if (mode.end) cmode.endRe = langRe(mode.end);
1129 cmode.terminatorEnd = source(mode.end) || '';
1130 if (mode.endsWithParent && parent.terminatorEnd) {
1131 cmode.terminatorEnd += (mode.end ? '|' : '') + parent.terminatorEnd;
1132 }
1133 }
1134 if (mode.illegal) cmode.illegalRe = langRe(/** @type {RegExp | string} */ (mode.illegal));
1135 if (!mode.contains) mode.contains = [];
1136
1137 mode.contains = [].concat(...mode.contains.map(function(c) {
1138 return expandOrCloneMode(c === 'self' ? mode : c);
1139 }));
1140 mode.contains.forEach(function(c) { compileMode(/** @type Mode */ (c), cmode); });
1141
1142 if (mode.starts) {
1143 compileMode(mode.starts, parent);
1144 }
1145
1146 cmode.matcher = buildModeRegex(cmode);
1147 return cmode;
1148 }
1149
1150 if (!language.compilerExtensions) language.compilerExtensions = [];
1151
1152 // self is not valid at the top-level
1153 if (language.contains && language.contains.includes('self')) {
1154 throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
1155 }
1156
1157 // we need a null object, which inherit will guarantee
1158 language.classNameAliases = inherit(language.classNameAliases || {});
1159
1160 return compileMode(/** @type Mode */ (language));
1161 }
1162
1163 /**
1164 * Determines if a mode has a dependency on it's parent or not
1165 *
1166 * If a mode does have a parent dependency then often we need to clone it if
1167 * it's used in multiple places so that each copy points to the correct parent,
1168 * where-as modes without a parent can often safely be re-used at the bottom of
1169 * a mode chain.
1170 *
1171 * @param {Mode | null} mode
1172 * @returns {boolean} - is there a dependency on the parent?
1173 * */
1174 function dependencyOnParent(mode) {
1175 if (!mode) return false;
1176
1177 return mode.endsWithParent || dependencyOnParent(mode.starts);
1178 }
1179
1180 /**
1181 * Expands a mode or clones it if necessary
1182 *
1183 * This is necessary for modes with parental dependenceis (see notes on
1184 * `dependencyOnParent`) and for nodes that have `variants` - which must then be
1185 * exploded into their own individual modes at compile time.
1186 *
1187 * @param {Mode} mode
1188 * @returns {Mode | Mode[]}
1189 * */
1190 function expandOrCloneMode(mode) {
1191 if (mode.variants && !mode.cachedVariants) {
1192 mode.cachedVariants = mode.variants.map(function(variant) {
1193 return inherit(mode, { variants: null }, variant);
1194 });
1195 }
1196
1197 // EXPAND
1198 // if we have variants then essentially "replace" the mode with the variants
1199 // this happens in compileMode, where this function is called from
1200 if (mode.cachedVariants) {
1201 return mode.cachedVariants;
1202 }
1203
1204 // CLONE
1205 // if we have dependencies on parents then we need a unique
1206 // instance of ourselves, so we can be reused with many
1207 // different parents without issue
1208 if (dependencyOnParent(mode)) {
1209 return inherit(mode, { starts: mode.starts ? inherit(mode.starts) : null });
1210 }
1211
1212 if (Object.isFrozen(mode)) {
1213 return inherit(mode);
1214 }
1215
1216 // no special dependency issues, just return ourselves
1217 return mode;
1218 }
1219
1220 var version = "10.5.0";
1221
1222 // @ts-nocheck
1223
1224 function hasValueOrEmptyAttribute(value) {
1225 return Boolean(value || value === "");
1226 }
1227
1228 function BuildVuePlugin(hljs) {
1229 const Component = {
1230 props: ["language", "code", "autodetect"],
1231 data: function() {
1232 return {
1233 detectedLanguage: "",
1234 unknownLanguage: false
1235 };
1236 },
1237 computed: {
1238 className() {
1239 if (this.unknownLanguage) return "";
1240
1241 return "hljs " + this.detectedLanguage;
1242 },
1243 highlighted() {
1244 // no idea what language to use, return raw code
1245 if (!this.autoDetect && !hljs.getLanguage(this.language)) {
1246 console.warn(`The language "${this.language}" you specified could not be found.`);
1247 this.unknownLanguage = true;
1248 return escapeHTML(this.code);
1249 }
1250
1251 let result = {};
1252 if (this.autoDetect) {
1253 result = hljs.highlightAuto(this.code);
1254 this.detectedLanguage = result.language;
1255 } else {
1256 result = hljs.highlight(this.language, this.code, this.ignoreIllegals);
1257 this.detectedLanguage = this.language;
1258 }
1259 return result.value;
1260 },
1261 autoDetect() {
1262 return !this.language || hasValueOrEmptyAttribute(this.autodetect);
1263 },
1264 ignoreIllegals() {
1265 return true;
1266 }
1267 },
1268 // this avoids needing to use a whole Vue compilation pipeline just
1269 // to build Highlight.js
1270 render(createElement) {
1271 return createElement("pre", {}, [
1272 createElement("code", {
1273 class: this.className,
1274 domProps: { innerHTML: this.highlighted }
1275 })
1276 ]);
1277 }
1278 // template: `<pre><code :class="className" v-html="highlighted"></code></pre>`
1279 };
1280
1281 const VuePlugin = {
1282 install(Vue) {
1283 Vue.component('highlightjs', Component);
1284 }
1285 };
1286
1287 return { Component, VuePlugin };
1288 }
1289
1290 /* plugin itself */
1291
1292 /** @type {HLJSPlugin} */
1293 const mergeHTMLPlugin = {
1294 "after:highlightBlock": ({ block, result, text }) => {
1295 const originalStream = nodeStream(block);
1296 if (!originalStream.length) return;
1297
1298 const resultNode = document.createElement('div');
1299 resultNode.innerHTML = result.value;
1300 result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
1301 }
1302 };
1303
1304 /* Stream merging support functions */
1305
1306 /**
1307 * @typedef Event
1308 * @property {'start'|'stop'} event
1309 * @property {number} offset
1310 * @property {Node} node
1311 */
1312
1313 /**
1314 * @param {Node} node
1315 */
1316 function tag(node) {
1317 return node.nodeName.toLowerCase();
1318 }
1319
1320 /**
1321 * @param {Node} node
1322 */
1323 function nodeStream(node) {
1324 /** @type Event[] */
1325 const result = [];
1326 (function _nodeStream(node, offset) {
1327 for (let child = node.firstChild; child; child = child.nextSibling) {
1328 if (child.nodeType === 3) {
1329 offset += child.nodeValue.length;
1330 } else if (child.nodeType === 1) {
1331 result.push({
1332 event: 'start',
1333 offset: offset,
1334 node: child
1335 });
1336 offset = _nodeStream(child, offset);
1337 // Prevent void elements from having an end tag that would actually
1338 // double them in the output. There are more void elements in HTML
1339 // but we list only those realistically expected in code display.
1340 if (!tag(child).match(/br|hr|img|input/)) {
1341 result.push({
1342 event: 'stop',
1343 offset: offset,
1344 node: child
1345 });
1346 }
1347 }
1348 }
1349 return offset;
1350 })(node, 0);
1351 return result;
1352 }
1353
1354 /**
1355 * @param {any} original - the original stream
1356 * @param {any} highlighted - stream of the highlighted source
1357 * @param {string} value - the original source itself
1358 */
1359 function mergeStreams(original, highlighted, value) {
1360 let processed = 0;
1361 let result = '';
1362 const nodeStack = [];
1363
1364 function selectStream() {
1365 if (!original.length || !highlighted.length) {
1366 return original.length ? original : highlighted;
1367 }
1368 if (original[0].offset !== highlighted[0].offset) {
1369 return (original[0].offset < highlighted[0].offset) ? original : highlighted;
1370 }
1371
1372 /*
1373 To avoid starting the stream just before it should stop the order is
1374 ensured that original always starts first and closes last:
1375
1376 if (event1 == 'start' && event2 == 'start')
1377 return original;
1378 if (event1 == 'start' && event2 == 'stop')
1379 return highlighted;
1380 if (event1 == 'stop' && event2 == 'start')
1381 return original;
1382 if (event1 == 'stop' && event2 == 'stop')
1383 return highlighted;
1384
1385 ... which is collapsed to:
1386 */
1387 return highlighted[0].event === 'start' ? original : highlighted;
1388 }
1389
1390 /**
1391 * @param {Node} node
1392 */
1393 function open(node) {
1394 /** @param {Attr} attr */
1395 function attributeString(attr) {
1396 return ' ' + attr.nodeName + '="' + escapeHTML(attr.value) + '"';
1397 }
1398 // @ts-ignore
1399 result += '<' + tag(node) + [].map.call(node.attributes, attributeString).join('') + '>';
1400 }
1401
1402 /**
1403 * @param {Node} node
1404 */
1405 function close(node) {
1406 result += '</' + tag(node) + '>';
1407 }
1408
1409 /**
1410 * @param {Event} event
1411 */
1412 function render(event) {
1413 (event.event === 'start' ? open : close)(event.node);
1414 }
1415
1416 while (original.length || highlighted.length) {
1417 let stream = selectStream();
1418 result += escapeHTML(value.substring(processed, stream[0].offset));
1419 processed = stream[0].offset;
1420 if (stream === original) {
1421 /*
1422 On any opening or closing tag of the original markup we first close
1423 the entire highlighted node stack, then render the original tag along
1424 with all the following original tags at the same offset and then
1425 reopen all the tags on the highlighted stack.
1426 */
1427 nodeStack.reverse().forEach(close);
1428 do {
1429 render(stream.splice(0, 1)[0]);
1430 stream = selectStream();
1431 } while (stream === original && stream.length && stream[0].offset === processed);
1432 nodeStack.reverse().forEach(open);
1433 } else {
1434 if (stream[0].event === 'start') {
1435 nodeStack.push(stream[0].node);
1436 } else {
1437 nodeStack.pop();
1438 }
1439 render(stream.splice(0, 1)[0]);
1440 }
1441 }
1442 return result + escapeHTML(value.substr(processed));
1443 }
1444
1445 /*
1446
1447 For the reasoning behind this please see:
1448 https://github.com/highlightjs/highlight.js/issues/2880#issuecomment-747275419
1449
1450 */
1451
1452 /**
1453 * @param {string} message
1454 */
1455 const error = (message) => {
1456 console.error(message);
1457 };
1458
1459 /**
1460 * @param {string} message
1461 * @param {any} args
1462 */
1463 const warn = (message, ...args) => {
1464 console.log(`WARN: ${message}`, ...args);
1465 };
1466
1467 /**
1468 * @param {string} version
1469 * @param {string} message
1470 */
1471 const deprecated = (version, message) => {
1472 console.log(`Deprecated as of ${version}. ${message}`);
1473 };
1474
1475 /*
1476 Syntax highlighting with language autodetection.
1477 https://highlightjs.org/
1478 */
1479
1480 const escape$1 = escapeHTML;
1481 const inherit$1 = inherit;
1482 const NO_MATCH = Symbol("nomatch");
1483
1484 /**
1485 * @param {any} hljs - object that is extended (legacy)
1486 * @returns {HLJSApi}
1487 */
1488 const HLJS = function(hljs) {
1489 // Global internal variables used within the highlight.js library.
1490 /** @type {Record<string, Language>} */
1491 const languages = Object.create(null);
1492 /** @type {Record<string, string>} */
1493 const aliases = Object.create(null);
1494 /** @type {HLJSPlugin[]} */
1495 const plugins = [];
1496
1497 // safe/production mode - swallows more errors, tries to keep running
1498 // even if a single syntax or parse hits a fatal error
1499 let SAFE_MODE = true;
1500 const fixMarkupRe = /(^(<[^>]+>|\t|)+|\n)/gm;
1501 const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
1502 /** @type {Language} */
1503 const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] };
1504
1505 // Global options used when within external APIs. This is modified when
1506 // calling the `hljs.configure` function.
1507 /** @type HLJSOptions */
1508 let options = {
1509 noHighlightRe: /^(no-?highlight)$/i,
1510 languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
1511 classPrefix: 'hljs-',
1512 tabReplace: null,
1513 useBR: false,
1514 languages: null,
1515 // beta configuration options, subject to change, welcome to discuss
1516 // https://github.com/highlightjs/highlight.js/issues/1086
1517 __emitter: TokenTreeEmitter
1518 };
1519
1520 /* Utility functions */
1521
1522 /**
1523 * Tests a language name to see if highlighting should be skipped
1524 * @param {string} languageName
1525 */
1526 function shouldNotHighlight(languageName) {
1527 return options.noHighlightRe.test(languageName);
1528 }
1529
1530 /**
1531 * @param {HighlightedHTMLElement} block - the HTML element to determine language for
1532 */
1533 function blockLanguage(block) {
1534 let classes = block.className + ' ';
1535
1536 classes += block.parentNode ? block.parentNode.className : '';
1537
1538 // language-* takes precedence over non-prefixed class names.
1539 const match = options.languageDetectRe.exec(classes);
1540 if (match) {
1541 const language = getLanguage(match[1]);
1542 if (!language) {
1543 warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
1544 warn("Falling back to no-highlight mode for this block.", block);
1545 }
1546 return language ? match[1] : 'no-highlight';
1547 }
1548
1549 return classes
1550 .split(/\s+/)
1551 .find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
1552 }
1553
1554 /**
1555 * Core highlighting function.
1556 *
1557 * @param {string} languageName - the language to use for highlighting
1558 * @param {string} code - the code to highlight
1559 * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1560 * @param {CompiledMode} [continuation] - current continuation mode, if any
1561 *
1562 * @returns {HighlightResult} Result - an object that represents the result
1563 * @property {string} language - the language name
1564 * @property {number} relevance - the relevance score
1565 * @property {string} value - the highlighted HTML code
1566 * @property {string} code - the original raw code
1567 * @property {CompiledMode} top - top of the current mode stack
1568 * @property {boolean} illegal - indicates whether any illegal matches were found
1569 */
1570 function highlight(languageName, code, ignoreIllegals, continuation) {
1571 /** @type {BeforeHighlightContext} */
1572 const context = {
1573 code,
1574 language: languageName
1575 };
1576 // the plugin can change the desired language or the code to be highlighted
1577 // just be changing the object it was passed
1578 fire("before:highlight", context);
1579
1580 // a before plugin can usurp the result completely by providing it's own
1581 // in which case we don't even need to call highlight
1582 const result = context.result ?
1583 context.result :
1584 _highlight(context.language, context.code, ignoreIllegals, continuation);
1585
1586 result.code = context.code;
1587 // the plugin can change anything in result to suite it
1588 fire("after:highlight", result);
1589
1590 return result;
1591 }
1592
1593 /**
1594 * private highlight that's used internally and does not fire callbacks
1595 *
1596 * @param {string} languageName - the language to use for highlighting
1597 * @param {string} code - the code to highlight
1598 * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1599 * @param {CompiledMode} [continuation] - current continuation mode, if any
1600 * @returns {HighlightResult} - result of the highlight operation
1601 */
1602 function _highlight(languageName, code, ignoreIllegals, continuation) {
1603 const codeToHighlight = code;
1604
1605 /**
1606 * Return keyword data if a match is a keyword
1607 * @param {CompiledMode} mode - current mode
1608 * @param {RegExpMatchArray} match - regexp match data
1609 * @returns {KeywordData | false}
1610 */
1611 function keywordData(mode, match) {
1612 const matchText = language.case_insensitive ? match[0].toLowerCase() : match[0];
1613 return Object.prototype.hasOwnProperty.call(mode.keywords, matchText) && mode.keywords[matchText];
1614 }
1615
1616 function processKeywords() {
1617 if (!top.keywords) {
1618 emitter.addText(modeBuffer);
1619 return;
1620 }
1621
1622 let lastIndex = 0;
1623 top.keywordPatternRe.lastIndex = 0;
1624 let match = top.keywordPatternRe.exec(modeBuffer);
1625 let buf = "";
1626
1627 while (match) {
1628 buf += modeBuffer.substring(lastIndex, match.index);
1629 const data = keywordData(top, match);
1630 if (data) {
1631 const [kind, keywordRelevance] = data;
1632 emitter.addText(buf);
1633 buf = "";
1634
1635 relevance += keywordRelevance;
1636 const cssClass = language.classNameAliases[kind] || kind;
1637 emitter.addKeyword(match[0], cssClass);
1638 } else {
1639 buf += match[0];
1640 }
1641 lastIndex = top.keywordPatternRe.lastIndex;
1642 match = top.keywordPatternRe.exec(modeBuffer);
1643 }
1644 buf += modeBuffer.substr(lastIndex);
1645 emitter.addText(buf);
1646 }
1647
1648 function processSubLanguage() {
1649 if (modeBuffer === "") return;
1650 /** @type HighlightResult */
1651 let result = null;
1652
1653 if (typeof top.subLanguage === 'string') {
1654 if (!languages[top.subLanguage]) {
1655 emitter.addText(modeBuffer);
1656 return;
1657 }
1658 result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1659 continuations[top.subLanguage] = /** @type {CompiledMode} */ (result.top);
1660 } else {
1661 result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1662 }
1663
1664 // Counting embedded language score towards the host language may be disabled
1665 // with zeroing the containing mode relevance. Use case in point is Markdown that
1666 // allows XML everywhere and makes every XML snippet to have a much larger Markdown
1667 // score.
1668 if (top.relevance > 0) {
1669 relevance += result.relevance;
1670 }
1671 emitter.addSublanguage(result.emitter, result.language);
1672 }
1673
1674 function processBuffer() {
1675 if (top.subLanguage != null) {
1676 processSubLanguage();
1677 } else {
1678 processKeywords();
1679 }
1680 modeBuffer = '';
1681 }
1682
1683 /**
1684 * @param {Mode} mode - new mode to start
1685 */
1686 function startNewMode(mode) {
1687 if (mode.className) {
1688 emitter.openNode(language.classNameAliases[mode.className] || mode.className);
1689 }
1690 top = Object.create(mode, { parent: { value: top } });
1691 return top;
1692 }
1693
1694 /**
1695 * @param {CompiledMode } mode - the mode to potentially end
1696 * @param {RegExpMatchArray} match - the latest match
1697 * @param {string} matchPlusRemainder - match plus remainder of content
1698 * @returns {CompiledMode | void} - the next mode, or if void continue on in current mode
1699 */
1700 function endOfMode(mode, match, matchPlusRemainder) {
1701 let matched = startsWith(mode.endRe, matchPlusRemainder);
1702
1703 if (matched) {
1704 if (mode["on:end"]) {
1705 const resp = new Response(mode);
1706 mode["on:end"](match, resp);
1707 if (resp.ignore) matched = false;
1708 }
1709
1710 if (matched) {
1711 while (mode.endsParent && mode.parent) {
1712 mode = mode.parent;
1713 }
1714 return mode;
1715 }
1716 }
1717 // even if on:end fires an `ignore` it's still possible
1718 // that we might trigger the end node because of a parent mode
1719 if (mode.endsWithParent) {
1720 return endOfMode(mode.parent, match, matchPlusRemainder);
1721 }
1722 }
1723
1724 /**
1725 * Handle matching but then ignoring a sequence of text
1726 *
1727 * @param {string} lexeme - string containing full match text
1728 */
1729 function doIgnore(lexeme) {
1730 if (top.matcher.regexIndex === 0) {
1731 // no more regexs to potentially match here, so we move the cursor forward one
1732 // space
1733 modeBuffer += lexeme[0];
1734 return 1;
1735 } else {
1736 // no need to move the cursor, we still have additional regexes to try and
1737 // match at this very spot
1738 resumeScanAtSamePosition = true;
1739 return 0;
1740 }
1741 }
1742
1743 /**
1744 * Handle the start of a new potential mode match
1745 *
1746 * @param {EnhancedMatch} match - the current match
1747 * @returns {number} how far to advance the parse cursor
1748 */
1749 function doBeginMatch(match) {
1750 const lexeme = match[0];
1751 const newMode = match.rule;
1752
1753 const resp = new Response(newMode);
1754 // first internal before callbacks, then the public ones
1755 const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1756 for (const cb of beforeCallbacks) {
1757 if (!cb) continue;
1758 cb(match, resp);
1759 if (resp.ignore) return doIgnore(lexeme);
1760 }
1761
1762 if (newMode && newMode.endSameAsBegin) {
1763 newMode.endRe = escape(lexeme);
1764 }
1765
1766 if (newMode.skip) {
1767 modeBuffer += lexeme;
1768 } else {
1769 if (newMode.excludeBegin) {
1770 modeBuffer += lexeme;
1771 }
1772 processBuffer();
1773 if (!newMode.returnBegin && !newMode.excludeBegin) {
1774 modeBuffer = lexeme;
1775 }
1776 }
1777 startNewMode(newMode);
1778 // if (mode["after:begin"]) {
1779 // let resp = new Response(mode);
1780 // mode["after:begin"](match, resp);
1781 // }
1782 return newMode.returnBegin ? 0 : lexeme.length;
1783 }
1784
1785 /**
1786 * Handle the potential end of mode
1787 *
1788 * @param {RegExpMatchArray} match - the current match
1789 */
1790 function doEndMatch(match) {
1791 const lexeme = match[0];
1792 const matchPlusRemainder = codeToHighlight.substr(match.index);
1793
1794 const endMode = endOfMode(top, match, matchPlusRemainder);
1795 if (!endMode) { return NO_MATCH; }
1796
1797 const origin = top;
1798 if (origin.skip) {
1799 modeBuffer += lexeme;
1800 } else {
1801 if (!(origin.returnEnd || origin.excludeEnd)) {
1802 modeBuffer += lexeme;
1803 }
1804 processBuffer();
1805 if (origin.excludeEnd) {
1806 modeBuffer = lexeme;
1807 }
1808 }
1809 do {
1810 if (top.className) {
1811 emitter.closeNode();
1812 }
1813 if (!top.skip && !top.subLanguage) {
1814 relevance += top.relevance;
1815 }
1816 top = top.parent;
1817 } while (top !== endMode.parent);
1818 if (endMode.starts) {
1819 if (endMode.endSameAsBegin) {
1820 endMode.starts.endRe = endMode.endRe;
1821 }
1822 startNewMode(endMode.starts);
1823 }
1824 return origin.returnEnd ? 0 : lexeme.length;
1825 }
1826
1827 function processContinuations() {
1828 const list = [];
1829 for (let current = top; current !== language; current = current.parent) {
1830 if (current.className) {
1831 list.unshift(current.className);
1832 }
1833 }
1834 list.forEach(item => emitter.openNode(item));
1835 }
1836
1837 /** @type {{type?: MatchType, index?: number, rule?: Mode}}} */
1838 let lastMatch = {};
1839
1840 /**
1841 * Process an individual match
1842 *
1843 * @param {string} textBeforeMatch - text preceeding the match (since the last match)
1844 * @param {EnhancedMatch} [match] - the match itself
1845 */
1846 function processLexeme(textBeforeMatch, match) {
1847 const lexeme = match && match[0];
1848
1849 // add non-matched text to the current mode buffer
1850 modeBuffer += textBeforeMatch;
1851
1852 if (lexeme == null) {
1853 processBuffer();
1854 return 0;
1855 }
1856
1857 // we've found a 0 width match and we're stuck, so we need to advance
1858 // this happens when we have badly behaved rules that have optional matchers to the degree that
1859 // sometimes they can end up matching nothing at all
1860 // Ref: https://github.com/highlightjs/highlight.js/issues/2140
1861 if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1862 // spit the "skipped" character that our regex choked on back into the output sequence
1863 modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1864 if (!SAFE_MODE) {
1865 /** @type {AnnotatedError} */
1866 const err = new Error('0 width match regex');
1867 err.languageName = languageName;
1868 err.badRule = lastMatch.rule;
1869 throw err;
1870 }
1871 return 1;
1872 }
1873 lastMatch = match;
1874
1875 if (match.type === "begin") {
1876 return doBeginMatch(match);
1877 } else if (match.type === "illegal" && !ignoreIllegals) {
1878 // illegal match, we do not continue processing
1879 /** @type {AnnotatedError} */
1880 const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
1881 err.mode = top;
1882 throw err;
1883 } else if (match.type === "end") {
1884 const processed = doEndMatch(match);
1885 if (processed !== NO_MATCH) {
1886 return processed;
1887 }
1888 }
1889
1890 // edge case for when illegal matches $ (end of line) which is technically
1891 // a 0 width match but not a begin/end match so it's not caught by the
1892 // first handler (when ignoreIllegals is true)
1893 if (match.type === "illegal" && lexeme === "") {
1894 // advance so we aren't stuck in an infinite loop
1895 return 1;
1896 }
1897
1898 // infinite loops are BAD, this is a last ditch catch all. if we have a
1899 // decent number of iterations yet our index (cursor position in our
1900 // parsing) still 3x behind our index then something is very wrong
1901 // so we bail
1902 if (iterations > 100000 && iterations > match.index * 3) {
1903 const err = new Error('potential infinite loop, way more iterations than matches');
1904 throw err;
1905 }
1906
1907 /*
1908 Why might be find ourselves here? Only one occasion now. An end match that was
1909 triggered but could not be completed. When might this happen? When an `endSameasBegin`
1910 rule sets the end rule to a specific match. Since the overall mode termination rule that's
1911 being used to scan the text isn't recompiled that means that any match that LOOKS like
1912 the end (but is not, because it is not an exact match to the beginning) will
1913 end up here. A definite end match, but when `doEndMatch` tries to "reapply"
1914 the end rule and fails to match, we wind up here, and just silently ignore the end.
1915
1916 This causes no real harm other than stopping a few times too many.
1917 */
1918
1919 modeBuffer += lexeme;
1920 return lexeme.length;
1921 }
1922
1923 const language = getLanguage(languageName);
1924 if (!language) {
1925 error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1926 throw new Error('Unknown language: "' + languageName + '"');
1927 }
1928
1929 const md = compileLanguage(language, { plugins });
1930 let result = '';
1931 /** @type {CompiledMode} */
1932 let top = continuation || md;
1933 /** @type Record<string,CompiledMode> */
1934 const continuations = {}; // keep continuations for sub-languages
1935 const emitter = new options.__emitter(options);
1936 processContinuations();
1937 let modeBuffer = '';
1938 let relevance = 0;
1939 let index = 0;
1940 let iterations = 0;
1941 let resumeScanAtSamePosition = false;
1942
1943 try {
1944 top.matcher.considerAll();
1945
1946 for (;;) {
1947 iterations++;
1948 if (resumeScanAtSamePosition) {
1949 // only regexes not matched previously will now be
1950 // considered for a potential match
1951 resumeScanAtSamePosition = false;
1952 } else {
1953 top.matcher.considerAll();
1954 }
1955 top.matcher.lastIndex = index;
1956
1957 const match = top.matcher.exec(codeToHighlight);
1958 // console.log("match", match[0], match.rule && match.rule.begin)
1959
1960 if (!match) break;
1961
1962 const beforeMatch = codeToHighlight.substring(index, match.index);
1963 const processedCount = processLexeme(beforeMatch, match);
1964 index = match.index + processedCount;
1965 }
1966 processLexeme(codeToHighlight.substr(index));
1967 emitter.closeAllNodes();
1968 emitter.finalize();
1969 result = emitter.toHTML();
1970
1971 return {
1972 relevance: relevance,
1973 value: result,
1974 language: languageName,
1975 illegal: false,
1976 emitter: emitter,
1977 top: top
1978 };
1979 } catch (err) {
1980 if (err.message && err.message.includes('Illegal')) {
1981 return {
1982 illegal: true,
1983 illegalBy: {
1984 msg: err.message,
1985 context: codeToHighlight.slice(index - 100, index + 100),
1986 mode: err.mode
1987 },
1988 sofar: result,
1989 relevance: 0,
1990 value: escape$1(codeToHighlight),
1991 emitter: emitter
1992 };
1993 } else if (SAFE_MODE) {
1994 return {
1995 illegal: false,
1996 relevance: 0,
1997 value: escape$1(codeToHighlight),
1998 emitter: emitter,
1999 language: languageName,
2000 top: top,
2001 errorRaised: err
2002 };
2003 } else {
2004 throw err;
2005 }
2006 }
2007 }
2008
2009 /**
2010 * returns a valid highlight result, without actually doing any actual work,
2011 * auto highlight starts with this and it's possible for small snippets that
2012 * auto-detection may not find a better match
2013 * @param {string} code
2014 * @returns {HighlightResult}
2015 */
2016 function justTextHighlightResult(code) {
2017 const result = {
2018 relevance: 0,
2019 emitter: new options.__emitter(options),
2020 value: escape$1(code),
2021 illegal: false,
2022 top: PLAINTEXT_LANGUAGE
2023 };
2024 result.emitter.addText(code);
2025 return result;
2026 }
2027
2028 /**
2029 Highlighting with language detection. Accepts a string with the code to
2030 highlight. Returns an object with the following properties:
2031
2032 - language (detected language)
2033 - relevance (int)
2034 - value (an HTML string with highlighting markup)
2035 - second_best (object with the same structure for second-best heuristically
2036 detected language, may be absent)
2037
2038 @param {string} code
2039 @param {Array<string>} [languageSubset]
2040 @returns {AutoHighlightResult}
2041 */
2042 function highlightAuto(code, languageSubset) {
2043 languageSubset = languageSubset || options.languages || Object.keys(languages);
2044 const plaintext = justTextHighlightResult(code);
2045
2046 const results = languageSubset.filter(getLanguage).filter(autoDetection).map(name =>
2047 _highlight(name, code, false)
2048 );
2049 results.unshift(plaintext); // plaintext is always an option
2050
2051 const sorted = results.sort((a, b) => {
2052 // sort base on relevance
2053 if (a.relevance !== b.relevance) return b.relevance - a.relevance;
2054
2055 // always award the tie to the base language
2056 // ie if C++ and Arduino are tied, it's more likely to be C++
2057 if (a.language && b.language) {
2058 if (getLanguage(a.language).supersetOf === b.language) {
2059 return 1;
2060 } else if (getLanguage(b.language).supersetOf === a.language) {
2061 return -1;
2062 }
2063 }
2064
2065 // otherwise say they are equal, which has the effect of sorting on
2066 // relevance while preserving the original ordering - which is how ties
2067 // have historically been settled, ie the language that comes first always
2068 // wins in the case of a tie
2069 return 0;
2070 });
2071
2072 const [best, secondBest] = sorted;
2073
2074 /** @type {AutoHighlightResult} */
2075 const result = best;
2076 result.second_best = secondBest;
2077
2078 return result;
2079 }
2080
2081 /**
2082 Post-processing of the highlighted markup:
2083
2084 - replace TABs with something more useful
2085 - replace real line-breaks with '<br>' for non-pre containers
2086
2087 @param {string} html
2088 @returns {string}
2089 */
2090 function fixMarkup(html) {
2091 if (!(options.tabReplace || options.useBR)) {
2092 return html;
2093 }
2094
2095 return html.replace(fixMarkupRe, match => {
2096 if (match === '\n') {
2097 return options.useBR ? '<br>' : match;
2098 } else if (options.tabReplace) {
2099 return match.replace(/\t/g, options.tabReplace);
2100 }
2101 return match;
2102 });
2103 }
2104
2105 /**
2106 * Builds new class name for block given the language name
2107 *
2108 * @param {HTMLElement} element
2109 * @param {string} [currentLang]
2110 * @param {string} [resultLang]
2111 */
2112 function updateClassName(element, currentLang, resultLang) {
2113 const language = currentLang ? aliases[currentLang] : resultLang;
2114
2115 element.classList.add("hljs");
2116 if (language) element.classList.add(language);
2117 }
2118
2119 /** @type {HLJSPlugin} */
2120 const brPlugin = {
2121 "before:highlightBlock": ({ block }) => {
2122 if (options.useBR) {
2123 block.innerHTML = block.innerHTML.replace(/\n/g, '').replace(/<br[ /]*>/g, '\n');
2124 }
2125 },
2126 "after:highlightBlock": ({ result }) => {
2127 if (options.useBR) {
2128 result.value = result.value.replace(/\n/g, "<br>");
2129 }
2130 }
2131 };
2132
2133 const TAB_REPLACE_RE = /^(<[^>]+>|\t)+/gm;
2134 /** @type {HLJSPlugin} */
2135 const tabReplacePlugin = {
2136 "after:highlightBlock": ({ result }) => {
2137 if (options.tabReplace) {
2138 result.value = result.value.replace(TAB_REPLACE_RE, (m) =>
2139 m.replace(/\t/g, options.tabReplace)
2140 );
2141 }
2142 }
2143 };
2144
2145 /**
2146 * Applies highlighting to a DOM node containing code. Accepts a DOM node and
2147 * two optional parameters for fixMarkup.
2148 *
2149 * @param {HighlightedHTMLElement} element - the HTML element to highlight
2150 */
2151 function highlightBlock(element) {
2152 /** @type HTMLElement */
2153 let node = null;
2154 const language = blockLanguage(element);
2155
2156 if (shouldNotHighlight(language)) return;
2157
2158 fire("before:highlightBlock",
2159 { block: element, language: language });
2160
2161 node = element;
2162 const text = node.textContent;
2163 const result = language ? highlight(language, text, true) : highlightAuto(text);
2164
2165 fire("after:highlightBlock", { block: element, result, text });
2166
2167 element.innerHTML = result.value;
2168 updateClassName(element, language, result.language);
2169 element.result = {
2170 language: result.language,
2171 // TODO: remove with version 11.0
2172 re: result.relevance,
2173 relavance: result.relevance
2174 };
2175 if (result.second_best) {
2176 element.second_best = {
2177 language: result.second_best.language,
2178 // TODO: remove with version 11.0
2179 re: result.second_best.relevance,
2180 relavance: result.second_best.relevance
2181 };
2182 }
2183 }
2184
2185 /**
2186 * Updates highlight.js global options with the passed options
2187 *
2188 * @param {Partial<HLJSOptions>} userOptions
2189 */
2190 function configure(userOptions) {
2191 if (userOptions.useBR) {
2192 deprecated("10.3.0", "'useBR' will be removed entirely in v11.0");
2193 deprecated("10.3.0", "Please see https://github.com/highlightjs/highlight.js/issues/2559");
2194 }
2195 options = inherit$1(options, userOptions);
2196 }
2197
2198 /**
2199 * Highlights to all <pre><code> blocks on a page
2200 *
2201 * @type {Function & {called?: boolean}}
2202 */
2203 const initHighlighting = () => {
2204 if (initHighlighting.called) return;
2205 initHighlighting.called = true;
2206
2207 const blocks = document.querySelectorAll('pre code');
2208 blocks.forEach(highlightBlock);
2209 };
2210
2211 // Higlights all when DOMContentLoaded fires
2212 function initHighlightingOnLoad() {
2213 // @ts-ignore
2214 window.addEventListener('DOMContentLoaded', initHighlighting, false);
2215 }
2216
2217 /**
2218 * Register a language grammar module
2219 *
2220 * @param {string} languageName
2221 * @param {LanguageFn} languageDefinition
2222 */
2223 function registerLanguage(languageName, languageDefinition) {
2224 let lang = null;
2225 try {
2226 lang = languageDefinition(hljs);
2227 } catch (error$1) {
2228 error("Language definition for '{}' could not be registered.".replace("{}", languageName));
2229 // hard or soft error
2230 if (!SAFE_MODE) { throw error$1; } else { error(error$1); }
2231 // languages that have serious errors are replaced with essentially a
2232 // "plaintext" stand-in so that the code blocks will still get normal
2233 // css classes applied to them - and one bad language won't break the
2234 // entire highlighter
2235 lang = PLAINTEXT_LANGUAGE;
2236 }
2237 // give it a temporary name if it doesn't have one in the meta-data
2238 if (!lang.name) lang.name = languageName;
2239 languages[languageName] = lang;
2240 lang.rawDefinition = languageDefinition.bind(null, hljs);
2241
2242 if (lang.aliases) {
2243 registerAliases(lang.aliases, { languageName });
2244 }
2245 }
2246
2247 /**
2248 * @returns {string[]} List of language internal names
2249 */
2250 function listLanguages() {
2251 return Object.keys(languages);
2252 }
2253
2254 /**
2255 intended usage: When one language truly requires another
2256
2257 Unlike `getLanguage`, this will throw when the requested language
2258 is not available.
2259
2260 @param {string} name - name of the language to fetch/require
2261 @returns {Language | never}
2262 */
2263 function requireLanguage(name) {
2264 deprecated("10.4.0", "requireLanguage will be removed entirely in v11.");
2265 deprecated("10.4.0", "Please see https://github.com/highlightjs/highlight.js/pull/2844");
2266
2267 const lang = getLanguage(name);
2268 if (lang) { return lang; }
2269
2270 const err = new Error('The \'{}\' language is required, but not loaded.'.replace('{}', name));
2271 throw err;
2272 }
2273
2274 /**
2275 * @param {string} name - name of the language to retrieve
2276 * @returns {Language | undefined}
2277 */
2278 function getLanguage(name) {
2279 name = (name || '').toLowerCase();
2280 return languages[name] || languages[aliases[name]];
2281 }
2282
2283 /**
2284 *
2285 * @param {string|string[]} aliasList - single alias or list of aliases
2286 * @param {{languageName: string}} opts
2287 */
2288 function registerAliases(aliasList, { languageName }) {
2289 if (typeof aliasList === 'string') {
2290 aliasList = [aliasList];
2291 }
2292 aliasList.forEach(alias => { aliases[alias] = languageName; });
2293 }
2294
2295 /**
2296 * Determines if a given language has auto-detection enabled
2297 * @param {string} name - name of the language
2298 */
2299 function autoDetection(name) {
2300 const lang = getLanguage(name);
2301 return lang && !lang.disableAutodetect;
2302 }
2303
2304 /**
2305 * @param {HLJSPlugin} plugin
2306 */
2307 function addPlugin(plugin) {
2308 plugins.push(plugin);
2309 }
2310
2311 /**
2312 *
2313 * @param {PluginEvent} event
2314 * @param {any} args
2315 */
2316 function fire(event, args) {
2317 const cb = event;
2318 plugins.forEach(function(plugin) {
2319 if (plugin[cb]) {
2320 plugin[cb](args);
2321 }
2322 });
2323 }
2324
2325 /**
2326 Note: fixMarkup is deprecated and will be removed entirely in v11
2327
2328 @param {string} arg
2329 @returns {string}
2330 */
2331 function deprecateFixMarkup(arg) {
2332 deprecated("10.2.0", "fixMarkup will be removed entirely in v11.0");
2333 deprecated("10.2.0", "Please see https://github.com/highlightjs/highlight.js/issues/2534");
2334
2335 return fixMarkup(arg);
2336 }
2337
2338 /* Interface definition */
2339 Object.assign(hljs, {
2340 highlight,
2341 highlightAuto,
2342 fixMarkup: deprecateFixMarkup,
2343 highlightBlock,
2344 configure,
2345 initHighlighting,
2346 initHighlightingOnLoad,
2347 registerLanguage,
2348 listLanguages,
2349 getLanguage,
2350 registerAliases,
2351 requireLanguage,
2352 autoDetection,
2353 inherit: inherit$1,
2354 addPlugin,
2355 // plugins for frameworks
2356 vuePlugin: BuildVuePlugin(hljs).VuePlugin
2357 });
2358
2359 hljs.debugMode = function() { SAFE_MODE = false; };
2360 hljs.safeMode = function() { SAFE_MODE = true; };
2361 hljs.versionString = version;
2362
2363 for (const key in MODES) {
2364 // @ts-ignore
2365 if (typeof MODES[key] === "object") {
2366 // @ts-ignore
2367 deepFreezeEs6(MODES[key]);
2368 }
2369 }
2370
2371 // merge all the modes/regexs into our main object
2372 Object.assign(hljs, MODES);
2373
2374 // built-in plugins, likely to be moved out of core in the future
2375 hljs.addPlugin(brPlugin); // slated to be removed in v11
2376 hljs.addPlugin(mergeHTMLPlugin);
2377 hljs.addPlugin(tabReplacePlugin);
2378 return hljs;
2379 };
2380
2381 // export an "instance" of the highlighter
2382 var highlight = HLJS({});
2383
2384 return highlight;
2385
2386}());
2387if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = hljs; }
2388
2389hljs.registerLanguage('apache', function () {
2390 'use strict';
2391
2392 /*
2393 Language: Apache config
2394 Author: Ruslan Keba <rukeba@gmail.com>
2395 Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
2396 Website: https://httpd.apache.org
2397 Description: language definition for Apache configuration files (httpd.conf & .htaccess)
2398 Category: common, config
2399 Audit: 2020
2400 */
2401
2402 /** @type LanguageFn */
2403 function apache(hljs) {
2404 const NUMBER_REF = {
2405 className: 'number',
2406 begin: /[$%]\d+/
2407 };
2408 const NUMBER = {
2409 className: 'number',
2410 begin: /\d+/
2411 };
2412 const IP_ADDRESS = {
2413 className: "number",
2414 begin: /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?/
2415 };
2416 const PORT_NUMBER = {
2417 className: "number",
2418 begin: /:\d{1,5}/
2419 };
2420 return {
2421 name: 'Apache config',
2422 aliases: [ 'apacheconf' ],
2423 case_insensitive: true,
2424 contains: [
2425 hljs.HASH_COMMENT_MODE,
2426 {
2427 className: 'section',
2428 begin: /<\/?/,
2429 end: />/,
2430 contains: [
2431 IP_ADDRESS,
2432 PORT_NUMBER,
2433 // low relevance prevents us from claming XML/HTML where this rule would
2434 // match strings inside of XML tags
2435 hljs.inherit(hljs.QUOTE_STRING_MODE, { relevance: 0 })
2436 ]
2437 },
2438 {
2439 className: 'attribute',
2440 begin: /\w+/,
2441 relevance: 0,
2442 // keywords aren’t needed for highlighting per se, they only boost relevance
2443 // for a very generally defined mode (starts with a word, ends with line-end
2444 keywords: {
2445 nomarkup:
2446 'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
2447 'sethandler errordocument loadmodule options header listen serverroot ' +
2448 'servername'
2449 },
2450 starts: {
2451 end: /$/,
2452 relevance: 0,
2453 keywords: { literal: 'on off all deny allow' },
2454 contains: [
2455 {
2456 className: 'meta',
2457 begin: /\s\[/,
2458 end: /\]$/
2459 },
2460 {
2461 className: 'variable',
2462 begin: /[\$%]\{/,
2463 end: /\}/,
2464 contains: [
2465 'self',
2466 NUMBER_REF
2467 ]
2468 },
2469 IP_ADDRESS,
2470 NUMBER,
2471 hljs.QUOTE_STRING_MODE
2472 ]
2473 }
2474 }
2475 ],
2476 illegal: /\S/
2477 };
2478 }
2479
2480 return apache;
2481
2482 return module.exports.definer || module.exports;
2483
2484}());
2485
2486hljs.registerLanguage('bash', function () {
2487 'use strict';
2488
2489 /**
2490 * @param {string} value
2491 * @returns {RegExp}
2492 * */
2493
2494 /**
2495 * @param {RegExp | string } re
2496 * @returns {string}
2497 */
2498 function source(re) {
2499 if (!re) return null;
2500 if (typeof re === "string") return re;
2501
2502 return re.source;
2503 }
2504
2505 /**
2506 * @param {...(RegExp | string) } args
2507 * @returns {string}
2508 */
2509 function concat(...args) {
2510 const joined = args.map((x) => source(x)).join("");
2511 return joined;
2512 }
2513
2514 /*
2515 Language: Bash
2516 Author: vah <vahtenberg@gmail.com>
2517 Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
2518 Website: https://www.gnu.org/software/bash/
2519 Category: common
2520 */
2521
2522 /** @type LanguageFn */
2523 function bash(hljs) {
2524 const VAR = {};
2525 const BRACED_VAR = {
2526 begin: /\$\{/,
2527 end:/\}/,
2528 contains: [
2529 "self",
2530 {
2531 begin: /:-/,
2532 contains: [ VAR ]
2533 } // default values
2534 ]
2535 };
2536 Object.assign(VAR,{
2537 className: 'variable',
2538 variants: [
2539 {begin: concat(/\$[\w\d#@][\w\d_]*/,
2540 // negative look-ahead tries to avoid matching patterns that are not
2541 // Perl at all like $ident$, @ident@, etc.
2542 `(?![\\w\\d])(?![$])`) },
2543 BRACED_VAR
2544 ]
2545 });
2546
2547 const SUBST = {
2548 className: 'subst',
2549 begin: /\$\(/, end: /\)/,
2550 contains: [hljs.BACKSLASH_ESCAPE]
2551 };
2552 const HERE_DOC = {
2553 begin: /<<-?\s*(?=\w+)/,
2554 starts: {
2555 contains: [
2556 hljs.END_SAME_AS_BEGIN({
2557 begin: /(\w+)/,
2558 end: /(\w+)/,
2559 className: 'string'
2560 })
2561 ]
2562 }
2563 };
2564 const QUOTE_STRING = {
2565 className: 'string',
2566 begin: /"/, end: /"/,
2567 contains: [
2568 hljs.BACKSLASH_ESCAPE,
2569 VAR,
2570 SUBST
2571 ]
2572 };
2573 SUBST.contains.push(QUOTE_STRING);
2574 const ESCAPED_QUOTE = {
2575 className: '',
2576 begin: /\\"/
2577
2578 };
2579 const APOS_STRING = {
2580 className: 'string',
2581 begin: /'/, end: /'/
2582 };
2583 const ARITHMETIC = {
2584 begin: /\$\(\(/,
2585 end: /\)\)/,
2586 contains: [
2587 { begin: /\d+#[0-9a-f]+/, className: "number" },
2588 hljs.NUMBER_MODE,
2589 VAR
2590 ]
2591 };
2592 const SH_LIKE_SHELLS = [
2593 "fish",
2594 "bash",
2595 "zsh",
2596 "sh",
2597 "csh",
2598 "ksh",
2599 "tcsh",
2600 "dash",
2601 "scsh",
2602 ];
2603 const KNOWN_SHEBANG = hljs.SHEBANG({
2604 binary: `(${SH_LIKE_SHELLS.join("|")})`,
2605 relevance: 10
2606 });
2607 const FUNCTION = {
2608 className: 'function',
2609 begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
2610 returnBegin: true,
2611 contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
2612 relevance: 0
2613 };
2614
2615 return {
2616 name: 'Bash',
2617 aliases: ['sh', 'zsh'],
2618 keywords: {
2619 $pattern: /\b[a-z._-]+\b/,
2620 keyword:
2621 'if then else elif fi for while in do done case esac function',
2622 literal:
2623 'true false',
2624 built_in:
2625 // Shell built-ins
2626 // http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
2627 'break cd continue eval exec exit export getopts hash pwd readonly return shift test times ' +
2628 'trap umask unset ' +
2629 // Bash built-ins
2630 'alias bind builtin caller command declare echo enable help let local logout mapfile printf ' +
2631 'read readarray source type typeset ulimit unalias ' +
2632 // Shell modifiers
2633 'set shopt ' +
2634 // Zsh built-ins
2635 'autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles ' +
2636 'compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate ' +
2637 'fc fg float functions getcap getln history integer jobs kill limit log noglob popd print ' +
2638 'pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit ' +
2639 'unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof ' +
2640 'zpty zregexparse zsocket zstyle ztcp'
2641 },
2642 contains: [
2643 KNOWN_SHEBANG, // to catch known shells and boost relevancy
2644 hljs.SHEBANG(), // to catch unknown shells but still highlight the shebang
2645 FUNCTION,
2646 ARITHMETIC,
2647 hljs.HASH_COMMENT_MODE,
2648 HERE_DOC,
2649 QUOTE_STRING,
2650 ESCAPED_QUOTE,
2651 APOS_STRING,
2652 VAR
2653 ]
2654 };
2655 }
2656
2657 return bash;
2658
2659 return module.exports.definer || module.exports;
2660
2661}());
2662
2663hljs.registerLanguage('c', function () {
2664 'use strict';
2665
2666 /**
2667 * @param {string} value
2668 * @returns {RegExp}
2669 * */
2670
2671 /**
2672 * @param {RegExp | string } re
2673 * @returns {string}
2674 */
2675 function source(re) {
2676 if (!re) return null;
2677 if (typeof re === "string") return re;
2678
2679 return re.source;
2680 }
2681
2682 /**
2683 * @param {RegExp | string } re
2684 * @returns {string}
2685 */
2686 function optional(re) {
2687 return concat('(', re, ')?');
2688 }
2689
2690 /**
2691 * @param {...(RegExp | string) } args
2692 * @returns {string}
2693 */
2694 function concat(...args) {
2695 const joined = args.map((x) => source(x)).join("");
2696 return joined;
2697 }
2698
2699 /*
2700 Language: C-like foundation grammar for C/C++ grammars
2701 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
2702 Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>, Sam Wu <samsam2310@gmail.com>, Jordi Petit <jordi.petit@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, Google Inc. (David Benjamin) <davidben@google.com>
2703 */
2704
2705 /** @type LanguageFn */
2706 function cLike(hljs) {
2707 // added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
2708 // not include such support nor can we be sure all the grammars depending
2709 // on it would desire this behavior
2710 const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', {
2711 contains: [
2712 {
2713 begin: /\\\n/
2714 }
2715 ]
2716 });
2717 const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
2718 const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
2719 const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
2720 const FUNCTION_TYPE_RE = '(' +
2721 DECLTYPE_AUTO_RE + '|' +
2722 optional(NAMESPACE_RE) +
2723 '[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) +
2724 ')';
2725 const CPP_PRIMITIVE_TYPES = {
2726 className: 'keyword',
2727 begin: '\\b[a-z\\d_]*_t\\b'
2728 };
2729
2730 // https://en.cppreference.com/w/cpp/language/escape
2731 // \\ \x \xFF \u2837 \u00323747 \374
2732 const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
2733 const STRINGS = {
2734 className: 'string',
2735 variants: [
2736 {
2737 begin: '(u8?|U|L)?"',
2738 end: '"',
2739 illegal: '\\n',
2740 contains: [ hljs.BACKSLASH_ESCAPE ]
2741 },
2742 {
2743 begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + "|.)",
2744 end: '\'',
2745 illegal: '.'
2746 },
2747 hljs.END_SAME_AS_BEGIN({
2748 begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
2749 end: /\)([^()\\ ]{0,16})"/
2750 })
2751 ]
2752 };
2753
2754 const NUMBERS = {
2755 className: 'number',
2756 variants: [
2757 {
2758 begin: '\\b(0b[01\']+)'
2759 },
2760 {
2761 begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)'
2762 },
2763 {
2764 begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)'
2765 }
2766 ],
2767 relevance: 0
2768 };
2769
2770 const PREPROCESSOR = {
2771 className: 'meta',
2772 begin: /#\s*[a-z]+\b/,
2773 end: /$/,
2774 keywords: {
2775 'meta-keyword':
2776 'if else elif endif define undef warning error line ' +
2777 'pragma _Pragma ifdef ifndef include'
2778 },
2779 contains: [
2780 {
2781 begin: /\\\n/,
2782 relevance: 0
2783 },
2784 hljs.inherit(STRINGS, {
2785 className: 'meta-string'
2786 }),
2787 {
2788 className: 'meta-string',
2789 begin: /<.*?>/,
2790 end: /$/,
2791 illegal: '\\n'
2792 },
2793 C_LINE_COMMENT_MODE,
2794 hljs.C_BLOCK_COMMENT_MODE
2795 ]
2796 };
2797
2798 const TITLE_MODE = {
2799 className: 'title',
2800 begin: optional(NAMESPACE_RE) + hljs.IDENT_RE,
2801 relevance: 0
2802 };
2803
2804 const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
2805
2806 const CPP_KEYWORDS = {
2807 keyword: 'int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof ' +
2808 'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace ' +
2809 'unsigned long volatile static protected bool template mutable if public friend ' +
2810 'do goto auto void enum else break extern using asm case typeid wchar_t ' +
2811 'short reinterpret_cast|10 default double register explicit signed typename try this ' +
2812 'switch continue inline delete alignas alignof constexpr consteval constinit decltype ' +
2813 'concept co_await co_return co_yield requires ' +
2814 'noexcept static_assert thread_local restrict final override ' +
2815 'atomic_bool atomic_char atomic_schar ' +
2816 'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
2817 'atomic_ullong new throw return ' +
2818 'and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq',
2819 built_in: 'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' +
2820 'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set ' +
2821 'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos ' +
2822 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
2823 'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
2824 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
2825 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
2826 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
2827 'vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary',
2828 literal: 'true false nullptr NULL'
2829 };
2830
2831 const EXPRESSION_CONTAINS = [
2832 PREPROCESSOR,
2833 CPP_PRIMITIVE_TYPES,
2834 C_LINE_COMMENT_MODE,
2835 hljs.C_BLOCK_COMMENT_MODE,
2836 NUMBERS,
2837 STRINGS
2838 ];
2839
2840 const EXPRESSION_CONTEXT = {
2841 // This mode covers expression context where we can't expect a function
2842 // definition and shouldn't highlight anything that looks like one:
2843 // `return some()`, `else if()`, `(x*sum(1, 2))`
2844 variants: [
2845 {
2846 begin: /=/,
2847 end: /;/
2848 },
2849 {
2850 begin: /\(/,
2851 end: /\)/
2852 },
2853 {
2854 beginKeywords: 'new throw return else',
2855 end: /;/
2856 }
2857 ],
2858 keywords: CPP_KEYWORDS,
2859 contains: EXPRESSION_CONTAINS.concat([
2860 {
2861 begin: /\(/,
2862 end: /\)/,
2863 keywords: CPP_KEYWORDS,
2864 contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
2865 relevance: 0
2866 }
2867 ]),
2868 relevance: 0
2869 };
2870
2871 const FUNCTION_DECLARATION = {
2872 className: 'function',
2873 begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
2874 returnBegin: true,
2875 end: /[{;=]/,
2876 excludeEnd: true,
2877 keywords: CPP_KEYWORDS,
2878 illegal: /[^\w\s\*&:<>.]/,
2879 contains: [
2880 { // to prevent it from being confused as the function title
2881 begin: DECLTYPE_AUTO_RE,
2882 keywords: CPP_KEYWORDS,
2883 relevance: 0
2884 },
2885 {
2886 begin: FUNCTION_TITLE,
2887 returnBegin: true,
2888 contains: [ TITLE_MODE ],
2889 relevance: 0
2890 },
2891 {
2892 className: 'params',
2893 begin: /\(/,
2894 end: /\)/,
2895 keywords: CPP_KEYWORDS,
2896 relevance: 0,
2897 contains: [
2898 C_LINE_COMMENT_MODE,
2899 hljs.C_BLOCK_COMMENT_MODE,
2900 STRINGS,
2901 NUMBERS,
2902 CPP_PRIMITIVE_TYPES,
2903 // Count matching parentheses.
2904 {
2905 begin: /\(/,
2906 end: /\)/,
2907 keywords: CPP_KEYWORDS,
2908 relevance: 0,
2909 contains: [
2910 'self',
2911 C_LINE_COMMENT_MODE,
2912 hljs.C_BLOCK_COMMENT_MODE,
2913 STRINGS,
2914 NUMBERS,
2915 CPP_PRIMITIVE_TYPES
2916 ]
2917 }
2918 ]
2919 },
2920 CPP_PRIMITIVE_TYPES,
2921 C_LINE_COMMENT_MODE,
2922 hljs.C_BLOCK_COMMENT_MODE,
2923 PREPROCESSOR
2924 ]
2925 };
2926
2927 return {
2928 aliases: [
2929 'c',
2930 'cc',
2931 'h',
2932 'c++',
2933 'h++',
2934 'hpp',
2935 'hh',
2936 'hxx',
2937 'cxx'
2938 ],
2939 keywords: CPP_KEYWORDS,
2940 // the base c-like language will NEVER be auto-detected, rather the
2941 // derivitives: c, c++, arduino turn auto-detect back on for themselves
2942 disableAutodetect: true,
2943 illegal: '</',
2944 contains: [].concat(
2945 EXPRESSION_CONTEXT,
2946 FUNCTION_DECLARATION,
2947 EXPRESSION_CONTAINS,
2948 [
2949 PREPROCESSOR,
2950 { // containers: ie, `vector <int> rooms (9);`
2951 begin: '\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<',
2952 end: '>',
2953 keywords: CPP_KEYWORDS,
2954 contains: [
2955 'self',
2956 CPP_PRIMITIVE_TYPES
2957 ]
2958 },
2959 {
2960 begin: hljs.IDENT_RE + '::',
2961 keywords: CPP_KEYWORDS
2962 },
2963 {
2964 className: 'class',
2965 beginKeywords: 'enum class struct union',
2966 end: /[{;:<>=]/,
2967 contains: [
2968 {
2969 beginKeywords: "final class struct"
2970 },
2971 hljs.TITLE_MODE
2972 ]
2973 }
2974 ]),
2975 exports: {
2976 preprocessor: PREPROCESSOR,
2977 strings: STRINGS,
2978 keywords: CPP_KEYWORDS
2979 }
2980 };
2981 }
2982
2983 /*
2984 Language: C
2985 Category: common, system
2986 Website: https://en.wikipedia.org/wiki/C_(programming_language)
2987 */
2988
2989 /** @type LanguageFn */
2990 function c(hljs) {
2991 const lang = cLike(hljs);
2992 // Until C is actually different than C++ there is no reason to auto-detect C
2993 // as it's own language since it would just fail auto-detect testing or
2994 // simply match with C++.
2995 //
2996 // See further comments in c-like.js.
2997
2998 // lang.disableAutodetect = false;
2999 lang.name = 'C';
3000 lang.aliases = ['c', 'h'];
3001 return lang;
3002 }
3003
3004 return c;
3005
3006 return module.exports.definer || module.exports;
3007
3008}());
3009
3010hljs.registerLanguage('coffeescript', function () {
3011 'use strict';
3012
3013 const KEYWORDS = [
3014 "as", // for exports
3015 "in",
3016 "of",
3017 "if",
3018 "for",
3019 "while",
3020 "finally",
3021 "var",
3022 "new",
3023 "function",
3024 "do",
3025 "return",
3026 "void",
3027 "else",
3028 "break",
3029 "catch",
3030 "instanceof",
3031 "with",
3032 "throw",
3033 "case",
3034 "default",
3035 "try",
3036 "switch",
3037 "continue",
3038 "typeof",
3039 "delete",
3040 "let",
3041 "yield",
3042 "const",
3043 "class",
3044 // JS handles these with a special rule
3045 // "get",
3046 // "set",
3047 "debugger",
3048 "async",
3049 "await",
3050 "static",
3051 "import",
3052 "from",
3053 "export",
3054 "extends"
3055 ];
3056 const LITERALS = [
3057 "true",
3058 "false",
3059 "null",
3060 "undefined",
3061 "NaN",
3062 "Infinity"
3063 ];
3064
3065 const TYPES = [
3066 "Intl",
3067 "DataView",
3068 "Number",
3069 "Math",
3070 "Date",
3071 "String",
3072 "RegExp",
3073 "Object",
3074 "Function",
3075 "Boolean",
3076 "Error",
3077 "Symbol",
3078 "Set",
3079 "Map",
3080 "WeakSet",
3081 "WeakMap",
3082 "Proxy",
3083 "Reflect",
3084 "JSON",
3085 "Promise",
3086 "Float64Array",
3087 "Int16Array",
3088 "Int32Array",
3089 "Int8Array",
3090 "Uint16Array",
3091 "Uint32Array",
3092 "Float32Array",
3093 "Array",
3094 "Uint8Array",
3095 "Uint8ClampedArray",
3096 "ArrayBuffer"
3097 ];
3098
3099 const ERROR_TYPES = [
3100 "EvalError",
3101 "InternalError",
3102 "RangeError",
3103 "ReferenceError",
3104 "SyntaxError",
3105 "TypeError",
3106 "URIError"
3107 ];
3108
3109 const BUILT_IN_GLOBALS = [
3110 "setInterval",
3111 "setTimeout",
3112 "clearInterval",
3113 "clearTimeout",
3114
3115 "require",
3116 "exports",
3117
3118 "eval",
3119 "isFinite",
3120 "isNaN",
3121 "parseFloat",
3122 "parseInt",
3123 "decodeURI",
3124 "decodeURIComponent",
3125 "encodeURI",
3126 "encodeURIComponent",
3127 "escape",
3128 "unescape"
3129 ];
3130
3131 const BUILT_IN_VARIABLES = [
3132 "arguments",
3133 "this",
3134 "super",
3135 "console",
3136 "window",
3137 "document",
3138 "localStorage",
3139 "module",
3140 "global" // Node.js
3141 ];
3142
3143 const BUILT_INS = [].concat(
3144 BUILT_IN_GLOBALS,
3145 BUILT_IN_VARIABLES,
3146 TYPES,
3147 ERROR_TYPES
3148 );
3149
3150 /*
3151 Language: CoffeeScript
3152 Author: Dmytrii Nagirniak <dnagir@gmail.com>
3153 Contributors: Oleg Efimov <efimovov@gmail.com>, Cédric Néhémie <cedric.nehemie@gmail.com>
3154 Description: CoffeeScript is a programming language that transcompiles to JavaScript. For info about language see http://coffeescript.org/
3155 Category: common, scripting
3156 Website: https://coffeescript.org
3157 */
3158
3159 /** @type LanguageFn */
3160 function coffeescript(hljs) {
3161 const COFFEE_BUILT_INS = [
3162 'npm',
3163 'print'
3164 ];
3165 const COFFEE_LITERALS = [
3166 'yes',
3167 'no',
3168 'on',
3169 'off'
3170 ];
3171 const COFFEE_KEYWORDS = [
3172 'then',
3173 'unless',
3174 'until',
3175 'loop',
3176 'by',
3177 'when',
3178 'and',
3179 'or',
3180 'is',
3181 'isnt',
3182 'not'
3183 ];
3184 const NOT_VALID_KEYWORDS = [
3185 "var",
3186 "const",
3187 "let",
3188 "function",
3189 "static"
3190 ];
3191 const excluding = (list) =>
3192 (kw) => !list.includes(kw);
3193 const KEYWORDS$1 = {
3194 keyword: KEYWORDS.concat(COFFEE_KEYWORDS).filter(excluding(NOT_VALID_KEYWORDS)).join(" "),
3195 literal: LITERALS.concat(COFFEE_LITERALS).join(" "),
3196 built_in: BUILT_INS.concat(COFFEE_BUILT_INS).join(" ")
3197 };
3198 const JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
3199 const SUBST = {
3200 className: 'subst',
3201 begin: /#\{/,
3202 end: /\}/,
3203 keywords: KEYWORDS$1
3204 };
3205 const EXPRESSIONS = [
3206 hljs.BINARY_NUMBER_MODE,
3207 hljs.inherit(hljs.C_NUMBER_MODE, {
3208 starts: {
3209 end: '(\\s*/)?',
3210 relevance: 0
3211 }
3212 }), // a number tries to eat the following slash to prevent treating it as a regexp
3213 {
3214 className: 'string',
3215 variants: [
3216 {
3217 begin: /'''/,
3218 end: /'''/,
3219 contains: [hljs.BACKSLASH_ESCAPE]
3220 },
3221 {
3222 begin: /'/,
3223 end: /'/,
3224 contains: [hljs.BACKSLASH_ESCAPE]
3225 },
3226 {
3227 begin: /"""/,
3228 end: /"""/,
3229 contains: [
3230 hljs.BACKSLASH_ESCAPE,
3231 SUBST
3232 ]
3233 },
3234 {
3235 begin: /"/,
3236 end: /"/,
3237 contains: [
3238 hljs.BACKSLASH_ESCAPE,
3239 SUBST
3240 ]
3241 }
3242 ]
3243 },
3244 {
3245 className: 'regexp',
3246 variants: [
3247 {
3248 begin: '///',
3249 end: '///',
3250 contains: [
3251 SUBST,
3252 hljs.HASH_COMMENT_MODE
3253 ]
3254 },
3255 {
3256 begin: '//[gim]{0,3}(?=\\W)',
3257 relevance: 0
3258 },
3259 {
3260 // regex can't start with space to parse x / 2 / 3 as two divisions
3261 // regex can't start with *, and it supports an "illegal" in the main mode
3262 begin: /\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/
3263 }
3264 ]
3265 },
3266 {
3267 begin: '@' + JS_IDENT_RE // relevance booster
3268 },
3269 {
3270 subLanguage: 'javascript',
3271 excludeBegin: true,
3272 excludeEnd: true,
3273 variants: [
3274 {
3275 begin: '```',
3276 end: '```'
3277 },
3278 {
3279 begin: '`',
3280 end: '`'
3281 }
3282 ]
3283 }
3284 ];
3285 SUBST.contains = EXPRESSIONS;
3286
3287 const TITLE = hljs.inherit(hljs.TITLE_MODE, {
3288 begin: JS_IDENT_RE
3289 });
3290 const POSSIBLE_PARAMS_RE = '(\\(.*\\)\\s*)?\\B[-=]>';
3291 const PARAMS = {
3292 className: 'params',
3293 begin: '\\([^\\(]',
3294 returnBegin: true,
3295 /* We need another contained nameless mode to not have every nested
3296 pair of parens to be called "params" */
3297 contains: [{
3298 begin: /\(/,
3299 end: /\)/,
3300 keywords: KEYWORDS$1,
3301 contains: ['self'].concat(EXPRESSIONS)
3302 }]
3303 };
3304
3305 return {
3306 name: 'CoffeeScript',
3307 aliases: [
3308 'coffee',
3309 'cson',
3310 'iced'
3311 ],
3312 keywords: KEYWORDS$1,
3313 illegal: /\/\*/,
3314 contains: EXPRESSIONS.concat([
3315 hljs.COMMENT('###', '###'),
3316 hljs.HASH_COMMENT_MODE,
3317 {
3318 className: 'function',
3319 begin: '^\\s*' + JS_IDENT_RE + '\\s*=\\s*' + POSSIBLE_PARAMS_RE,
3320 end: '[-=]>',
3321 returnBegin: true,
3322 contains: [
3323 TITLE,
3324 PARAMS
3325 ]
3326 },
3327 {
3328 // anonymous function start
3329 begin: /[:\(,=]\s*/,
3330 relevance: 0,
3331 contains: [{
3332 className: 'function',
3333 begin: POSSIBLE_PARAMS_RE,
3334 end: '[-=]>',
3335 returnBegin: true,
3336 contains: [PARAMS]
3337 }]
3338 },
3339 {
3340 className: 'class',
3341 beginKeywords: 'class',
3342 end: '$',
3343 illegal: /[:="\[\]]/,
3344 contains: [
3345 {
3346 beginKeywords: 'extends',
3347 endsWithParent: true,
3348 illegal: /[:="\[\]]/,
3349 contains: [TITLE]
3350 },
3351 TITLE
3352 ]
3353 },
3354 {
3355 begin: JS_IDENT_RE + ':',
3356 end: ':',
3357 returnBegin: true,
3358 returnEnd: true,
3359 relevance: 0
3360 }
3361 ])
3362 };
3363 }
3364
3365 return coffeescript;
3366
3367 return module.exports.definer || module.exports;
3368
3369}());
3370
3371hljs.registerLanguage('cpp', function () {
3372 'use strict';
3373
3374 /**
3375 * @param {string} value
3376 * @returns {RegExp}
3377 * */
3378
3379 /**
3380 * @param {RegExp | string } re
3381 * @returns {string}
3382 */
3383 function source(re) {
3384 if (!re) return null;
3385 if (typeof re === "string") return re;
3386
3387 return re.source;
3388 }
3389
3390 /**
3391 * @param {RegExp | string } re
3392 * @returns {string}
3393 */
3394 function optional(re) {
3395 return concat('(', re, ')?');
3396 }
3397
3398 /**
3399 * @param {...(RegExp | string) } args
3400 * @returns {string}
3401 */
3402 function concat(...args) {
3403 const joined = args.map((x) => source(x)).join("");
3404 return joined;
3405 }
3406
3407 /*
3408 Language: C-like foundation grammar for C/C++ grammars
3409 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
3410 Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>, Sam Wu <samsam2310@gmail.com>, Jordi Petit <jordi.petit@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, Google Inc. (David Benjamin) <davidben@google.com>
3411 */
3412
3413 /** @type LanguageFn */
3414 function cLike(hljs) {
3415 // added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
3416 // not include such support nor can we be sure all the grammars depending
3417 // on it would desire this behavior
3418 const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', {
3419 contains: [
3420 {
3421 begin: /\\\n/
3422 }
3423 ]
3424 });
3425 const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
3426 const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
3427 const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
3428 const FUNCTION_TYPE_RE = '(' +
3429 DECLTYPE_AUTO_RE + '|' +
3430 optional(NAMESPACE_RE) +
3431 '[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) +
3432 ')';
3433 const CPP_PRIMITIVE_TYPES = {
3434 className: 'keyword',
3435 begin: '\\b[a-z\\d_]*_t\\b'
3436 };
3437
3438 // https://en.cppreference.com/w/cpp/language/escape
3439 // \\ \x \xFF \u2837 \u00323747 \374
3440 const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
3441 const STRINGS = {
3442 className: 'string',
3443 variants: [
3444 {
3445 begin: '(u8?|U|L)?"',
3446 end: '"',
3447 illegal: '\\n',
3448 contains: [ hljs.BACKSLASH_ESCAPE ]
3449 },
3450 {
3451 begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + "|.)",
3452 end: '\'',
3453 illegal: '.'
3454 },
3455 hljs.END_SAME_AS_BEGIN({
3456 begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
3457 end: /\)([^()\\ ]{0,16})"/
3458 })
3459 ]
3460 };
3461
3462 const NUMBERS = {
3463 className: 'number',
3464 variants: [
3465 {
3466 begin: '\\b(0b[01\']+)'
3467 },
3468 {
3469 begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)'
3470 },
3471 {
3472 begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)'
3473 }
3474 ],
3475 relevance: 0
3476 };
3477
3478 const PREPROCESSOR = {
3479 className: 'meta',
3480 begin: /#\s*[a-z]+\b/,
3481 end: /$/,
3482 keywords: {
3483 'meta-keyword':
3484 'if else elif endif define undef warning error line ' +
3485 'pragma _Pragma ifdef ifndef include'
3486 },
3487 contains: [
3488 {
3489 begin: /\\\n/,
3490 relevance: 0
3491 },
3492 hljs.inherit(STRINGS, {
3493 className: 'meta-string'
3494 }),
3495 {
3496 className: 'meta-string',
3497 begin: /<.*?>/,
3498 end: /$/,
3499 illegal: '\\n'
3500 },
3501 C_LINE_COMMENT_MODE,
3502 hljs.C_BLOCK_COMMENT_MODE
3503 ]
3504 };
3505
3506 const TITLE_MODE = {
3507 className: 'title',
3508 begin: optional(NAMESPACE_RE) + hljs.IDENT_RE,
3509 relevance: 0
3510 };
3511
3512 const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
3513
3514 const CPP_KEYWORDS = {
3515 keyword: 'int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof ' +
3516 'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace ' +
3517 'unsigned long volatile static protected bool template mutable if public friend ' +
3518 'do goto auto void enum else break extern using asm case typeid wchar_t ' +
3519 'short reinterpret_cast|10 default double register explicit signed typename try this ' +
3520 'switch continue inline delete alignas alignof constexpr consteval constinit decltype ' +
3521 'concept co_await co_return co_yield requires ' +
3522 'noexcept static_assert thread_local restrict final override ' +
3523 'atomic_bool atomic_char atomic_schar ' +
3524 'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
3525 'atomic_ullong new throw return ' +
3526 'and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq',
3527 built_in: 'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' +
3528 'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set ' +
3529 'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos ' +
3530 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
3531 'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
3532 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
3533 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
3534 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
3535 'vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary',
3536 literal: 'true false nullptr NULL'
3537 };
3538
3539 const EXPRESSION_CONTAINS = [
3540 PREPROCESSOR,
3541 CPP_PRIMITIVE_TYPES,
3542 C_LINE_COMMENT_MODE,
3543 hljs.C_BLOCK_COMMENT_MODE,
3544 NUMBERS,
3545 STRINGS
3546 ];
3547
3548 const EXPRESSION_CONTEXT = {
3549 // This mode covers expression context where we can't expect a function
3550 // definition and shouldn't highlight anything that looks like one:
3551 // `return some()`, `else if()`, `(x*sum(1, 2))`
3552 variants: [
3553 {
3554 begin: /=/,
3555 end: /;/
3556 },
3557 {
3558 begin: /\(/,
3559 end: /\)/
3560 },
3561 {
3562 beginKeywords: 'new throw return else',
3563 end: /;/
3564 }
3565 ],
3566 keywords: CPP_KEYWORDS,
3567 contains: EXPRESSION_CONTAINS.concat([
3568 {
3569 begin: /\(/,
3570 end: /\)/,
3571 keywords: CPP_KEYWORDS,
3572 contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
3573 relevance: 0
3574 }
3575 ]),
3576 relevance: 0
3577 };
3578
3579 const FUNCTION_DECLARATION = {
3580 className: 'function',
3581 begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
3582 returnBegin: true,
3583 end: /[{;=]/,
3584 excludeEnd: true,
3585 keywords: CPP_KEYWORDS,
3586 illegal: /[^\w\s\*&:<>.]/,
3587 contains: [
3588 { // to prevent it from being confused as the function title
3589 begin: DECLTYPE_AUTO_RE,
3590 keywords: CPP_KEYWORDS,
3591 relevance: 0
3592 },
3593 {
3594 begin: FUNCTION_TITLE,
3595 returnBegin: true,
3596 contains: [ TITLE_MODE ],
3597 relevance: 0
3598 },
3599 {
3600 className: 'params',
3601 begin: /\(/,
3602 end: /\)/,
3603 keywords: CPP_KEYWORDS,
3604 relevance: 0,
3605 contains: [
3606 C_LINE_COMMENT_MODE,
3607 hljs.C_BLOCK_COMMENT_MODE,
3608 STRINGS,
3609 NUMBERS,
3610 CPP_PRIMITIVE_TYPES,
3611 // Count matching parentheses.
3612 {
3613 begin: /\(/,
3614 end: /\)/,
3615 keywords: CPP_KEYWORDS,
3616 relevance: 0,
3617 contains: [
3618 'self',
3619 C_LINE_COMMENT_MODE,
3620 hljs.C_BLOCK_COMMENT_MODE,
3621 STRINGS,
3622 NUMBERS,
3623 CPP_PRIMITIVE_TYPES
3624 ]
3625 }
3626 ]
3627 },
3628 CPP_PRIMITIVE_TYPES,
3629 C_LINE_COMMENT_MODE,
3630 hljs.C_BLOCK_COMMENT_MODE,
3631 PREPROCESSOR
3632 ]
3633 };
3634
3635 return {
3636 aliases: [
3637 'c',
3638 'cc',
3639 'h',
3640 'c++',
3641 'h++',
3642 'hpp',
3643 'hh',
3644 'hxx',
3645 'cxx'
3646 ],
3647 keywords: CPP_KEYWORDS,
3648 // the base c-like language will NEVER be auto-detected, rather the
3649 // derivitives: c, c++, arduino turn auto-detect back on for themselves
3650 disableAutodetect: true,
3651 illegal: '</',
3652 contains: [].concat(
3653 EXPRESSION_CONTEXT,
3654 FUNCTION_DECLARATION,
3655 EXPRESSION_CONTAINS,
3656 [
3657 PREPROCESSOR,
3658 { // containers: ie, `vector <int> rooms (9);`
3659 begin: '\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<',
3660 end: '>',
3661 keywords: CPP_KEYWORDS,
3662 contains: [
3663 'self',
3664 CPP_PRIMITIVE_TYPES
3665 ]
3666 },
3667 {
3668 begin: hljs.IDENT_RE + '::',
3669 keywords: CPP_KEYWORDS
3670 },
3671 {
3672 className: 'class',
3673 beginKeywords: 'enum class struct union',
3674 end: /[{;:<>=]/,
3675 contains: [
3676 {
3677 beginKeywords: "final class struct"
3678 },
3679 hljs.TITLE_MODE
3680 ]
3681 }
3682 ]),
3683 exports: {
3684 preprocessor: PREPROCESSOR,
3685 strings: STRINGS,
3686 keywords: CPP_KEYWORDS
3687 }
3688 };
3689 }
3690
3691 /*
3692 Language: C++
3693 Category: common, system
3694 Website: https://isocpp.org
3695 */
3696
3697 /** @type LanguageFn */
3698 function cpp(hljs) {
3699 const lang = cLike(hljs);
3700 // return auto-detection back on
3701 lang.disableAutodetect = false;
3702 lang.name = 'C++';
3703 lang.aliases = ['cc', 'c++', 'h++', 'hpp', 'hh', 'hxx', 'cxx'];
3704 return lang;
3705 }
3706
3707 return cpp;
3708
3709 return module.exports.definer || module.exports;
3710
3711}());
3712
3713hljs.registerLanguage('csharp', function () {
3714 'use strict';
3715
3716 /*
3717 Language: C#
3718 Author: Jason Diamond <jason@diamond.name>
3719 Contributor: Nicolas LLOBERA <nllobera@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, David Pine <david.pine@microsoft.com>
3720 Website: https://docs.microsoft.com/en-us/dotnet/csharp/
3721 Category: common
3722 */
3723
3724 /** @type LanguageFn */
3725 function csharp(hljs) {
3726 var BUILT_IN_KEYWORDS = [
3727 'bool',
3728 'byte',
3729 'char',
3730 'decimal',
3731 'delegate',
3732 'double',
3733 'dynamic',
3734 'enum',
3735 'float',
3736 'int',
3737 'long',
3738 'nint',
3739 'nuint',
3740 'object',
3741 'sbyte',
3742 'short',
3743 'string',
3744 'ulong',
3745 'unit',
3746 'ushort'
3747 ];
3748 var FUNCTION_MODIFIERS = [
3749 'public',
3750 'private',
3751 'protected',
3752 'static',
3753 'internal',
3754 'protected',
3755 'abstract',
3756 'async',
3757 'extern',
3758 'override',
3759 'unsafe',
3760 'virtual',
3761 'new',
3762 'sealed',
3763 'partial'
3764 ];
3765 var LITERAL_KEYWORDS = [
3766 'default',
3767 'false',
3768 'null',
3769 'true'
3770 ];
3771 var NORMAL_KEYWORDS = [
3772 'abstract',
3773 'as',
3774 'base',
3775 'break',
3776 'case',
3777 'class',
3778 'const',
3779 'continue',
3780 'do',
3781 'else',
3782 'event',
3783 'explicit',
3784 'extern',
3785 'finally',
3786 'fixed',
3787 'for',
3788 'foreach',
3789 'goto',
3790 'if',
3791 'implicit',
3792 'in',
3793 'interface',
3794 'internal',
3795 'is',
3796 'lock',
3797 'namespace',
3798 'new',
3799 'operator',
3800 'out',
3801 'override',
3802 'params',
3803 'private',
3804 'protected',
3805 'public',
3806 'readonly',
3807 'record',
3808 'ref',
3809 'return',
3810 'sealed',
3811 'sizeof',
3812 'stackalloc',
3813 'static',
3814 'struct',
3815 'switch',
3816 'this',
3817 'throw',
3818 'try',
3819 'typeof',
3820 'unchecked',
3821 'unsafe',
3822 'using',
3823 'virtual',
3824 'void',
3825 'volatile',
3826 'while'
3827 ];
3828 var CONTEXTUAL_KEYWORDS = [
3829 'add',
3830 'alias',
3831 'and',
3832 'ascending',
3833 'async',
3834 'await',
3835 'by',
3836 'descending',
3837 'equals',
3838 'from',
3839 'get',
3840 'global',
3841 'group',
3842 'init',
3843 'into',
3844 'join',
3845 'let',
3846 'nameof',
3847 'not',
3848 'notnull',
3849 'on',
3850 'or',
3851 'orderby',
3852 'partial',
3853 'remove',
3854 'select',
3855 'set',
3856 'unmanaged',
3857 'value|0',
3858 'var',
3859 'when',
3860 'where',
3861 'with',
3862 'yield'
3863 ];
3864
3865 var KEYWORDS = {
3866 keyword: NORMAL_KEYWORDS.concat(CONTEXTUAL_KEYWORDS).join(' '),
3867 built_in: BUILT_IN_KEYWORDS.join(' '),
3868 literal: LITERAL_KEYWORDS.join(' ')
3869 };
3870 var TITLE_MODE = hljs.inherit(hljs.TITLE_MODE, {begin: '[a-zA-Z](\\.?\\w)*'});
3871 var NUMBERS = {
3872 className: 'number',
3873 variants: [
3874 { begin: '\\b(0b[01\']+)' },
3875 { begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)' },
3876 { begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' }
3877 ],
3878 relevance: 0
3879 };
3880 var VERBATIM_STRING = {
3881 className: 'string',
3882 begin: '@"', end: '"',
3883 contains: [{begin: '""'}]
3884 };
3885 var VERBATIM_STRING_NO_LF = hljs.inherit(VERBATIM_STRING, {illegal: /\n/});
3886 var SUBST = {
3887 className: 'subst',
3888 begin: /\{/, end: /\}/,
3889 keywords: KEYWORDS
3890 };
3891 var SUBST_NO_LF = hljs.inherit(SUBST, {illegal: /\n/});
3892 var INTERPOLATED_STRING = {
3893 className: 'string',
3894 begin: /\$"/, end: '"',
3895 illegal: /\n/,
3896 contains: [{begin: /\{\{/}, {begin: /\}\}/}, hljs.BACKSLASH_ESCAPE, SUBST_NO_LF]
3897 };
3898 var INTERPOLATED_VERBATIM_STRING = {
3899 className: 'string',
3900 begin: /\$@"/, end: '"',
3901 contains: [{begin: /\{\{/}, {begin: /\}\}/}, {begin: '""'}, SUBST]
3902 };
3903 var INTERPOLATED_VERBATIM_STRING_NO_LF = hljs.inherit(INTERPOLATED_VERBATIM_STRING, {
3904 illegal: /\n/,
3905 contains: [{begin: /\{\{/}, {begin: /\}\}/}, {begin: '""'}, SUBST_NO_LF]
3906 });
3907 SUBST.contains = [
3908 INTERPOLATED_VERBATIM_STRING,
3909 INTERPOLATED_STRING,
3910 VERBATIM_STRING,
3911 hljs.APOS_STRING_MODE,
3912 hljs.QUOTE_STRING_MODE,
3913 NUMBERS,
3914 hljs.C_BLOCK_COMMENT_MODE
3915 ];
3916 SUBST_NO_LF.contains = [
3917 INTERPOLATED_VERBATIM_STRING_NO_LF,
3918 INTERPOLATED_STRING,
3919 VERBATIM_STRING_NO_LF,
3920 hljs.APOS_STRING_MODE,
3921 hljs.QUOTE_STRING_MODE,
3922 NUMBERS,
3923 hljs.inherit(hljs.C_BLOCK_COMMENT_MODE, {illegal: /\n/})
3924 ];
3925 var STRING = {
3926 variants: [
3927 INTERPOLATED_VERBATIM_STRING,
3928 INTERPOLATED_STRING,
3929 VERBATIM_STRING,
3930 hljs.APOS_STRING_MODE,
3931 hljs.QUOTE_STRING_MODE
3932 ]
3933 };
3934
3935 var GENERIC_MODIFIER = {
3936 begin: "<",
3937 end: ">",
3938 contains: [
3939 { beginKeywords: "in out"},
3940 TITLE_MODE
3941 ]
3942 };
3943 var TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?';
3944 var AT_IDENTIFIER = {
3945 // prevents expressions like `@class` from incorrect flagging
3946 // `class` as a keyword
3947 begin: "@" + hljs.IDENT_RE,
3948 relevance: 0
3949 };
3950
3951 return {
3952 name: 'C#',
3953 aliases: ['cs', 'c#'],
3954 keywords: KEYWORDS,
3955 illegal: /::/,
3956 contains: [
3957 hljs.COMMENT(
3958 '///',
3959 '$',
3960 {
3961 returnBegin: true,
3962 contains: [
3963 {
3964 className: 'doctag',
3965 variants: [
3966 {
3967 begin: '///', relevance: 0
3968 },
3969 {
3970 begin: '<!--|-->'
3971 },
3972 {
3973 begin: '</?', end: '>'
3974 }
3975 ]
3976 }
3977 ]
3978 }
3979 ),
3980 hljs.C_LINE_COMMENT_MODE,
3981 hljs.C_BLOCK_COMMENT_MODE,
3982 {
3983 className: 'meta',
3984 begin: '#', end: '$',
3985 keywords: {
3986 'meta-keyword': 'if else elif endif define undef warning error line region endregion pragma checksum'
3987 }
3988 },
3989 STRING,
3990 NUMBERS,
3991 {
3992 beginKeywords: 'class interface',
3993 relevance: 0,
3994 end: /[{;=]/,
3995 illegal: /[^\s:,]/,
3996 contains: [
3997 { beginKeywords: "where class" },
3998 TITLE_MODE,
3999 GENERIC_MODIFIER,
4000 hljs.C_LINE_COMMENT_MODE,
4001 hljs.C_BLOCK_COMMENT_MODE
4002 ]
4003 },
4004 {
4005 beginKeywords: 'namespace',
4006 relevance: 0,
4007 end: /[{;=]/,
4008 illegal: /[^\s:]/,
4009 contains: [
4010 TITLE_MODE,
4011 hljs.C_LINE_COMMENT_MODE,
4012 hljs.C_BLOCK_COMMENT_MODE
4013 ]
4014 },
4015 {
4016 beginKeywords: 'record',
4017 relevance: 0,
4018 end: /[{;=]/,
4019 illegal: /[^\s:]/,
4020 contains: [
4021 TITLE_MODE,
4022 GENERIC_MODIFIER,
4023 hljs.C_LINE_COMMENT_MODE,
4024 hljs.C_BLOCK_COMMENT_MODE
4025 ]
4026 },
4027 {
4028 // [Attributes("")]
4029 className: 'meta',
4030 begin: '^\\s*\\[', excludeBegin: true, end: '\\]', excludeEnd: true,
4031 contains: [
4032 {className: 'meta-string', begin: /"/, end: /"/}
4033 ]
4034 },
4035 {
4036 // Expression keywords prevent 'keyword Name(...)' from being
4037 // recognized as a function definition
4038 beginKeywords: 'new return throw await else',
4039 relevance: 0
4040 },
4041 {
4042 className: 'function',
4043 begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', returnBegin: true,
4044 end: /\s*[{;=]/, excludeEnd: true,
4045 keywords: KEYWORDS,
4046 contains: [
4047 // prevents these from being highlighted `title`
4048 {
4049 beginKeywords: FUNCTION_MODIFIERS.join(" "),
4050 relevance: 0
4051 },
4052 {
4053 begin: hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', returnBegin: true,
4054 contains: [
4055 hljs.TITLE_MODE,
4056 GENERIC_MODIFIER
4057 ],
4058 relevance: 0
4059 },
4060 {
4061 className: 'params',
4062 begin: /\(/, end: /\)/,
4063 excludeBegin: true,
4064 excludeEnd: true,
4065 keywords: KEYWORDS,
4066 relevance: 0,
4067 contains: [
4068 STRING,
4069 NUMBERS,
4070 hljs.C_BLOCK_COMMENT_MODE
4071 ]
4072 },
4073 hljs.C_LINE_COMMENT_MODE,
4074 hljs.C_BLOCK_COMMENT_MODE
4075 ]
4076 },
4077 AT_IDENTIFIER
4078 ]
4079 };
4080 }
4081
4082 return csharp;
4083
4084 return module.exports.definer || module.exports;
4085
4086}());
4087
4088hljs.registerLanguage('css', function () {
4089 'use strict';
4090
4091 /*
4092 Language: CSS
4093 Category: common, css
4094 Website: https://developer.mozilla.org/en-US/docs/Web/CSS
4095 */
4096
4097 /** @type LanguageFn */
4098 function css(hljs) {
4099 var FUNCTION_LIKE = {
4100 begin: /[\w-]+\(/, returnBegin: true,
4101 contains: [
4102 {
4103 className: 'built_in',
4104 begin: /[\w-]+/
4105 },
4106 {
4107 begin: /\(/, end: /\)/,
4108 contains: [
4109 hljs.APOS_STRING_MODE,
4110 hljs.QUOTE_STRING_MODE,
4111 hljs.CSS_NUMBER_MODE,
4112 ]
4113 }
4114 ]
4115 };
4116 var ATTRIBUTE = {
4117 className: 'attribute',
4118 begin: /\S/, end: ':', excludeEnd: true,
4119 starts: {
4120 endsWithParent: true, excludeEnd: true,
4121 contains: [
4122 FUNCTION_LIKE,
4123 hljs.CSS_NUMBER_MODE,
4124 hljs.QUOTE_STRING_MODE,
4125 hljs.APOS_STRING_MODE,
4126 hljs.C_BLOCK_COMMENT_MODE,
4127 {
4128 className: 'number', begin: '#[0-9A-Fa-f]+'
4129 },
4130 {
4131 className: 'meta', begin: '!important'
4132 }
4133 ]
4134 }
4135 };
4136 var AT_IDENTIFIER = '@[a-z-]+'; // @font-face
4137 var AT_MODIFIERS = "and or not only";
4138 var AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
4139 var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
4140 var RULE = {
4141 begin: /([*]\s?)?(?:[A-Z_.\-\\]+|--[a-zA-Z0-9_-]+)\s*(\/\*\*\/)?:/, returnBegin: true, end: ';', endsWithParent: true,
4142 contains: [
4143 ATTRIBUTE
4144 ]
4145 };
4146
4147 return {
4148 name: 'CSS',
4149 case_insensitive: true,
4150 illegal: /[=|'\$]/,
4151 contains: [
4152 hljs.C_BLOCK_COMMENT_MODE,
4153 {
4154 className: 'selector-id', begin: /#[A-Za-z0-9_-]+/
4155 },
4156 {
4157 className: 'selector-class', begin: '\\.' + IDENT_RE
4158 },
4159 {
4160 className: 'selector-attr',
4161 begin: /\[/, end: /\]/,
4162 illegal: '$',
4163 contains: [
4164 hljs.APOS_STRING_MODE,
4165 hljs.QUOTE_STRING_MODE,
4166 ]
4167 },
4168 {
4169 className: 'selector-pseudo',
4170 begin: /:(:)?[a-zA-Z0-9_+()"'.-]+/
4171 },
4172 // matching these here allows us to treat them more like regular CSS
4173 // rules so everything between the {} gets regular rule highlighting,
4174 // which is what we want for page and font-face
4175 {
4176 begin: '@(page|font-face)',
4177 lexemes: AT_IDENTIFIER,
4178 keywords: '@page @font-face'
4179 },
4180 {
4181 begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing
4182 // because it doesn’t let it to be parsed as
4183 // a rule set but instead drops parser into
4184 // the default mode which is how it should be.
4185 illegal: /:/, // break on Less variables @var: ...
4186 returnBegin: true,
4187 contains: [
4188 {
4189 className: 'keyword',
4190 begin: AT_PROPERTY_RE
4191 },
4192 {
4193 begin: /\s/, endsWithParent: true, excludeEnd: true,
4194 relevance: 0,
4195 keywords: AT_MODIFIERS,
4196 contains: [
4197 {
4198 begin: /[a-z-]+:/,
4199 className:"attribute"
4200 },
4201 hljs.APOS_STRING_MODE,
4202 hljs.QUOTE_STRING_MODE,
4203 hljs.CSS_NUMBER_MODE
4204 ]
4205 }
4206 ]
4207 },
4208 {
4209 className: 'selector-tag', begin: IDENT_RE,
4210 relevance: 0
4211 },
4212 {
4213 begin: /\{/, end: /\}/,
4214 illegal: /\S/,
4215 contains: [
4216 hljs.C_BLOCK_COMMENT_MODE,
4217 { begin: /;/ }, // empty ; rule
4218 RULE,
4219 ]
4220 }
4221 ]
4222 };
4223 }
4224
4225 return css;
4226
4227 return module.exports.definer || module.exports;
4228
4229}());
4230
4231hljs.registerLanguage('diff', function () {
4232 'use strict';
4233
4234 /*
4235 Language: Diff
4236 Description: Unified and context diff
4237 Author: Vasily Polovnyov <vast@whiteants.net>
4238 Website: https://www.gnu.org/software/diffutils/
4239 Category: common
4240 */
4241
4242 /** @type LanguageFn */
4243 function diff(hljs) {
4244 return {
4245 name: 'Diff',
4246 aliases: ['patch'],
4247 contains: [
4248 {
4249 className: 'meta',
4250 relevance: 10,
4251 variants: [
4252 {
4253 begin: /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/
4254 },
4255 {
4256 begin: /^\*\*\* +\d+,\d+ +\*\*\*\*$/
4257 },
4258 {
4259 begin: /^--- +\d+,\d+ +----$/
4260 }
4261 ]
4262 },
4263 {
4264 className: 'comment',
4265 variants: [
4266 {
4267 begin: /Index: /,
4268 end: /$/
4269 },
4270 {
4271 begin: /^index/,
4272 end: /$/
4273 },
4274 {
4275 begin: /={3,}/,
4276 end: /$/
4277 },
4278 {
4279 begin: /^-{3}/,
4280 end: /$/
4281 },
4282 {
4283 begin: /^\*{3} /,
4284 end: /$/
4285 },
4286 {
4287 begin: /^\+{3}/,
4288 end: /$/
4289 },
4290 {
4291 begin: /^\*{15}$/
4292 },
4293 {
4294 begin: /^diff --git/,
4295 end: /$/
4296 }
4297 ]
4298 },
4299 {
4300 className: 'addition',
4301 begin: /^\+/,
4302 end: /$/
4303 },
4304 {
4305 className: 'deletion',
4306 begin: /^-/,
4307 end: /$/
4308 },
4309 {
4310 className: 'addition',
4311 begin: /^!/,
4312 end: /$/
4313 }
4314 ]
4315 };
4316 }
4317
4318 return diff;
4319
4320 return module.exports.definer || module.exports;
4321
4322}());
4323
4324hljs.registerLanguage('go', function () {
4325 'use strict';
4326
4327 /*
4328 Language: Go
4329 Author: Stephan Kountso aka StepLg <steplg@gmail.com>
4330 Contributors: Evgeny Stepanischev <imbolk@gmail.com>
4331 Description: Google go language (golang). For info about language
4332 Website: http://golang.org/
4333 Category: common, system
4334 */
4335
4336 function go(hljs) {
4337 const GO_KEYWORDS = {
4338 keyword:
4339 'break default func interface select case map struct chan else goto package switch ' +
4340 'const fallthrough if range type continue for import return var go defer ' +
4341 'bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 ' +
4342 'uint16 uint32 uint64 int uint uintptr rune',
4343 literal:
4344 'true false iota nil',
4345 built_in:
4346 'append cap close complex copy imag len make new panic print println real recover delete'
4347 };
4348 return {
4349 name: 'Go',
4350 aliases: ['golang'],
4351 keywords: GO_KEYWORDS,
4352 illegal: '</',
4353 contains: [
4354 hljs.C_LINE_COMMENT_MODE,
4355 hljs.C_BLOCK_COMMENT_MODE,
4356 {
4357 className: 'string',
4358 variants: [
4359 hljs.QUOTE_STRING_MODE,
4360 hljs.APOS_STRING_MODE,
4361 {
4362 begin: '`',
4363 end: '`'
4364 }
4365 ]
4366 },
4367 {
4368 className: 'number',
4369 variants: [
4370 {
4371 begin: hljs.C_NUMBER_RE + '[i]',
4372 relevance: 1
4373 },
4374 hljs.C_NUMBER_MODE
4375 ]
4376 },
4377 {
4378 begin: /:=/ // relevance booster
4379 },
4380 {
4381 className: 'function',
4382 beginKeywords: 'func',
4383 end: '\\s*(\\{|$)',
4384 excludeEnd: true,
4385 contains: [
4386 hljs.TITLE_MODE,
4387 {
4388 className: 'params',
4389 begin: /\(/,
4390 end: /\)/,
4391 keywords: GO_KEYWORDS,
4392 illegal: /["']/
4393 }
4394 ]
4395 }
4396 ]
4397 };
4398 }
4399
4400 return go;
4401
4402 return module.exports.definer || module.exports;
4403
4404}());
4405
4406hljs.registerLanguage('http', function () {
4407 'use strict';
4408
4409 /**
4410 * @param {string} value
4411 * @returns {RegExp}
4412 * */
4413
4414 /**
4415 * @param {RegExp | string } re
4416 * @returns {string}
4417 */
4418 function source(re) {
4419 if (!re) return null;
4420 if (typeof re === "string") return re;
4421
4422 return re.source;
4423 }
4424
4425 /**
4426 * @param {...(RegExp | string) } args
4427 * @returns {string}
4428 */
4429 function concat(...args) {
4430 const joined = args.map((x) => source(x)).join("");
4431 return joined;
4432 }
4433
4434 /*
4435 Language: HTTP
4436 Description: HTTP request and response headers with automatic body highlighting
4437 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
4438 Category: common, protocols
4439 Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
4440 */
4441
4442 function http(hljs) {
4443 const VERSION = 'HTTP/(2|1\\.[01])';
4444 const HEADER_NAME = /[A-Za-z][A-Za-z0-9-]*/;
4445 const HEADERS_AND_BODY = [
4446 {
4447 className: 'attribute',
4448 begin: concat('^', HEADER_NAME, '(?=\\:\\s)'),
4449 starts: {
4450 contains: [
4451 {
4452 className: "punctuation",
4453 begin: /: /,
4454 relevance: 0,
4455 starts: {
4456 end: '$',
4457 relevance: 0
4458 }
4459 }
4460 ]
4461 }
4462 },
4463 {
4464 begin: '\\n\\n',
4465 starts: { subLanguage: [], endsWithParent: true }
4466 }
4467 ];
4468
4469 return {
4470 name: 'HTTP',
4471 aliases: ['https'],
4472 illegal: /\S/,
4473 contains: [
4474 // response
4475 {
4476 begin: '^(?=' + VERSION + " \\d{3})",
4477 end: /$/,
4478 contains: [
4479 {
4480 className: "meta",
4481 begin: VERSION
4482 },
4483 {
4484 className: 'number', begin: '\\b\\d{3}\\b'
4485 }
4486 ],
4487 starts: {
4488 end: /\b\B/,
4489 illegal: /\S/,
4490 contains: HEADERS_AND_BODY
4491 }
4492 },
4493 // request
4494 {
4495 begin: '(?=^[A-Z]+ (.*?) ' + VERSION + '$)',
4496 end: /$/,
4497 contains: [
4498 {
4499 className: 'string',
4500 begin: ' ',
4501 end: ' ',
4502 excludeBegin: true,
4503 excludeEnd: true
4504 },
4505 {
4506 className: "meta",
4507 begin: VERSION
4508 },
4509 {
4510 className: 'keyword',
4511 begin: '[A-Z]+'
4512 }
4513 ],
4514 starts: {
4515 end: /\b\B/,
4516 illegal: /\S/,
4517 contains: HEADERS_AND_BODY
4518 }
4519 }
4520 ]
4521 };
4522 }
4523
4524 return http;
4525
4526 return module.exports.definer || module.exports;
4527
4528}());
4529
4530hljs.registerLanguage('ini', function () {
4531 'use strict';
4532
4533 /**
4534 * @param {string} value
4535 * @returns {RegExp}
4536 * */
4537
4538 /**
4539 * @param {RegExp | string } re
4540 * @returns {string}
4541 */
4542 function source(re) {
4543 if (!re) return null;
4544 if (typeof re === "string") return re;
4545
4546 return re.source;
4547 }
4548
4549 /**
4550 * @param {RegExp | string } re
4551 * @returns {string}
4552 */
4553 function lookahead(re) {
4554 return concat('(?=', re, ')');
4555 }
4556
4557 /**
4558 * @param {...(RegExp | string) } args
4559 * @returns {string}
4560 */
4561 function concat(...args) {
4562 const joined = args.map((x) => source(x)).join("");
4563 return joined;
4564 }
4565
4566 /**
4567 * Any of the passed expresssions may match
4568 *
4569 * Creates a huge this | this | that | that match
4570 * @param {(RegExp | string)[] } args
4571 * @returns {string}
4572 */
4573 function either(...args) {
4574 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
4575 return joined;
4576 }
4577
4578 /*
4579 Language: TOML, also INI
4580 Description: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.
4581 Contributors: Guillaume Gomez <guillaume1.gomez@gmail.com>
4582 Category: common, config
4583 Website: https://github.com/toml-lang/toml
4584 */
4585
4586 function ini(hljs) {
4587 const NUMBERS = {
4588 className: 'number',
4589 relevance: 0,
4590 variants: [
4591 {
4592 begin: /([+-]+)?[\d]+_[\d_]+/
4593 },
4594 {
4595 begin: hljs.NUMBER_RE
4596 }
4597 ]
4598 };
4599 const COMMENTS = hljs.COMMENT();
4600 COMMENTS.variants = [
4601 {
4602 begin: /;/,
4603 end: /$/
4604 },
4605 {
4606 begin: /#/,
4607 end: /$/
4608 }
4609 ];
4610 const VARIABLES = {
4611 className: 'variable',
4612 variants: [
4613 {
4614 begin: /\$[\w\d"][\w\d_]*/
4615 },
4616 {
4617 begin: /\$\{(.*?)\}/
4618 }
4619 ]
4620 };
4621 const LITERALS = {
4622 className: 'literal',
4623 begin: /\bon|off|true|false|yes|no\b/
4624 };
4625 const STRINGS = {
4626 className: "string",
4627 contains: [hljs.BACKSLASH_ESCAPE],
4628 variants: [
4629 {
4630 begin: "'''",
4631 end: "'''",
4632 relevance: 10
4633 },
4634 {
4635 begin: '"""',
4636 end: '"""',
4637 relevance: 10
4638 },
4639 {
4640 begin: '"',
4641 end: '"'
4642 },
4643 {
4644 begin: "'",
4645 end: "'"
4646 }
4647 ]
4648 };
4649 const ARRAY = {
4650 begin: /\[/,
4651 end: /\]/,
4652 contains: [
4653 COMMENTS,
4654 LITERALS,
4655 VARIABLES,
4656 STRINGS,
4657 NUMBERS,
4658 'self'
4659 ],
4660 relevance: 0
4661 };
4662
4663 const BARE_KEY = /[A-Za-z0-9_-]+/;
4664 const QUOTED_KEY_DOUBLE_QUOTE = /"(\\"|[^"])*"/;
4665 const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/;
4666 const ANY_KEY = either(
4667 BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE
4668 );
4669 const DOTTED_KEY = concat(
4670 ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*',
4671 lookahead(/\s*=\s*[^#\s]/)
4672 );
4673
4674 return {
4675 name: 'TOML, also INI',
4676 aliases: ['toml'],
4677 case_insensitive: true,
4678 illegal: /\S/,
4679 contains: [
4680 COMMENTS,
4681 {
4682 className: 'section',
4683 begin: /\[+/,
4684 end: /\]+/
4685 },
4686 {
4687 begin: DOTTED_KEY,
4688 className: 'attr',
4689 starts: {
4690 end: /$/,
4691 contains: [
4692 COMMENTS,
4693 ARRAY,
4694 LITERALS,
4695 VARIABLES,
4696 STRINGS,
4697 NUMBERS
4698 ]
4699 }
4700 }
4701 ]
4702 };
4703 }
4704
4705 return ini;
4706
4707 return module.exports.definer || module.exports;
4708
4709}());
4710
4711hljs.registerLanguage('java', function () {
4712 'use strict';
4713
4714 // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10
4715 var decimalDigits = '[0-9](_*[0-9])*';
4716 var frac = `\\.(${decimalDigits})`;
4717 var hexDigits = '[0-9a-fA-F](_*[0-9a-fA-F])*';
4718 var NUMERIC = {
4719 className: 'number',
4720 variants: [
4721 // DecimalFloatingPointLiteral
4722 // including ExponentPart
4723 { begin: `(\\b(${decimalDigits})((${frac})|\\.)?|(${frac}))` +
4724 `[eE][+-]?(${decimalDigits})[fFdD]?\\b` },
4725 // excluding ExponentPart
4726 { begin: `\\b(${decimalDigits})((${frac})[fFdD]?\\b|\\.([fFdD]\\b)?)` },
4727 { begin: `(${frac})[fFdD]?\\b` },
4728 { begin: `\\b(${decimalDigits})[fFdD]\\b` },
4729
4730 // HexadecimalFloatingPointLiteral
4731 { begin: `\\b0[xX]((${hexDigits})\\.?|(${hexDigits})?\\.(${hexDigits}))` +
4732 `[pP][+-]?(${decimalDigits})[fFdD]?\\b` },
4733
4734 // DecimalIntegerLiteral
4735 { begin: '\\b(0|[1-9](_*[0-9])*)[lL]?\\b' },
4736
4737 // HexIntegerLiteral
4738 { begin: `\\b0[xX](${hexDigits})[lL]?\\b` },
4739
4740 // OctalIntegerLiteral
4741 { begin: '\\b0(_*[0-7])*[lL]?\\b' },
4742
4743 // BinaryIntegerLiteral
4744 { begin: '\\b0[bB][01](_*[01])*[lL]?\\b' },
4745 ],
4746 relevance: 0
4747 };
4748
4749 /*
4750 Language: Java
4751 Author: Vsevolod Solovyov <vsevolod.solovyov@gmail.com>
4752 Category: common, enterprise
4753 Website: https://www.java.com/
4754 */
4755
4756 function java(hljs) {
4757 var JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*';
4758 var GENERIC_IDENT_RE = JAVA_IDENT_RE + '(<' + JAVA_IDENT_RE + '(\\s*,\\s*' + JAVA_IDENT_RE + ')*>)?';
4759 var KEYWORDS = 'false synchronized int abstract float private char boolean var static null if const ' +
4760 'for true while long strictfp finally protected import native final void ' +
4761 'enum else break transient catch instanceof byte super volatile case assert short ' +
4762 'package default double public try this switch continue throws protected public private ' +
4763 'module requires exports do';
4764
4765 var ANNOTATION = {
4766 className: 'meta',
4767 begin: '@' + JAVA_IDENT_RE,
4768 contains: [
4769 {
4770 begin: /\(/,
4771 end: /\)/,
4772 contains: ["self"] // allow nested () inside our annotation
4773 },
4774 ]
4775 };
4776 const NUMBER = NUMERIC;
4777
4778 return {
4779 name: 'Java',
4780 aliases: ['jsp'],
4781 keywords: KEYWORDS,
4782 illegal: /<\/|#/,
4783 contains: [
4784 hljs.COMMENT(
4785 '/\\*\\*',
4786 '\\*/',
4787 {
4788 relevance: 0,
4789 contains: [
4790 {
4791 // eat up @'s in emails to prevent them to be recognized as doctags
4792 begin: /\w+@/, relevance: 0
4793 },
4794 {
4795 className: 'doctag',
4796 begin: '@[A-Za-z]+'
4797 }
4798 ]
4799 }
4800 ),
4801 // relevance boost
4802 {
4803 begin: /import java\.[a-z]+\./,
4804 keywords: "import",
4805 relevance: 2
4806 },
4807 hljs.C_LINE_COMMENT_MODE,
4808 hljs.C_BLOCK_COMMENT_MODE,
4809 hljs.APOS_STRING_MODE,
4810 hljs.QUOTE_STRING_MODE,
4811 {
4812 className: 'class',
4813 beginKeywords: 'class interface enum', end: /[{;=]/, excludeEnd: true,
4814 keywords: 'class interface enum',
4815 illegal: /[:"\[\]]/,
4816 contains: [
4817 { beginKeywords: 'extends implements' },
4818 hljs.UNDERSCORE_TITLE_MODE
4819 ]
4820 },
4821 {
4822 // Expression keywords prevent 'keyword Name(...)' from being
4823 // recognized as a function definition
4824 beginKeywords: 'new throw return else',
4825 relevance: 0
4826 },
4827 {
4828 className: 'class',
4829 begin: 'record\\s+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(',
4830 returnBegin: true,
4831 excludeEnd: true,
4832 end: /[{;=]/,
4833 keywords: KEYWORDS,
4834 contains: [
4835 { beginKeywords: "record" },
4836 {
4837 begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(',
4838 returnBegin: true,
4839 relevance: 0,
4840 contains: [hljs.UNDERSCORE_TITLE_MODE]
4841 },
4842 {
4843 className: 'params',
4844 begin: /\(/, end: /\)/,
4845 keywords: KEYWORDS,
4846 relevance: 0,
4847 contains: [
4848 hljs.C_BLOCK_COMMENT_MODE
4849 ]
4850 },
4851 hljs.C_LINE_COMMENT_MODE,
4852 hljs.C_BLOCK_COMMENT_MODE
4853 ]
4854 },
4855 {
4856 className: 'function',
4857 begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
4858 excludeEnd: true,
4859 keywords: KEYWORDS,
4860 contains: [
4861 {
4862 begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true,
4863 relevance: 0,
4864 contains: [hljs.UNDERSCORE_TITLE_MODE]
4865 },
4866 {
4867 className: 'params',
4868 begin: /\(/, end: /\)/,
4869 keywords: KEYWORDS,
4870 relevance: 0,
4871 contains: [
4872 ANNOTATION,
4873 hljs.APOS_STRING_MODE,
4874 hljs.QUOTE_STRING_MODE,
4875 NUMBER,
4876 hljs.C_BLOCK_COMMENT_MODE
4877 ]
4878 },
4879 hljs.C_LINE_COMMENT_MODE,
4880 hljs.C_BLOCK_COMMENT_MODE
4881 ]
4882 },
4883 NUMBER,
4884 ANNOTATION
4885 ]
4886 };
4887 }
4888
4889 return java;
4890
4891 return module.exports.definer || module.exports;
4892
4893}());
4894
4895hljs.registerLanguage('javascript', function () {
4896 'use strict';
4897
4898 const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
4899 const KEYWORDS = [
4900 "as", // for exports
4901 "in",
4902 "of",
4903 "if",
4904 "for",
4905 "while",
4906 "finally",
4907 "var",
4908 "new",
4909 "function",
4910 "do",
4911 "return",
4912 "void",
4913 "else",
4914 "break",
4915 "catch",
4916 "instanceof",
4917 "with",
4918 "throw",
4919 "case",
4920 "default",
4921 "try",
4922 "switch",
4923 "continue",
4924 "typeof",
4925 "delete",
4926 "let",
4927 "yield",
4928 "const",
4929 "class",
4930 // JS handles these with a special rule
4931 // "get",
4932 // "set",
4933 "debugger",
4934 "async",
4935 "await",
4936 "static",
4937 "import",
4938 "from",
4939 "export",
4940 "extends"
4941 ];
4942 const LITERALS = [
4943 "true",
4944 "false",
4945 "null",
4946 "undefined",
4947 "NaN",
4948 "Infinity"
4949 ];
4950
4951 const TYPES = [
4952 "Intl",
4953 "DataView",
4954 "Number",
4955 "Math",
4956 "Date",
4957 "String",
4958 "RegExp",
4959 "Object",
4960 "Function",
4961 "Boolean",
4962 "Error",
4963 "Symbol",
4964 "Set",
4965 "Map",
4966 "WeakSet",
4967 "WeakMap",
4968 "Proxy",
4969 "Reflect",
4970 "JSON",
4971 "Promise",
4972 "Float64Array",
4973 "Int16Array",
4974 "Int32Array",
4975 "Int8Array",
4976 "Uint16Array",
4977 "Uint32Array",
4978 "Float32Array",
4979 "Array",
4980 "Uint8Array",
4981 "Uint8ClampedArray",
4982 "ArrayBuffer"
4983 ];
4984
4985 const ERROR_TYPES = [
4986 "EvalError",
4987 "InternalError",
4988 "RangeError",
4989 "ReferenceError",
4990 "SyntaxError",
4991 "TypeError",
4992 "URIError"
4993 ];
4994
4995 const BUILT_IN_GLOBALS = [
4996 "setInterval",
4997 "setTimeout",
4998 "clearInterval",
4999 "clearTimeout",
5000
5001 "require",
5002 "exports",
5003
5004 "eval",
5005 "isFinite",
5006 "isNaN",
5007 "parseFloat",
5008 "parseInt",
5009 "decodeURI",
5010 "decodeURIComponent",
5011 "encodeURI",
5012 "encodeURIComponent",
5013 "escape",
5014 "unescape"
5015 ];
5016
5017 const BUILT_IN_VARIABLES = [
5018 "arguments",
5019 "this",
5020 "super",
5021 "console",
5022 "window",
5023 "document",
5024 "localStorage",
5025 "module",
5026 "global" // Node.js
5027 ];
5028
5029 const BUILT_INS = [].concat(
5030 BUILT_IN_GLOBALS,
5031 BUILT_IN_VARIABLES,
5032 TYPES,
5033 ERROR_TYPES
5034 );
5035
5036 /**
5037 * @param {string} value
5038 * @returns {RegExp}
5039 * */
5040
5041 /**
5042 * @param {RegExp | string } re
5043 * @returns {string}
5044 */
5045 function source(re) {
5046 if (!re) return null;
5047 if (typeof re === "string") return re;
5048
5049 return re.source;
5050 }
5051
5052 /**
5053 * @param {RegExp | string } re
5054 * @returns {string}
5055 */
5056 function lookahead(re) {
5057 return concat('(?=', re, ')');
5058 }
5059
5060 /**
5061 * @param {...(RegExp | string) } args
5062 * @returns {string}
5063 */
5064 function concat(...args) {
5065 const joined = args.map((x) => source(x)).join("");
5066 return joined;
5067 }
5068
5069 /*
5070 Language: JavaScript
5071 Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
5072 Category: common, scripting
5073 Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
5074 */
5075
5076 /** @type LanguageFn */
5077 function javascript(hljs) {
5078 /**
5079 * Takes a string like "<Booger" and checks to see
5080 * if we can find a matching "</Booger" later in the
5081 * content.
5082 * @param {RegExpMatchArray} match
5083 * @param {{after:number}} param1
5084 */
5085 const hasClosingTag = (match, { after }) => {
5086 const tag = "</" + match[0].slice(1);
5087 const pos = match.input.indexOf(tag, after);
5088 return pos !== -1;
5089 };
5090
5091 const IDENT_RE$1 = IDENT_RE;
5092 const FRAGMENT = {
5093 begin: '<>',
5094 end: '</>'
5095 };
5096 const XML_TAG = {
5097 begin: /<[A-Za-z0-9\\._:-]+/,
5098 end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
5099 /**
5100 * @param {RegExpMatchArray} match
5101 * @param {CallbackResponse} response
5102 */
5103 isTrulyOpeningTag: (match, response) => {
5104 const afterMatchIndex = match[0].length + match.index;
5105 const nextChar = match.input[afterMatchIndex];
5106 // nested type?
5107 // HTML should not include another raw `<` inside a tag
5108 // But a type might: `<Array<Array<number>>`, etc.
5109 if (nextChar === "<") {
5110 response.ignoreMatch();
5111 return;
5112 }
5113 // <something>
5114 // This is now either a tag or a type.
5115 if (nextChar === ">") {
5116 // if we cannot find a matching closing tag, then we
5117 // will ignore it
5118 if (!hasClosingTag(match, { after: afterMatchIndex })) {
5119 response.ignoreMatch();
5120 }
5121 }
5122 }
5123 };
5124 const KEYWORDS$1 = {
5125 $pattern: IDENT_RE,
5126 keyword: KEYWORDS.join(" "),
5127 literal: LITERALS.join(" "),
5128 built_in: BUILT_INS.join(" ")
5129 };
5130
5131 // https://tc39.es/ecma262/#sec-literals-numeric-literals
5132 const decimalDigits = '[0-9](_?[0-9])*';
5133 const frac = `\\.(${decimalDigits})`;
5134 // DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
5135 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
5136 const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
5137 const NUMBER = {
5138 className: 'number',
5139 variants: [
5140 // DecimalLiteral
5141 { begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))` +
5142 `[eE][+-]?(${decimalDigits})\\b` },
5143 { begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
5144
5145 // DecimalBigIntegerLiteral
5146 { begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
5147
5148 // NonDecimalIntegerLiteral
5149 { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
5150 { begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
5151 { begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
5152
5153 // LegacyOctalIntegerLiteral (does not include underscore separators)
5154 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
5155 { begin: "\\b0[0-7]+n?\\b" },
5156 ],
5157 relevance: 0
5158 };
5159
5160 const SUBST = {
5161 className: 'subst',
5162 begin: '\\$\\{',
5163 end: '\\}',
5164 keywords: KEYWORDS$1,
5165 contains: [] // defined later
5166 };
5167 const HTML_TEMPLATE = {
5168 begin: 'html`',
5169 end: '',
5170 starts: {
5171 end: '`',
5172 returnEnd: false,
5173 contains: [
5174 hljs.BACKSLASH_ESCAPE,
5175 SUBST
5176 ],
5177 subLanguage: 'xml'
5178 }
5179 };
5180 const CSS_TEMPLATE = {
5181 begin: 'css`',
5182 end: '',
5183 starts: {
5184 end: '`',
5185 returnEnd: false,
5186 contains: [
5187 hljs.BACKSLASH_ESCAPE,
5188 SUBST
5189 ],
5190 subLanguage: 'css'
5191 }
5192 };
5193 const TEMPLATE_STRING = {
5194 className: 'string',
5195 begin: '`',
5196 end: '`',
5197 contains: [
5198 hljs.BACKSLASH_ESCAPE,
5199 SUBST
5200 ]
5201 };
5202 const JSDOC_COMMENT = hljs.COMMENT(
5203 /\/\*\*(?!\/)/,
5204 '\\*/',
5205 {
5206 relevance: 0,
5207 contains: [
5208 {
5209 className: 'doctag',
5210 begin: '@[A-Za-z]+',
5211 contains: [
5212 {
5213 className: 'type',
5214 begin: '\\{',
5215 end: '\\}',
5216 relevance: 0
5217 },
5218 {
5219 className: 'variable',
5220 begin: IDENT_RE$1 + '(?=\\s*(-)|$)',
5221 endsParent: true,
5222 relevance: 0
5223 },
5224 // eat spaces (not newlines) so we can find
5225 // types or variables
5226 {
5227 begin: /(?=[^\n])\s/,
5228 relevance: 0
5229 }
5230 ]
5231 }
5232 ]
5233 }
5234 );
5235 const COMMENT = {
5236 className: "comment",
5237 variants: [
5238 JSDOC_COMMENT,
5239 hljs.C_BLOCK_COMMENT_MODE,
5240 hljs.C_LINE_COMMENT_MODE
5241 ]
5242 };
5243 const SUBST_INTERNALS = [
5244 hljs.APOS_STRING_MODE,
5245 hljs.QUOTE_STRING_MODE,
5246 HTML_TEMPLATE,
5247 CSS_TEMPLATE,
5248 TEMPLATE_STRING,
5249 NUMBER,
5250 hljs.REGEXP_MODE
5251 ];
5252 SUBST.contains = SUBST_INTERNALS
5253 .concat({
5254 // we need to pair up {} inside our subst to prevent
5255 // it from ending too early by matching another }
5256 begin: /\{/,
5257 end: /\}/,
5258 keywords: KEYWORDS$1,
5259 contains: [
5260 "self"
5261 ].concat(SUBST_INTERNALS)
5262 });
5263 const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
5264 const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
5265 // eat recursive parens in sub expressions
5266 {
5267 begin: /\(/,
5268 end: /\)/,
5269 keywords: KEYWORDS$1,
5270 contains: ["self"].concat(SUBST_AND_COMMENTS)
5271 }
5272 ]);
5273 const PARAMS = {
5274 className: 'params',
5275 begin: /\(/,
5276 end: /\)/,
5277 excludeBegin: true,
5278 excludeEnd: true,
5279 keywords: KEYWORDS$1,
5280 contains: PARAMS_CONTAINS
5281 };
5282
5283 return {
5284 name: 'Javascript',
5285 aliases: ['js', 'jsx', 'mjs', 'cjs'],
5286 keywords: KEYWORDS$1,
5287 // this will be extended by TypeScript
5288 exports: { PARAMS_CONTAINS },
5289 illegal: /#(?![$_A-z])/,
5290 contains: [
5291 hljs.SHEBANG({
5292 label: "shebang",
5293 binary: "node",
5294 relevance: 5
5295 }),
5296 {
5297 label: "use_strict",
5298 className: 'meta',
5299 relevance: 10,
5300 begin: /^\s*['"]use (strict|asm)['"]/
5301 },
5302 hljs.APOS_STRING_MODE,
5303 hljs.QUOTE_STRING_MODE,
5304 HTML_TEMPLATE,
5305 CSS_TEMPLATE,
5306 TEMPLATE_STRING,
5307 COMMENT,
5308 NUMBER,
5309 { // object attr container
5310 begin: concat(/[{,\n]\s*/,
5311 // we need to look ahead to make sure that we actually have an
5312 // attribute coming up so we don't steal a comma from a potential
5313 // "value" container
5314 //
5315 // NOTE: this might not work how you think. We don't actually always
5316 // enter this mode and stay. Instead it might merely match `,
5317 // <comments up next>` and then immediately end after the , because it
5318 // fails to find any actual attrs. But this still does the job because
5319 // it prevents the value contain rule from grabbing this instead and
5320 // prevening this rule from firing when we actually DO have keys.
5321 lookahead(concat(
5322 // we also need to allow for multiple possible comments inbetween
5323 // the first key:value pairing
5324 /(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,
5325 IDENT_RE$1 + '\\s*:'))),
5326 relevance: 0,
5327 contains: [
5328 {
5329 className: 'attr',
5330 begin: IDENT_RE$1 + lookahead('\\s*:'),
5331 relevance: 0
5332 }
5333 ]
5334 },
5335 { // "value" container
5336 begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
5337 keywords: 'return throw case',
5338 contains: [
5339 COMMENT,
5340 hljs.REGEXP_MODE,
5341 {
5342 className: 'function',
5343 // we have to count the parens to make sure we actually have the
5344 // correct bounding ( ) before the =>. There could be any number of
5345 // sub-expressions inside also surrounded by parens.
5346 begin: '(\\(' +
5347 '[^()]*(\\(' +
5348 '[^()]*(\\(' +
5349 '[^()]*' +
5350 '\\)[^()]*)*' +
5351 '\\)[^()]*)*' +
5352 '\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>',
5353 returnBegin: true,
5354 end: '\\s*=>',
5355 contains: [
5356 {
5357 className: 'params',
5358 variants: [
5359 {
5360 begin: hljs.UNDERSCORE_IDENT_RE,
5361 relevance: 0
5362 },
5363 {
5364 className: null,
5365 begin: /\(\s*\)/,
5366 skip: true
5367 },
5368 {
5369 begin: /\(/,
5370 end: /\)/,
5371 excludeBegin: true,
5372 excludeEnd: true,
5373 keywords: KEYWORDS$1,
5374 contains: PARAMS_CONTAINS
5375 }
5376 ]
5377 }
5378 ]
5379 },
5380 { // could be a comma delimited list of params to a function call
5381 begin: /,/, relevance: 0
5382 },
5383 {
5384 className: '',
5385 begin: /\s/,
5386 end: /\s*/,
5387 skip: true
5388 },
5389 { // JSX
5390 variants: [
5391 { begin: FRAGMENT.begin, end: FRAGMENT.end },
5392 {
5393 begin: XML_TAG.begin,
5394 // we carefully check the opening tag to see if it truly
5395 // is a tag and not a false positive
5396 'on:begin': XML_TAG.isTrulyOpeningTag,
5397 end: XML_TAG.end
5398 }
5399 ],
5400 subLanguage: 'xml',
5401 contains: [
5402 {
5403 begin: XML_TAG.begin,
5404 end: XML_TAG.end,
5405 skip: true,
5406 contains: ['self']
5407 }
5408 ]
5409 }
5410 ],
5411 relevance: 0
5412 },
5413 {
5414 className: 'function',
5415 beginKeywords: 'function',
5416 end: /[{;]/,
5417 excludeEnd: true,
5418 keywords: KEYWORDS$1,
5419 contains: [
5420 'self',
5421 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5422 PARAMS
5423 ],
5424 illegal: /%/
5425 },
5426 {
5427 // prevent this from getting swallowed up by function
5428 // since they appear "function like"
5429 beginKeywords: "while if switch catch for"
5430 },
5431 {
5432 className: 'function',
5433 // we have to count the parens to make sure we actually have the correct
5434 // bounding ( ). There could be any number of sub-expressions inside
5435 // also surrounded by parens.
5436 begin: hljs.UNDERSCORE_IDENT_RE +
5437 '\\(' + // first parens
5438 '[^()]*(\\(' +
5439 '[^()]*(\\(' +
5440 '[^()]*' +
5441 '\\)[^()]*)*' +
5442 '\\)[^()]*)*' +
5443 '\\)\\s*\\{', // end parens
5444 returnBegin:true,
5445 contains: [
5446 PARAMS,
5447 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5448 ]
5449 },
5450 // hack: prevents detection of keywords in some circumstances
5451 // .keyword()
5452 // $keyword = x
5453 {
5454 variants: [
5455 { begin: '\\.' + IDENT_RE$1 },
5456 { begin: '\\$' + IDENT_RE$1 }
5457 ],
5458 relevance: 0
5459 },
5460 { // ES6 class
5461 className: 'class',
5462 beginKeywords: 'class',
5463 end: /[{;=]/,
5464 excludeEnd: true,
5465 illegal: /[:"[\]]/,
5466 contains: [
5467 { beginKeywords: 'extends' },
5468 hljs.UNDERSCORE_TITLE_MODE
5469 ]
5470 },
5471 {
5472 begin: /\b(?=constructor)/,
5473 end: /[{;]/,
5474 excludeEnd: true,
5475 contains: [
5476 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5477 'self',
5478 PARAMS
5479 ]
5480 },
5481 {
5482 begin: '(get|set)\\s+(?=' + IDENT_RE$1 + '\\()',
5483 end: /\{/,
5484 keywords: "get set",
5485 contains: [
5486 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5487 { begin: /\(\)/ }, // eat to avoid empty params
5488 PARAMS
5489 ]
5490 },
5491 {
5492 begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
5493 }
5494 ]
5495 };
5496 }
5497
5498 return javascript;
5499
5500 return module.exports.definer || module.exports;
5501
5502}());
5503
5504hljs.registerLanguage('json', function () {
5505 'use strict';
5506
5507 /*
5508 Language: JSON
5509 Description: JSON (JavaScript Object Notation) is a lightweight data-interchange format.
5510 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
5511 Website: http://www.json.org
5512 Category: common, protocols
5513 */
5514
5515 function json(hljs) {
5516 const LITERALS = {
5517 literal: 'true false null'
5518 };
5519 const ALLOWED_COMMENTS = [
5520 hljs.C_LINE_COMMENT_MODE,
5521 hljs.C_BLOCK_COMMENT_MODE
5522 ];
5523 const TYPES = [
5524 hljs.QUOTE_STRING_MODE,
5525 hljs.C_NUMBER_MODE
5526 ];
5527 const VALUE_CONTAINER = {
5528 end: ',',
5529 endsWithParent: true,
5530 excludeEnd: true,
5531 contains: TYPES,
5532 keywords: LITERALS
5533 };
5534 const OBJECT = {
5535 begin: /\{/,
5536 end: /\}/,
5537 contains: [
5538 {
5539 className: 'attr',
5540 begin: /"/,
5541 end: /"/,
5542 contains: [hljs.BACKSLASH_ESCAPE],
5543 illegal: '\\n'
5544 },
5545 hljs.inherit(VALUE_CONTAINER, {
5546 begin: /:/
5547 })
5548 ].concat(ALLOWED_COMMENTS),
5549 illegal: '\\S'
5550 };
5551 const ARRAY = {
5552 begin: '\\[',
5553 end: '\\]',
5554 contains: [hljs.inherit(VALUE_CONTAINER)], // inherit is a workaround for a bug that makes shared modes with endsWithParent compile only the ending of one of the parents
5555 illegal: '\\S'
5556 };
5557 TYPES.push(OBJECT, ARRAY);
5558 ALLOWED_COMMENTS.forEach(function(rule) {
5559 TYPES.push(rule);
5560 });
5561 return {
5562 name: 'JSON',
5563 contains: TYPES,
5564 keywords: LITERALS,
5565 illegal: '\\S'
5566 };
5567 }
5568
5569 return json;
5570
5571 return module.exports.definer || module.exports;
5572
5573}());
5574
5575hljs.registerLanguage('kotlin', function () {
5576 'use strict';
5577
5578 // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10
5579 var decimalDigits = '[0-9](_*[0-9])*';
5580 var frac = `\\.(${decimalDigits})`;
5581 var hexDigits = '[0-9a-fA-F](_*[0-9a-fA-F])*';
5582 var NUMERIC = {
5583 className: 'number',
5584 variants: [
5585 // DecimalFloatingPointLiteral
5586 // including ExponentPart
5587 { begin: `(\\b(${decimalDigits})((${frac})|\\.)?|(${frac}))` +
5588 `[eE][+-]?(${decimalDigits})[fFdD]?\\b` },
5589 // excluding ExponentPart
5590 { begin: `\\b(${decimalDigits})((${frac})[fFdD]?\\b|\\.([fFdD]\\b)?)` },
5591 { begin: `(${frac})[fFdD]?\\b` },
5592 { begin: `\\b(${decimalDigits})[fFdD]\\b` },
5593
5594 // HexadecimalFloatingPointLiteral
5595 { begin: `\\b0[xX]((${hexDigits})\\.?|(${hexDigits})?\\.(${hexDigits}))` +
5596 `[pP][+-]?(${decimalDigits})[fFdD]?\\b` },
5597
5598 // DecimalIntegerLiteral
5599 { begin: '\\b(0|[1-9](_*[0-9])*)[lL]?\\b' },
5600
5601 // HexIntegerLiteral
5602 { begin: `\\b0[xX](${hexDigits})[lL]?\\b` },
5603
5604 // OctalIntegerLiteral
5605 { begin: '\\b0(_*[0-7])*[lL]?\\b' },
5606
5607 // BinaryIntegerLiteral
5608 { begin: '\\b0[bB][01](_*[01])*[lL]?\\b' },
5609 ],
5610 relevance: 0
5611 };
5612
5613 /*
5614 Language: Kotlin
5615 Description: Kotlin is an OSS statically typed programming language that targets the JVM, Android, JavaScript and Native.
5616 Author: Sergey Mashkov <cy6erGn0m@gmail.com>
5617 Website: https://kotlinlang.org
5618 Category: common
5619 */
5620
5621 function kotlin(hljs) {
5622 const KEYWORDS = {
5623 keyword:
5624 'abstract as val var vararg get set class object open private protected public noinline ' +
5625 'crossinline dynamic final enum if else do while for when throw try catch finally ' +
5626 'import package is in fun override companion reified inline lateinit init ' +
5627 'interface annotation data sealed internal infix operator out by constructor super ' +
5628 'tailrec where const inner suspend typealias external expect actual',
5629 built_in:
5630 'Byte Short Char Int Long Boolean Float Double Void Unit Nothing',
5631 literal:
5632 'true false null'
5633 };
5634 const KEYWORDS_WITH_LABEL = {
5635 className: 'keyword',
5636 begin: /\b(break|continue|return|this)\b/,
5637 starts: {
5638 contains: [
5639 {
5640 className: 'symbol',
5641 begin: /@\w+/
5642 }
5643 ]
5644 }
5645 };
5646 const LABEL = {
5647 className: 'symbol',
5648 begin: hljs.UNDERSCORE_IDENT_RE + '@'
5649 };
5650
5651 // for string templates
5652 const SUBST = {
5653 className: 'subst',
5654 begin: /\$\{/,
5655 end: /\}/,
5656 contains: [ hljs.C_NUMBER_MODE ]
5657 };
5658 const VARIABLE = {
5659 className: 'variable',
5660 begin: '\\$' + hljs.UNDERSCORE_IDENT_RE
5661 };
5662 const STRING = {
5663 className: 'string',
5664 variants: [
5665 {
5666 begin: '"""',
5667 end: '"""(?=[^"])',
5668 contains: [
5669 VARIABLE,
5670 SUBST
5671 ]
5672 },
5673 // Can't use built-in modes easily, as we want to use STRING in the meta
5674 // context as 'meta-string' and there's no syntax to remove explicitly set
5675 // classNames in built-in modes.
5676 {
5677 begin: '\'',
5678 end: '\'',
5679 illegal: /\n/,
5680 contains: [ hljs.BACKSLASH_ESCAPE ]
5681 },
5682 {
5683 begin: '"',
5684 end: '"',
5685 illegal: /\n/,
5686 contains: [
5687 hljs.BACKSLASH_ESCAPE,
5688 VARIABLE,
5689 SUBST
5690 ]
5691 }
5692 ]
5693 };
5694 SUBST.contains.push(STRING);
5695
5696 const ANNOTATION_USE_SITE = {
5697 className: 'meta',
5698 begin: '@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*' + hljs.UNDERSCORE_IDENT_RE + ')?'
5699 };
5700 const ANNOTATION = {
5701 className: 'meta',
5702 begin: '@' + hljs.UNDERSCORE_IDENT_RE,
5703 contains: [
5704 {
5705 begin: /\(/,
5706 end: /\)/,
5707 contains: [
5708 hljs.inherit(STRING, {
5709 className: 'meta-string'
5710 })
5711 ]
5712 }
5713 ]
5714 };
5715
5716 // https://kotlinlang.org/docs/reference/whatsnew11.html#underscores-in-numeric-literals
5717 // According to the doc above, the number mode of kotlin is the same as java 8,
5718 // so the code below is copied from java.js
5719 const KOTLIN_NUMBER_MODE = NUMERIC;
5720 const KOTLIN_NESTED_COMMENT = hljs.COMMENT(
5721 '/\\*', '\\*/',
5722 {
5723 contains: [ hljs.C_BLOCK_COMMENT_MODE ]
5724 }
5725 );
5726 const KOTLIN_PAREN_TYPE = {
5727 variants: [
5728 {
5729 className: 'type',
5730 begin: hljs.UNDERSCORE_IDENT_RE
5731 },
5732 {
5733 begin: /\(/,
5734 end: /\)/,
5735 contains: [] // defined later
5736 }
5737 ]
5738 };
5739 const KOTLIN_PAREN_TYPE2 = KOTLIN_PAREN_TYPE;
5740 KOTLIN_PAREN_TYPE2.variants[1].contains = [ KOTLIN_PAREN_TYPE ];
5741 KOTLIN_PAREN_TYPE.variants[1].contains = [ KOTLIN_PAREN_TYPE2 ];
5742
5743 return {
5744 name: 'Kotlin',
5745 aliases: [ 'kt' ],
5746 keywords: KEYWORDS,
5747 contains: [
5748 hljs.COMMENT(
5749 '/\\*\\*',
5750 '\\*/',
5751 {
5752 relevance: 0,
5753 contains: [
5754 {
5755 className: 'doctag',
5756 begin: '@[A-Za-z]+'
5757 }
5758 ]
5759 }
5760 ),
5761 hljs.C_LINE_COMMENT_MODE,
5762 KOTLIN_NESTED_COMMENT,
5763 KEYWORDS_WITH_LABEL,
5764 LABEL,
5765 ANNOTATION_USE_SITE,
5766 ANNOTATION,
5767 {
5768 className: 'function',
5769 beginKeywords: 'fun',
5770 end: '[(]|$',
5771 returnBegin: true,
5772 excludeEnd: true,
5773 keywords: KEYWORDS,
5774 relevance: 5,
5775 contains: [
5776 {
5777 begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(',
5778 returnBegin: true,
5779 relevance: 0,
5780 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
5781 },
5782 {
5783 className: 'type',
5784 begin: /</,
5785 end: />/,
5786 keywords: 'reified',
5787 relevance: 0
5788 },
5789 {
5790 className: 'params',
5791 begin: /\(/,
5792 end: /\)/,
5793 endsParent: true,
5794 keywords: KEYWORDS,
5795 relevance: 0,
5796 contains: [
5797 {
5798 begin: /:/,
5799 end: /[=,\/]/,
5800 endsWithParent: true,
5801 contains: [
5802 KOTLIN_PAREN_TYPE,
5803 hljs.C_LINE_COMMENT_MODE,
5804 KOTLIN_NESTED_COMMENT
5805 ],
5806 relevance: 0
5807 },
5808 hljs.C_LINE_COMMENT_MODE,
5809 KOTLIN_NESTED_COMMENT,
5810 ANNOTATION_USE_SITE,
5811 ANNOTATION,
5812 STRING,
5813 hljs.C_NUMBER_MODE
5814 ]
5815 },
5816 KOTLIN_NESTED_COMMENT
5817 ]
5818 },
5819 {
5820 className: 'class',
5821 beginKeywords: 'class interface trait', // remove 'trait' when removed from KEYWORDS
5822 end: /[:\{(]|$/,
5823 excludeEnd: true,
5824 illegal: 'extends implements',
5825 contains: [
5826 {
5827 beginKeywords: 'public protected internal private constructor'
5828 },
5829 hljs.UNDERSCORE_TITLE_MODE,
5830 {
5831 className: 'type',
5832 begin: /</,
5833 end: />/,
5834 excludeBegin: true,
5835 excludeEnd: true,
5836 relevance: 0
5837 },
5838 {
5839 className: 'type',
5840 begin: /[,:]\s*/,
5841 end: /[<\(,]|$/,
5842 excludeBegin: true,
5843 returnEnd: true
5844 },
5845 ANNOTATION_USE_SITE,
5846 ANNOTATION
5847 ]
5848 },
5849 STRING,
5850 {
5851 className: 'meta',
5852 begin: "^#!/usr/bin/env",
5853 end: '$',
5854 illegal: '\n'
5855 },
5856 KOTLIN_NUMBER_MODE
5857 ]
5858 };
5859 }
5860
5861 return kotlin;
5862
5863 return module.exports.definer || module.exports;
5864
5865}());
5866
5867hljs.registerLanguage('less', function () {
5868 'use strict';
5869
5870 /*
5871 Language: Less
5872 Description: It's CSS, with just a little more.
5873 Author: Max Mikhailov <seven.phases.max@gmail.com>
5874 Website: http://lesscss.org
5875 Category: common, css
5876 */
5877
5878 function less(hljs) {
5879 var IDENT_RE = '[\\w-]+'; // yes, Less identifiers may begin with a digit
5880 var INTERP_IDENT_RE = '(' + IDENT_RE + '|@\\{' + IDENT_RE + '\\})';
5881
5882 /* Generic Modes */
5883
5884 var RULES = [], VALUE = []; // forward def. for recursive modes
5885
5886 var STRING_MODE = function(c) { return {
5887 // Less strings are not multiline (also include '~' for more consistent coloring of "escaped" strings)
5888 className: 'string', begin: '~?' + c + '.*?' + c
5889 };};
5890
5891 var IDENT_MODE = function(name, begin, relevance) { return {
5892 className: name, begin: begin, relevance: relevance
5893 };};
5894
5895 var PARENS_MODE = {
5896 // used only to properly balance nested parens inside mixin call, def. arg list
5897 begin: '\\(', end: '\\)', contains: VALUE, relevance: 0
5898 };
5899
5900 // generic Less highlighter (used almost everywhere except selectors):
5901 VALUE.push(
5902 hljs.C_LINE_COMMENT_MODE,
5903 hljs.C_BLOCK_COMMENT_MODE,
5904 STRING_MODE("'"),
5905 STRING_MODE('"'),
5906 hljs.CSS_NUMBER_MODE, // fixme: it does not include dot for numbers like .5em :(
5907 {
5908 begin: '(url|data-uri)\\(',
5909 starts: {className: 'string', end: '[\\)\\n]', excludeEnd: true}
5910 },
5911 IDENT_MODE('number', '#[0-9A-Fa-f]+\\b'),
5912 PARENS_MODE,
5913 IDENT_MODE('variable', '@@?' + IDENT_RE, 10),
5914 IDENT_MODE('variable', '@\\{' + IDENT_RE + '\\}'),
5915 IDENT_MODE('built_in', '~?`[^`]*?`'), // inline javascript (or whatever host language) *multiline* string
5916 { // @media features (it’s here to not duplicate things in AT_RULE_MODE with extra PARENS_MODE overriding):
5917 className: 'attribute', begin: IDENT_RE + '\\s*:', end: ':', returnBegin: true, excludeEnd: true
5918 },
5919 {
5920 className: 'meta',
5921 begin: '!important'
5922 }
5923 );
5924
5925 var VALUE_WITH_RULESETS = VALUE.concat({
5926 begin: /\{/, end: /\}/, contains: RULES
5927 });
5928
5929 var MIXIN_GUARD_MODE = {
5930 beginKeywords: 'when', endsWithParent: true,
5931 contains: [{beginKeywords: 'and not'}].concat(VALUE) // using this form to override VALUE’s 'function' match
5932 };
5933
5934 /* Rule-Level Modes */
5935
5936 var RULE_MODE = {
5937 begin: INTERP_IDENT_RE + '\\s*:', returnBegin: true, end: '[;}]',
5938 relevance: 0,
5939 contains: [
5940 {
5941 className: 'attribute',
5942 begin: INTERP_IDENT_RE, end: ':', excludeEnd: true,
5943 starts: {
5944 endsWithParent: true, illegal: '[<=$]',
5945 relevance: 0,
5946 contains: VALUE
5947 }
5948 }
5949 ]
5950 };
5951
5952 var AT_RULE_MODE = {
5953 className: 'keyword',
5954 begin: '@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b',
5955 starts: {end: '[;{}]', returnEnd: true, contains: VALUE, relevance: 0}
5956 };
5957
5958 // variable definitions and calls
5959 var VAR_RULE_MODE = {
5960 className: 'variable',
5961 variants: [
5962 // using more strict pattern for higher relevance to increase chances of Less detection.
5963 // this is *the only* Less specific statement used in most of the sources, so...
5964 // (we’ll still often loose to the css-parser unless there's '//' comment,
5965 // simply because 1 variable just can't beat 99 properties :)
5966 {begin: '@' + IDENT_RE + '\\s*:', relevance: 15},
5967 {begin: '@' + IDENT_RE}
5968 ],
5969 starts: {end: '[;}]', returnEnd: true, contains: VALUE_WITH_RULESETS}
5970 };
5971
5972 var SELECTOR_MODE = {
5973 // first parse unambiguous selectors (i.e. those not starting with tag)
5974 // then fall into the scary lookahead-discriminator variant.
5975 // this mode also handles mixin definitions and calls
5976 variants: [{
5977 begin: '[\\.#:&\\[>]', end: '[;{}]' // mixin calls end with ';'
5978 }, {
5979 begin: INTERP_IDENT_RE, end: /\{/
5980 }],
5981 returnBegin: true,
5982 returnEnd: true,
5983 illegal: '[<=\'$"]',
5984 relevance: 0,
5985 contains: [
5986 hljs.C_LINE_COMMENT_MODE,
5987 hljs.C_BLOCK_COMMENT_MODE,
5988 MIXIN_GUARD_MODE,
5989 IDENT_MODE('keyword', 'all\\b'),
5990 IDENT_MODE('variable', '@\\{' + IDENT_RE + '\\}'), // otherwise it’s identified as tag
5991 IDENT_MODE('selector-tag', INTERP_IDENT_RE + '%?', 0), // '%' for more consistent coloring of @keyframes "tags"
5992 IDENT_MODE('selector-id', '#' + INTERP_IDENT_RE),
5993 IDENT_MODE('selector-class', '\\.' + INTERP_IDENT_RE, 0),
5994 IDENT_MODE('selector-tag', '&', 0),
5995 {className: 'selector-attr', begin: '\\[', end: '\\]'},
5996 {className: 'selector-pseudo', begin: /:(:)?[a-zA-Z0-9_\-+()"'.]+/},
5997 {begin: '\\(', end: '\\)', contains: VALUE_WITH_RULESETS}, // argument list of parametric mixins
5998 {begin: '!important'} // eat !important after mixin call or it will be colored as tag
5999 ]
6000 };
6001
6002 RULES.push(
6003 hljs.C_LINE_COMMENT_MODE,
6004 hljs.C_BLOCK_COMMENT_MODE,
6005 AT_RULE_MODE,
6006 VAR_RULE_MODE,
6007 RULE_MODE,
6008 SELECTOR_MODE
6009 );
6010
6011 return {
6012 name: 'Less',
6013 case_insensitive: true,
6014 illegal: '[=>\'/<($"]',
6015 contains: RULES
6016 };
6017 }
6018
6019 return less;
6020
6021 return module.exports.definer || module.exports;
6022
6023}());
6024
6025hljs.registerLanguage('lua', function () {
6026 'use strict';
6027
6028 /*
6029 Language: Lua
6030 Description: Lua is a powerful, efficient, lightweight, embeddable scripting language.
6031 Author: Andrew Fedorov <dmmdrs@mail.ru>
6032 Category: common, scripting
6033 Website: https://www.lua.org
6034 */
6035
6036 function lua(hljs) {
6037 const OPENING_LONG_BRACKET = '\\[=*\\[';
6038 const CLOSING_LONG_BRACKET = '\\]=*\\]';
6039 const LONG_BRACKETS = {
6040 begin: OPENING_LONG_BRACKET,
6041 end: CLOSING_LONG_BRACKET,
6042 contains: ['self']
6043 };
6044 const COMMENTS = [
6045 hljs.COMMENT('--(?!' + OPENING_LONG_BRACKET + ')', '$'),
6046 hljs.COMMENT(
6047 '--' + OPENING_LONG_BRACKET,
6048 CLOSING_LONG_BRACKET,
6049 {
6050 contains: [LONG_BRACKETS],
6051 relevance: 10
6052 }
6053 )
6054 ];
6055 return {
6056 name: 'Lua',
6057 keywords: {
6058 $pattern: hljs.UNDERSCORE_IDENT_RE,
6059 literal: "true false nil",
6060 keyword: "and break do else elseif end for goto if in local not or repeat return then until while",
6061 built_in:
6062 // Metatags and globals:
6063 '_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len ' +
6064 '__gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert ' +
6065 // Standard methods and properties:
6066 'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring ' +
6067 'module next pairs pcall print rawequal rawget rawset require select setfenv ' +
6068 'setmetatable tonumber tostring type unpack xpcall arg self ' +
6069 // Library methods and properties (one line per library):
6070 'coroutine resume yield status wrap create running debug getupvalue ' +
6071 'debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv ' +
6072 'io lines write close flush open output type read stderr stdin input stdout popen tmpfile ' +
6073 'math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan ' +
6074 'os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall ' +
6075 'string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower ' +
6076 'table setn insert getn foreachi maxn foreach concat sort remove'
6077 },
6078 contains: COMMENTS.concat([
6079 {
6080 className: 'function',
6081 beginKeywords: 'function',
6082 end: '\\)',
6083 contains: [
6084 hljs.inherit(hljs.TITLE_MODE, {
6085 begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*'
6086 }),
6087 {
6088 className: 'params',
6089 begin: '\\(',
6090 endsWithParent: true,
6091 contains: COMMENTS
6092 }
6093 ].concat(COMMENTS)
6094 },
6095 hljs.C_NUMBER_MODE,
6096 hljs.APOS_STRING_MODE,
6097 hljs.QUOTE_STRING_MODE,
6098 {
6099 className: 'string',
6100 begin: OPENING_LONG_BRACKET,
6101 end: CLOSING_LONG_BRACKET,
6102 contains: [LONG_BRACKETS],
6103 relevance: 5
6104 }
6105 ])
6106 };
6107 }
6108
6109 return lua;
6110
6111 return module.exports.definer || module.exports;
6112
6113}());
6114
6115hljs.registerLanguage('makefile', function () {
6116 'use strict';
6117
6118 /*
6119 Language: Makefile
6120 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
6121 Contributors: Joël Porquet <joel@porquet.org>
6122 Website: https://www.gnu.org/software/make/manual/html_node/Introduction.html
6123 Category: common
6124 */
6125
6126 function makefile(hljs) {
6127 /* Variables: simple (eg $(var)) and special (eg $@) */
6128 const VARIABLE = {
6129 className: 'variable',
6130 variants: [
6131 {
6132 begin: '\\$\\(' + hljs.UNDERSCORE_IDENT_RE + '\\)',
6133 contains: [ hljs.BACKSLASH_ESCAPE ]
6134 },
6135 {
6136 begin: /\$[@%<?\^\+\*]/
6137 }
6138 ]
6139 };
6140 /* Quoted string with variables inside */
6141 const QUOTE_STRING = {
6142 className: 'string',
6143 begin: /"/,
6144 end: /"/,
6145 contains: [
6146 hljs.BACKSLASH_ESCAPE,
6147 VARIABLE
6148 ]
6149 };
6150 /* Function: $(func arg,...) */
6151 const FUNC = {
6152 className: 'variable',
6153 begin: /\$\([\w-]+\s/,
6154 end: /\)/,
6155 keywords: {
6156 built_in:
6157 'subst patsubst strip findstring filter filter-out sort ' +
6158 'word wordlist firstword lastword dir notdir suffix basename ' +
6159 'addsuffix addprefix join wildcard realpath abspath error warning ' +
6160 'shell origin flavor foreach if or and call eval file value'
6161 },
6162 contains: [ VARIABLE ]
6163 };
6164 /* Variable assignment */
6165 const ASSIGNMENT = {
6166 begin: '^' + hljs.UNDERSCORE_IDENT_RE + '\\s*(?=[:+?]?=)'
6167 };
6168 /* Meta targets (.PHONY) */
6169 const META = {
6170 className: 'meta',
6171 begin: /^\.PHONY:/,
6172 end: /$/,
6173 keywords: {
6174 $pattern: /[\.\w]+/,
6175 'meta-keyword': '.PHONY'
6176 }
6177 };
6178 /* Targets */
6179 const TARGET = {
6180 className: 'section',
6181 begin: /^[^\s]+:/,
6182 end: /$/,
6183 contains: [ VARIABLE ]
6184 };
6185 return {
6186 name: 'Makefile',
6187 aliases: [
6188 'mk',
6189 'mak',
6190 'make',
6191 ],
6192 keywords: {
6193 $pattern: /[\w-]+/,
6194 keyword: 'define endef undefine ifdef ifndef ifeq ifneq else endif ' +
6195 'include -include sinclude override export unexport private vpath'
6196 },
6197 contains: [
6198 hljs.HASH_COMMENT_MODE,
6199 VARIABLE,
6200 QUOTE_STRING,
6201 FUNC,
6202 ASSIGNMENT,
6203 META,
6204 TARGET
6205 ]
6206 };
6207 }
6208
6209 return makefile;
6210
6211 return module.exports.definer || module.exports;
6212
6213}());
6214
6215hljs.registerLanguage('xml', function () {
6216 'use strict';
6217
6218 /**
6219 * @param {string} value
6220 * @returns {RegExp}
6221 * */
6222
6223 /**
6224 * @param {RegExp | string } re
6225 * @returns {string}
6226 */
6227 function source(re) {
6228 if (!re) return null;
6229 if (typeof re === "string") return re;
6230
6231 return re.source;
6232 }
6233
6234 /**
6235 * @param {RegExp | string } re
6236 * @returns {string}
6237 */
6238 function lookahead(re) {
6239 return concat('(?=', re, ')');
6240 }
6241
6242 /**
6243 * @param {RegExp | string } re
6244 * @returns {string}
6245 */
6246 function optional(re) {
6247 return concat('(', re, ')?');
6248 }
6249
6250 /**
6251 * @param {...(RegExp | string) } args
6252 * @returns {string}
6253 */
6254 function concat(...args) {
6255 const joined = args.map((x) => source(x)).join("");
6256 return joined;
6257 }
6258
6259 /**
6260 * Any of the passed expresssions may match
6261 *
6262 * Creates a huge this | this | that | that match
6263 * @param {(RegExp | string)[] } args
6264 * @returns {string}
6265 */
6266 function either(...args) {
6267 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
6268 return joined;
6269 }
6270
6271 /*
6272 Language: HTML, XML
6273 Website: https://www.w3.org/XML/
6274 Category: common
6275 Audit: 2020
6276 */
6277
6278 /** @type LanguageFn */
6279 function xml(hljs) {
6280 // Element names can contain letters, digits, hyphens, underscores, and periods
6281 const TAG_NAME_RE = concat(/[A-Z_]/, optional(/[A-Z0-9_.-]+:/), /[A-Z0-9_.-]*/);
6282 const XML_IDENT_RE = /[A-Za-z0-9._:-]+/;
6283 const XML_ENTITIES = {
6284 className: 'symbol',
6285 begin: /&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/
6286 };
6287 const XML_META_KEYWORDS = {
6288 begin: /\s/,
6289 contains: [
6290 {
6291 className: 'meta-keyword',
6292 begin: /#?[a-z_][a-z1-9_-]+/,
6293 illegal: /\n/
6294 }
6295 ]
6296 };
6297 const XML_META_PAR_KEYWORDS = hljs.inherit(XML_META_KEYWORDS, {
6298 begin: /\(/,
6299 end: /\)/
6300 });
6301 const APOS_META_STRING_MODE = hljs.inherit(hljs.APOS_STRING_MODE, {
6302 className: 'meta-string'
6303 });
6304 const QUOTE_META_STRING_MODE = hljs.inherit(hljs.QUOTE_STRING_MODE, {
6305 className: 'meta-string'
6306 });
6307 const TAG_INTERNALS = {
6308 endsWithParent: true,
6309 illegal: /</,
6310 relevance: 0,
6311 contains: [
6312 {
6313 className: 'attr',
6314 begin: XML_IDENT_RE,
6315 relevance: 0
6316 },
6317 {
6318 begin: /=\s*/,
6319 relevance: 0,
6320 contains: [
6321 {
6322 className: 'string',
6323 endsParent: true,
6324 variants: [
6325 {
6326 begin: /"/,
6327 end: /"/,
6328 contains: [ XML_ENTITIES ]
6329 },
6330 {
6331 begin: /'/,
6332 end: /'/,
6333 contains: [ XML_ENTITIES ]
6334 },
6335 {
6336 begin: /[^\s"'=<>`]+/
6337 }
6338 ]
6339 }
6340 ]
6341 }
6342 ]
6343 };
6344 return {
6345 name: 'HTML, XML',
6346 aliases: [
6347 'html',
6348 'xhtml',
6349 'rss',
6350 'atom',
6351 'xjb',
6352 'xsd',
6353 'xsl',
6354 'plist',
6355 'wsf',
6356 'svg'
6357 ],
6358 case_insensitive: true,
6359 contains: [
6360 {
6361 className: 'meta',
6362 begin: /<![a-z]/,
6363 end: />/,
6364 relevance: 10,
6365 contains: [
6366 XML_META_KEYWORDS,
6367 QUOTE_META_STRING_MODE,
6368 APOS_META_STRING_MODE,
6369 XML_META_PAR_KEYWORDS,
6370 {
6371 begin: /\[/,
6372 end: /\]/,
6373 contains: [
6374 {
6375 className: 'meta',
6376 begin: /<![a-z]/,
6377 end: />/,
6378 contains: [
6379 XML_META_KEYWORDS,
6380 XML_META_PAR_KEYWORDS,
6381 QUOTE_META_STRING_MODE,
6382 APOS_META_STRING_MODE
6383 ]
6384 }
6385 ]
6386 }
6387 ]
6388 },
6389 hljs.COMMENT(
6390 /<!--/,
6391 /-->/,
6392 {
6393 relevance: 10
6394 }
6395 ),
6396 {
6397 begin: /<!\[CDATA\[/,
6398 end: /\]\]>/,
6399 relevance: 10
6400 },
6401 XML_ENTITIES,
6402 {
6403 className: 'meta',
6404 begin: /<\?xml/,
6405 end: /\?>/,
6406 relevance: 10
6407 },
6408 {
6409 className: 'tag',
6410 /*
6411 The lookahead pattern (?=...) ensures that 'begin' only matches
6412 '<style' as a single word, followed by a whitespace or an
6413 ending braket. The '$' is needed for the lexeme to be recognized
6414 by hljs.subMode() that tests lexemes outside the stream.
6415 */
6416 begin: /<style(?=\s|>)/,
6417 end: />/,
6418 keywords: {
6419 name: 'style'
6420 },
6421 contains: [ TAG_INTERNALS ],
6422 starts: {
6423 end: /<\/style>/,
6424 returnEnd: true,
6425 subLanguage: [
6426 'css',
6427 'xml'
6428 ]
6429 }
6430 },
6431 {
6432 className: 'tag',
6433 // See the comment in the <style tag about the lookahead pattern
6434 begin: /<script(?=\s|>)/,
6435 end: />/,
6436 keywords: {
6437 name: 'script'
6438 },
6439 contains: [ TAG_INTERNALS ],
6440 starts: {
6441 end: /<\/script>/,
6442 returnEnd: true,
6443 subLanguage: [
6444 'javascript',
6445 'handlebars',
6446 'xml'
6447 ]
6448 }
6449 },
6450 // we need this for now for jSX
6451 {
6452 className: 'tag',
6453 begin: /<>|<\/>/
6454 },
6455 // open tag
6456 {
6457 className: 'tag',
6458 begin: concat(
6459 /</,
6460 lookahead(concat(
6461 TAG_NAME_RE,
6462 // <tag/>
6463 // <tag>
6464 // <tag ...
6465 either(/\/>/, />/, /\s/)
6466 ))
6467 ),
6468 end: /\/?>/,
6469 contains: [
6470 {
6471 className: 'name',
6472 begin: TAG_NAME_RE,
6473 relevance: 0,
6474 starts: TAG_INTERNALS
6475 }
6476 ]
6477 },
6478 // close tag
6479 {
6480 className: 'tag',
6481 begin: concat(
6482 /<\//,
6483 lookahead(concat(
6484 TAG_NAME_RE, />/
6485 ))
6486 ),
6487 contains: [
6488 {
6489 className: 'name',
6490 begin: TAG_NAME_RE,
6491 relevance: 0
6492 },
6493 {
6494 begin: />/,
6495 relevance: 0
6496 }
6497 ]
6498 }
6499 ]
6500 };
6501 }
6502
6503 return xml;
6504
6505 return module.exports.definer || module.exports;
6506
6507}());
6508
6509hljs.registerLanguage('markdown', function () {
6510 'use strict';
6511
6512 /**
6513 * @param {string} value
6514 * @returns {RegExp}
6515 * */
6516
6517 /**
6518 * @param {RegExp | string } re
6519 * @returns {string}
6520 */
6521 function source(re) {
6522 if (!re) return null;
6523 if (typeof re === "string") return re;
6524
6525 return re.source;
6526 }
6527
6528 /**
6529 * @param {...(RegExp | string) } args
6530 * @returns {string}
6531 */
6532 function concat(...args) {
6533 const joined = args.map((x) => source(x)).join("");
6534 return joined;
6535 }
6536
6537 /*
6538 Language: Markdown
6539 Requires: xml.js
6540 Author: John Crepezzi <john.crepezzi@gmail.com>
6541 Website: https://daringfireball.net/projects/markdown/
6542 Category: common, markup
6543 */
6544
6545 function markdown(hljs) {
6546 const INLINE_HTML = {
6547 begin: /<\/?[A-Za-z_]/,
6548 end: '>',
6549 subLanguage: 'xml',
6550 relevance: 0
6551 };
6552 const HORIZONTAL_RULE = {
6553 begin: '^[-\\*]{3,}',
6554 end: '$'
6555 };
6556 const CODE = {
6557 className: 'code',
6558 variants: [
6559 // TODO: fix to allow these to work with sublanguage also
6560 {
6561 begin: '(`{3,})[^`](.|\\n)*?\\1`*[ ]*'
6562 },
6563 {
6564 begin: '(~{3,})[^~](.|\\n)*?\\1~*[ ]*'
6565 },
6566 // needed to allow markdown as a sublanguage to work
6567 {
6568 begin: '```',
6569 end: '```+[ ]*$'
6570 },
6571 {
6572 begin: '~~~',
6573 end: '~~~+[ ]*$'
6574 },
6575 {
6576 begin: '`.+?`'
6577 },
6578 {
6579 begin: '(?=^( {4}|\\t))',
6580 // use contains to gobble up multiple lines to allow the block to be whatever size
6581 // but only have a single open/close tag vs one per line
6582 contains: [
6583 {
6584 begin: '^( {4}|\\t)',
6585 end: '(\\n)$'
6586 }
6587 ],
6588 relevance: 0
6589 }
6590 ]
6591 };
6592 const LIST = {
6593 className: 'bullet',
6594 begin: '^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)',
6595 end: '\\s+',
6596 excludeEnd: true
6597 };
6598 const LINK_REFERENCE = {
6599 begin: /^\[[^\n]+\]:/,
6600 returnBegin: true,
6601 contains: [
6602 {
6603 className: 'symbol',
6604 begin: /\[/,
6605 end: /\]/,
6606 excludeBegin: true,
6607 excludeEnd: true
6608 },
6609 {
6610 className: 'link',
6611 begin: /:\s*/,
6612 end: /$/,
6613 excludeBegin: true
6614 }
6615 ]
6616 };
6617 const URL_SCHEME = /[A-Za-z][A-Za-z0-9+.-]*/;
6618 const LINK = {
6619 variants: [
6620 // too much like nested array access in so many languages
6621 // to have any real relevance
6622 {
6623 begin: /\[.+?\]\[.*?\]/,
6624 relevance: 0
6625 },
6626 // popular internet URLs
6627 {
6628 begin: /\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
6629 relevance: 2
6630 },
6631 {
6632 begin: concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/),
6633 relevance: 2
6634 },
6635 // relative urls
6636 {
6637 begin: /\[.+?\]\([./?&#].*?\)/,
6638 relevance: 1
6639 },
6640 // whatever else, lower relevance (might not be a link at all)
6641 {
6642 begin: /\[.+?\]\(.*?\)/,
6643 relevance: 0
6644 }
6645 ],
6646 returnBegin: true,
6647 contains: [
6648 {
6649 className: 'string',
6650 relevance: 0,
6651 begin: '\\[',
6652 end: '\\]',
6653 excludeBegin: true,
6654 returnEnd: true
6655 },
6656 {
6657 className: 'link',
6658 relevance: 0,
6659 begin: '\\]\\(',
6660 end: '\\)',
6661 excludeBegin: true,
6662 excludeEnd: true
6663 },
6664 {
6665 className: 'symbol',
6666 relevance: 0,
6667 begin: '\\]\\[',
6668 end: '\\]',
6669 excludeBegin: true,
6670 excludeEnd: true
6671 }
6672 ]
6673 };
6674 const BOLD = {
6675 className: 'strong',
6676 contains: [],
6677 variants: [
6678 {
6679 begin: /_{2}/,
6680 end: /_{2}/
6681 },
6682 {
6683 begin: /\*{2}/,
6684 end: /\*{2}/
6685 }
6686 ]
6687 };
6688 const ITALIC = {
6689 className: 'emphasis',
6690 contains: [],
6691 variants: [
6692 {
6693 begin: /\*(?!\*)/,
6694 end: /\*/
6695 },
6696 {
6697 begin: /_(?!_)/,
6698 end: /_/,
6699 relevance: 0
6700 }
6701 ]
6702 };
6703 BOLD.contains.push(ITALIC);
6704 ITALIC.contains.push(BOLD);
6705
6706 let CONTAINABLE = [
6707 INLINE_HTML,
6708 LINK
6709 ];
6710
6711 BOLD.contains = BOLD.contains.concat(CONTAINABLE);
6712 ITALIC.contains = ITALIC.contains.concat(CONTAINABLE);
6713
6714 CONTAINABLE = CONTAINABLE.concat(BOLD, ITALIC);
6715
6716 const HEADER = {
6717 className: 'section',
6718 variants: [
6719 {
6720 begin: '^#{1,6}',
6721 end: '$',
6722 contains: CONTAINABLE
6723 },
6724 {
6725 begin: '(?=^.+?\\n[=-]{2,}$)',
6726 contains: [
6727 {
6728 begin: '^[=-]*$'
6729 },
6730 {
6731 begin: '^',
6732 end: "\\n",
6733 contains: CONTAINABLE
6734 }
6735 ]
6736 }
6737 ]
6738 };
6739
6740 const BLOCKQUOTE = {
6741 className: 'quote',
6742 begin: '^>\\s+',
6743 contains: CONTAINABLE,
6744 end: '$'
6745 };
6746
6747 return {
6748 name: 'Markdown',
6749 aliases: [
6750 'md',
6751 'mkdown',
6752 'mkd'
6753 ],
6754 contains: [
6755 HEADER,
6756 INLINE_HTML,
6757 LIST,
6758 BOLD,
6759 ITALIC,
6760 BLOCKQUOTE,
6761 CODE,
6762 HORIZONTAL_RULE,
6763 LINK,
6764 LINK_REFERENCE
6765 ]
6766 };
6767 }
6768
6769 return markdown;
6770
6771 return module.exports.definer || module.exports;
6772
6773}());
6774
6775hljs.registerLanguage('nginx', function () {
6776 'use strict';
6777
6778 /*
6779 Language: Nginx config
6780 Author: Peter Leonov <gojpeg@yandex.ru>
6781 Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
6782 Category: common, config
6783 Website: https://www.nginx.com
6784 */
6785
6786 function nginx(hljs) {
6787 const VAR = {
6788 className: 'variable',
6789 variants: [
6790 {
6791 begin: /\$\d+/
6792 },
6793 {
6794 begin: /\$\{/,
6795 end: /\}/
6796 },
6797 {
6798 begin: /[$@]/ + hljs.UNDERSCORE_IDENT_RE
6799 }
6800 ]
6801 };
6802 const DEFAULT = {
6803 endsWithParent: true,
6804 keywords: {
6805 $pattern: '[a-z/_]+',
6806 literal:
6807 'on off yes no true false none blocked debug info notice warn error crit ' +
6808 'select break last permanent redirect kqueue rtsig epoll poll /dev/poll'
6809 },
6810 relevance: 0,
6811 illegal: '=>',
6812 contains: [
6813 hljs.HASH_COMMENT_MODE,
6814 {
6815 className: 'string',
6816 contains: [
6817 hljs.BACKSLASH_ESCAPE,
6818 VAR
6819 ],
6820 variants: [
6821 {
6822 begin: /"/,
6823 end: /"/
6824 },
6825 {
6826 begin: /'/,
6827 end: /'/
6828 }
6829 ]
6830 },
6831 // this swallows entire URLs to avoid detecting numbers within
6832 {
6833 begin: '([a-z]+):/',
6834 end: '\\s',
6835 endsWithParent: true,
6836 excludeEnd: true,
6837 contains: [ VAR ]
6838 },
6839 {
6840 className: 'regexp',
6841 contains: [
6842 hljs.BACKSLASH_ESCAPE,
6843 VAR
6844 ],
6845 variants: [
6846 {
6847 begin: "\\s\\^",
6848 end: "\\s|\\{|;",
6849 returnEnd: true
6850 },
6851 // regexp locations (~, ~*)
6852 {
6853 begin: "~\\*?\\s+",
6854 end: "\\s|\\{|;",
6855 returnEnd: true
6856 },
6857 // *.example.com
6858 {
6859 begin: "\\*(\\.[a-z\\-]+)+"
6860 },
6861 // sub.example.*
6862 {
6863 begin: "([a-z\\-]+\\.)+\\*"
6864 }
6865 ]
6866 },
6867 // IP
6868 {
6869 className: 'number',
6870 begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
6871 },
6872 // units
6873 {
6874 className: 'number',
6875 begin: '\\b\\d+[kKmMgGdshdwy]*\\b',
6876 relevance: 0
6877 },
6878 VAR
6879 ]
6880 };
6881
6882 return {
6883 name: 'Nginx config',
6884 aliases: [ 'nginxconf' ],
6885 contains: [
6886 hljs.HASH_COMMENT_MODE,
6887 {
6888 begin: hljs.UNDERSCORE_IDENT_RE + '\\s+\\{',
6889 returnBegin: true,
6890 end: /\{/,
6891 contains: [
6892 {
6893 className: 'section',
6894 begin: hljs.UNDERSCORE_IDENT_RE
6895 }
6896 ],
6897 relevance: 0
6898 },
6899 {
6900 begin: hljs.UNDERSCORE_IDENT_RE + '\\s',
6901 end: ';|\\{',
6902 returnBegin: true,
6903 contains: [
6904 {
6905 className: 'attribute',
6906 begin: hljs.UNDERSCORE_IDENT_RE,
6907 starts: DEFAULT
6908 }
6909 ],
6910 relevance: 0
6911 }
6912 ],
6913 illegal: '[^\\s\\}]'
6914 };
6915 }
6916
6917 return nginx;
6918
6919 return module.exports.definer || module.exports;
6920
6921}());
6922
6923hljs.registerLanguage('objectivec', function () {
6924 'use strict';
6925
6926 /*
6927 Language: Objective-C
6928 Author: Valerii Hiora <valerii.hiora@gmail.com>
6929 Contributors: Angel G. Olloqui <angelgarcia.mail@gmail.com>, Matt Diephouse <matt@diephouse.com>, Andrew Farmer <ahfarmer@gmail.com>, Minh Nguyễn <mxn@1ec5.org>
6930 Website: https://developer.apple.com/documentation/objectivec
6931 Category: common
6932 */
6933
6934 function objectivec(hljs) {
6935 const API_CLASS = {
6936 className: 'built_in',
6937 begin: '\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+'
6938 };
6939 const IDENTIFIER_RE = /[a-zA-Z@][a-zA-Z0-9_]*/;
6940 const OBJC_KEYWORDS = {
6941 $pattern: IDENTIFIER_RE,
6942 keyword:
6943 'int float while char export sizeof typedef const struct for union ' +
6944 'unsigned long volatile static bool mutable if do return goto void ' +
6945 'enum else break extern asm case short default double register explicit ' +
6946 'signed typename this switch continue wchar_t inline readonly assign ' +
6947 'readwrite self @synchronized id typeof ' +
6948 'nonatomic super unichar IBOutlet IBAction strong weak copy ' +
6949 'in out inout bycopy byref oneway __strong __weak __block __autoreleasing ' +
6950 '@private @protected @public @try @property @end @throw @catch @finally ' +
6951 '@autoreleasepool @synthesize @dynamic @selector @optional @required ' +
6952 '@encode @package @import @defs @compatibility_alias ' +
6953 '__bridge __bridge_transfer __bridge_retained __bridge_retain ' +
6954 '__covariant __contravariant __kindof ' +
6955 '_Nonnull _Nullable _Null_unspecified ' +
6956 '__FUNCTION__ __PRETTY_FUNCTION__ __attribute__ ' +
6957 'getter setter retain unsafe_unretained ' +
6958 'nonnull nullable null_unspecified null_resettable class instancetype ' +
6959 'NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER ' +
6960 'NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED ' +
6961 'NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE ' +
6962 'NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END ' +
6963 'NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW ' +
6964 'NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN',
6965 literal:
6966 'false true FALSE TRUE nil YES NO NULL',
6967 built_in:
6968 'BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once'
6969 };
6970 const CLASS_KEYWORDS = {
6971 $pattern: IDENTIFIER_RE,
6972 keyword: '@interface @class @protocol @implementation'
6973 };
6974 return {
6975 name: 'Objective-C',
6976 aliases: [
6977 'mm',
6978 'objc',
6979 'obj-c',
6980 'obj-c++',
6981 'objective-c++'
6982 ],
6983 keywords: OBJC_KEYWORDS,
6984 illegal: '</',
6985 contains: [
6986 API_CLASS,
6987 hljs.C_LINE_COMMENT_MODE,
6988 hljs.C_BLOCK_COMMENT_MODE,
6989 hljs.C_NUMBER_MODE,
6990 hljs.QUOTE_STRING_MODE,
6991 hljs.APOS_STRING_MODE,
6992 {
6993 className: 'string',
6994 variants: [
6995 {
6996 begin: '@"',
6997 end: '"',
6998 illegal: '\\n',
6999 contains: [ hljs.BACKSLASH_ESCAPE ]
7000 }
7001 ]
7002 },
7003 {
7004 className: 'meta',
7005 begin: /#\s*[a-z]+\b/,
7006 end: /$/,
7007 keywords: {
7008 'meta-keyword':
7009 'if else elif endif define undef warning error line ' +
7010 'pragma ifdef ifndef include'
7011 },
7012 contains: [
7013 {
7014 begin: /\\\n/,
7015 relevance: 0
7016 },
7017 hljs.inherit(hljs.QUOTE_STRING_MODE, {
7018 className: 'meta-string'
7019 }),
7020 {
7021 className: 'meta-string',
7022 begin: /<.*?>/,
7023 end: /$/,
7024 illegal: '\\n'
7025 },
7026 hljs.C_LINE_COMMENT_MODE,
7027 hljs.C_BLOCK_COMMENT_MODE
7028 ]
7029 },
7030 {
7031 className: 'class',
7032 begin: '(' + CLASS_KEYWORDS.keyword.split(' ').join('|') + ')\\b',
7033 end: /(\{|$)/,
7034 excludeEnd: true,
7035 keywords: CLASS_KEYWORDS,
7036 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
7037 },
7038 {
7039 begin: '\\.' + hljs.UNDERSCORE_IDENT_RE,
7040 relevance: 0
7041 }
7042 ]
7043 };
7044 }
7045
7046 return objectivec;
7047
7048 return module.exports.definer || module.exports;
7049
7050}());
7051
7052hljs.registerLanguage('perl', function () {
7053 'use strict';
7054
7055 /**
7056 * @param {string} value
7057 * @returns {RegExp}
7058 * */
7059
7060 /**
7061 * @param {RegExp | string } re
7062 * @returns {string}
7063 */
7064 function source(re) {
7065 if (!re) return null;
7066 if (typeof re === "string") return re;
7067
7068 return re.source;
7069 }
7070
7071 /**
7072 * @param {...(RegExp | string) } args
7073 * @returns {string}
7074 */
7075 function concat(...args) {
7076 const joined = args.map((x) => source(x)).join("");
7077 return joined;
7078 }
7079
7080 /*
7081 Language: Perl
7082 Author: Peter Leonov <gojpeg@yandex.ru>
7083 Website: https://www.perl.org
7084 Category: common
7085 */
7086
7087 /** @type LanguageFn */
7088 function perl(hljs) {
7089 // https://perldoc.perl.org/perlre#Modifiers
7090 const REGEX_MODIFIERS = /[dualxmsipn]{0,12}/; // aa and xx are valid, making max length 12
7091 const PERL_KEYWORDS = {
7092 $pattern: /[\w.]+/,
7093 keyword: 'getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ' +
7094 'ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime ' +
7095 'readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq ' +
7096 'fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent ' +
7097 'shutdown dump chomp connect getsockname die socketpair close flock exists index shmget ' +
7098 'sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr ' +
7099 'unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 ' +
7100 'getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline ' +
7101 'endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand ' +
7102 'mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink ' +
7103 'getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr ' +
7104 'untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link ' +
7105 'getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller ' +
7106 'lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and ' +
7107 'sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 ' +
7108 'chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach ' +
7109 'tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir ' +
7110 'ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe ' +
7111 'atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when'
7112 };
7113 const SUBST = {
7114 className: 'subst',
7115 begin: '[$@]\\{',
7116 end: '\\}',
7117 keywords: PERL_KEYWORDS
7118 };
7119 const METHOD = {
7120 begin: /->\{/,
7121 end: /\}/
7122 // contains defined later
7123 };
7124 const VAR = {
7125 variants: [
7126 {
7127 begin: /\$\d/
7128 },
7129 {
7130 begin: concat(
7131 /[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,
7132 // negative look-ahead tries to avoid matching patterns that are not
7133 // Perl at all like $ident$, @ident@, etc.
7134 `(?![A-Za-z])(?![@$%])`
7135 )
7136 },
7137 {
7138 begin: /[$%@][^\s\w{]/,
7139 relevance: 0
7140 }
7141 ]
7142 };
7143 const STRING_CONTAINS = [
7144 hljs.BACKSLASH_ESCAPE,
7145 SUBST,
7146 VAR
7147 ];
7148 const PERL_DEFAULT_CONTAINS = [
7149 VAR,
7150 hljs.HASH_COMMENT_MODE,
7151 hljs.COMMENT(
7152 /^=\w/,
7153 /=cut/,
7154 {
7155 endsWithParent: true
7156 }
7157 ),
7158 METHOD,
7159 {
7160 className: 'string',
7161 contains: STRING_CONTAINS,
7162 variants: [
7163 {
7164 begin: 'q[qwxr]?\\s*\\(',
7165 end: '\\)',
7166 relevance: 5
7167 },
7168 {
7169 begin: 'q[qwxr]?\\s*\\[',
7170 end: '\\]',
7171 relevance: 5
7172 },
7173 {
7174 begin: 'q[qwxr]?\\s*\\{',
7175 end: '\\}',
7176 relevance: 5
7177 },
7178 {
7179 begin: 'q[qwxr]?\\s*\\|',
7180 end: '\\|',
7181 relevance: 5
7182 },
7183 {
7184 begin: 'q[qwxr]?\\s*<',
7185 end: '>',
7186 relevance: 5
7187 },
7188 {
7189 begin: 'qw\\s+q',
7190 end: 'q',
7191 relevance: 5
7192 },
7193 {
7194 begin: '\'',
7195 end: '\'',
7196 contains: [ hljs.BACKSLASH_ESCAPE ]
7197 },
7198 {
7199 begin: '"',
7200 end: '"'
7201 },
7202 {
7203 begin: '`',
7204 end: '`',
7205 contains: [ hljs.BACKSLASH_ESCAPE ]
7206 },
7207 {
7208 begin: /\{\w+\}/,
7209 contains: [],
7210 relevance: 0
7211 },
7212 {
7213 begin: '-?\\w+\\s*=>',
7214 contains: [],
7215 relevance: 0
7216 }
7217 ]
7218 },
7219 {
7220 className: 'number',
7221 begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
7222 relevance: 0
7223 },
7224 { // regexp container
7225 begin: '(\\/\\/|' + hljs.RE_STARTERS_RE + '|\\b(split|return|print|reverse|grep)\\b)\\s*',
7226 keywords: 'split return print reverse grep',
7227 relevance: 0,
7228 contains: [
7229 hljs.HASH_COMMENT_MODE,
7230 {
7231 className: 'regexp',
7232 begin: concat(
7233 /(s|tr|y)/,
7234 /\//,
7235 /(\\.|[^\\\/])*/,
7236 /\//,
7237 /(\\.|[^\\\/])*/,
7238 /\//,
7239 REGEX_MODIFIERS
7240 ),
7241 relevance: 10
7242 },
7243 {
7244 className: 'regexp',
7245 begin: /(m|qr)?\//,
7246 end: concat(
7247 /\//,
7248 REGEX_MODIFIERS
7249 ),
7250 contains: [ hljs.BACKSLASH_ESCAPE ],
7251 relevance: 0 // allows empty "//" which is a common comment delimiter in other languages
7252 }
7253 ]
7254 },
7255 {
7256 className: 'function',
7257 beginKeywords: 'sub',
7258 end: '(\\s*\\(.*?\\))?[;{]',
7259 excludeEnd: true,
7260 relevance: 5,
7261 contains: [ hljs.TITLE_MODE ]
7262 },
7263 {
7264 begin: '-\\w\\b',
7265 relevance: 0
7266 },
7267 {
7268 begin: "^__DATA__$",
7269 end: "^__END__$",
7270 subLanguage: 'mojolicious',
7271 contains: [
7272 {
7273 begin: "^@@.*",
7274 end: "$",
7275 className: "comment"
7276 }
7277 ]
7278 }
7279 ];
7280 SUBST.contains = PERL_DEFAULT_CONTAINS;
7281 METHOD.contains = PERL_DEFAULT_CONTAINS;
7282
7283 return {
7284 name: 'Perl',
7285 aliases: [
7286 'pl',
7287 'pm'
7288 ],
7289 keywords: PERL_KEYWORDS,
7290 contains: PERL_DEFAULT_CONTAINS
7291 };
7292 }
7293
7294 return perl;
7295
7296 return module.exports.definer || module.exports;
7297
7298}());
7299
7300hljs.registerLanguage('php', function () {
7301 'use strict';
7302
7303 /*
7304 Language: PHP
7305 Author: Victor Karamzin <Victor.Karamzin@enterra-inc.com>
7306 Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Ivan Sagalaev <maniac@softwaremaniacs.org>
7307 Website: https://www.php.net
7308 Category: common
7309 */
7310
7311 /**
7312 * @param {HLJSApi} hljs
7313 * @returns {LanguageDetail}
7314 * */
7315 function php(hljs) {
7316 const VARIABLE = {
7317 className: 'variable',
7318 begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' +
7319 // negative look-ahead tries to avoid matching patterns that are not
7320 // Perl at all like $ident$, @ident@, etc.
7321 `(?![A-Za-z0-9])(?![$])`
7322 };
7323 const PREPROCESSOR = {
7324 className: 'meta',
7325 variants: [
7326 { begin: /<\?php/, relevance: 10 }, // boost for obvious PHP
7327 { begin: /<\?[=]?/ },
7328 { begin: /\?>/ } // end php tag
7329 ]
7330 };
7331 const SUBST = {
7332 className: 'subst',
7333 variants: [
7334 { begin: /\$\w+/ },
7335 { begin: /\{\$/, end: /\}/ }
7336 ]
7337 };
7338 const SINGLE_QUOTED = hljs.inherit(hljs.APOS_STRING_MODE, {
7339 illegal: null,
7340 });
7341 const DOUBLE_QUOTED = hljs.inherit(hljs.QUOTE_STRING_MODE, {
7342 illegal: null,
7343 contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
7344 });
7345 const HEREDOC = hljs.END_SAME_AS_BEGIN({
7346 begin: /<<<[ \t]*(\w+)\n/,
7347 end: /[ \t]*(\w+)\b/,
7348 contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
7349 });
7350 const STRING = {
7351 className: 'string',
7352 contains: [hljs.BACKSLASH_ESCAPE, PREPROCESSOR],
7353 variants: [
7354 hljs.inherit(SINGLE_QUOTED, {
7355 begin: "b'", end: "'",
7356 }),
7357 hljs.inherit(DOUBLE_QUOTED, {
7358 begin: 'b"', end: '"',
7359 }),
7360 DOUBLE_QUOTED,
7361 SINGLE_QUOTED,
7362 HEREDOC
7363 ]
7364 };
7365 const NUMBER = {variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]};
7366 const KEYWORDS = {
7367 keyword:
7368 // Magic constants:
7369 // <https://www.php.net/manual/en/language.constants.predefined.php>
7370 '__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ ' +
7371 // Function that look like language construct or language construct that look like function:
7372 // List of keywords that may not require parenthesis
7373 'die echo exit include include_once print require require_once ' +
7374 // These are not language construct (function) but operate on the currently-executing function and can access the current symbol table
7375 // 'compact extract func_get_arg func_get_args func_num_args get_called_class get_parent_class ' +
7376 // Other keywords:
7377 // <https://www.php.net/manual/en/reserved.php>
7378 // <https://www.php.net/manual/en/language.types.type-juggling.php>
7379 'array abstract and as binary bool boolean break callable case catch class clone const continue declare ' +
7380 'default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends ' +
7381 'final finally float for foreach from global goto if implements instanceof insteadof int integer interface ' +
7382 'isset iterable list match|0 new object or private protected public real return string switch throw trait ' +
7383 'try unset use var void while xor yield',
7384 literal: 'false null true',
7385 built_in:
7386 // Standard PHP library:
7387 // <https://www.php.net/manual/en/book.spl.php>
7388 'Error|0 ' + // error is too common a name esp since PHP is case in-sensitive
7389 'AppendIterator ArgumentCountError ArithmeticError ArrayIterator ArrayObject AssertionError BadFunctionCallException BadMethodCallException CachingIterator CallbackFilterIterator CompileError Countable DirectoryIterator DivisionByZeroError DomainException EmptyIterator ErrorException Exception FilesystemIterator FilterIterator GlobIterator InfiniteIterator InvalidArgumentException IteratorIterator LengthException LimitIterator LogicException MultipleIterator NoRewindIterator OutOfBoundsException OutOfRangeException OuterIterator OverflowException ParentIterator ParseError RangeException RecursiveArrayIterator RecursiveCachingIterator RecursiveCallbackFilterIterator RecursiveDirectoryIterator RecursiveFilterIterator RecursiveIterator RecursiveIteratorIterator RecursiveRegexIterator RecursiveTreeIterator RegexIterator RuntimeException SeekableIterator SplDoublyLinkedList SplFileInfo SplFileObject SplFixedArray SplHeap SplMaxHeap SplMinHeap SplObjectStorage SplObserver SplObserver SplPriorityQueue SplQueue SplStack SplSubject SplSubject SplTempFileObject TypeError UnderflowException UnexpectedValueException ' +
7390 // Reserved interfaces:
7391 // <https://www.php.net/manual/en/reserved.interfaces.php>
7392 'ArrayAccess Closure Generator Iterator IteratorAggregate Serializable Throwable Traversable WeakReference ' +
7393 // Reserved classes:
7394 // <https://www.php.net/manual/en/reserved.classes.php>
7395 'Directory __PHP_Incomplete_Class parent php_user_filter self static stdClass'
7396 };
7397 return {
7398 aliases: ['php', 'php3', 'php4', 'php5', 'php6', 'php7', 'php8'],
7399 case_insensitive: true,
7400 keywords: KEYWORDS,
7401 contains: [
7402 hljs.HASH_COMMENT_MODE,
7403 hljs.COMMENT('//', '$', {contains: [PREPROCESSOR]}),
7404 hljs.COMMENT(
7405 '/\\*',
7406 '\\*/',
7407 {
7408 contains: [
7409 {
7410 className: 'doctag',
7411 begin: '@[A-Za-z]+'
7412 }
7413 ]
7414 }
7415 ),
7416 hljs.COMMENT(
7417 '__halt_compiler.+?;',
7418 false,
7419 {
7420 endsWithParent: true,
7421 keywords: '__halt_compiler'
7422 }
7423 ),
7424 PREPROCESSOR,
7425 {
7426 className: 'keyword', begin: /\$this\b/
7427 },
7428 VARIABLE,
7429 {
7430 // swallow composed identifiers to avoid parsing them as keywords
7431 begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
7432 },
7433 {
7434 className: 'function',
7435 relevance: 0,
7436 beginKeywords: 'fn function', end: /[;{]/, excludeEnd: true,
7437 illegal: '[$%\\[]',
7438 contains: [
7439 hljs.UNDERSCORE_TITLE_MODE,
7440 {
7441 begin: '=>' // No markup, just a relevance booster
7442 },
7443 {
7444 className: 'params',
7445 begin: '\\(', end: '\\)',
7446 excludeBegin: true,
7447 excludeEnd: true,
7448 keywords: KEYWORDS,
7449 contains: [
7450 'self',
7451 VARIABLE,
7452 hljs.C_BLOCK_COMMENT_MODE,
7453 STRING,
7454 NUMBER
7455 ]
7456 }
7457 ]
7458 },
7459 {
7460 className: 'class',
7461 beginKeywords: 'class interface',
7462 relevance: 0,
7463 end: /\{/,
7464 excludeEnd: true,
7465 illegal: /[:($"]/,
7466 contains: [
7467 {beginKeywords: 'extends implements'},
7468 hljs.UNDERSCORE_TITLE_MODE
7469 ]
7470 },
7471 {
7472 beginKeywords: 'namespace',
7473 relevance: 0,
7474 end: ';',
7475 illegal: /[.']/,
7476 contains: [hljs.UNDERSCORE_TITLE_MODE]
7477 },
7478 {
7479 beginKeywords: 'use',
7480 relevance: 0,
7481 end: ';',
7482 contains: [hljs.UNDERSCORE_TITLE_MODE]
7483 },
7484 STRING,
7485 NUMBER
7486 ]
7487 };
7488 }
7489
7490 return php;
7491
7492 return module.exports.definer || module.exports;
7493
7494}());
7495
7496hljs.registerLanguage('php-template', function () {
7497 'use strict';
7498
7499 /*
7500 Language: PHP Template
7501 Requires: xml.js, php.js
7502 Author: Josh Goebel <hello@joshgoebel.com>
7503 Website: https://www.php.net
7504 Category: common
7505 */
7506
7507 function phpTemplate(hljs) {
7508 return {
7509 name: "PHP template",
7510 subLanguage: 'xml',
7511 contains: [
7512 {
7513 begin: /<\?(php|=)?/,
7514 end: /\?>/,
7515 subLanguage: 'php',
7516 contains: [
7517 // We don't want the php closing tag ?> to close the PHP block when
7518 // inside any of the following blocks:
7519 {
7520 begin: '/\\*',
7521 end: '\\*/',
7522 skip: true
7523 },
7524 {
7525 begin: 'b"',
7526 end: '"',
7527 skip: true
7528 },
7529 {
7530 begin: 'b\'',
7531 end: '\'',
7532 skip: true
7533 },
7534 hljs.inherit(hljs.APOS_STRING_MODE, {
7535 illegal: null,
7536 className: null,
7537 contains: null,
7538 skip: true
7539 }),
7540 hljs.inherit(hljs.QUOTE_STRING_MODE, {
7541 illegal: null,
7542 className: null,
7543 contains: null,
7544 skip: true
7545 })
7546 ]
7547 }
7548 ]
7549 };
7550 }
7551
7552 return phpTemplate;
7553
7554 return module.exports.definer || module.exports;
7555
7556}());
7557
7558hljs.registerLanguage('plaintext', function () {
7559 'use strict';
7560
7561 /*
7562 Language: Plain text
7563 Author: Egor Rogov (e.rogov@postgrespro.ru)
7564 Description: Plain text without any highlighting.
7565 Category: common
7566 */
7567
7568 function plaintext(hljs) {
7569 return {
7570 name: 'Plain text',
7571 aliases: [
7572 'text',
7573 'txt'
7574 ],
7575 disableAutodetect: true
7576 };
7577 }
7578
7579 return plaintext;
7580
7581 return module.exports.definer || module.exports;
7582
7583}());
7584
7585hljs.registerLanguage('properties', function () {
7586 'use strict';
7587
7588 /*
7589 Language: .properties
7590 Contributors: Valentin Aitken <valentin@nalisbg.com>, Egor Rogov <e.rogov@postgrespro.ru>
7591 Website: https://en.wikipedia.org/wiki/.properties
7592 Category: common, config
7593 */
7594
7595 function properties(hljs) {
7596
7597 // whitespaces: space, tab, formfeed
7598 var WS0 = '[ \\t\\f]*';
7599 var WS1 = '[ \\t\\f]+';
7600 // delimiter
7601 var EQUAL_DELIM = WS0+'[:=]'+WS0;
7602 var WS_DELIM = WS1;
7603 var DELIM = '(' + EQUAL_DELIM + '|' + WS_DELIM + ')';
7604 var KEY_ALPHANUM = '([^\\\\\\W:= \\t\\f\\n]|\\\\.)+';
7605 var KEY_OTHER = '([^\\\\:= \\t\\f\\n]|\\\\.)+';
7606
7607 var DELIM_AND_VALUE = {
7608 // skip DELIM
7609 end: DELIM,
7610 relevance: 0,
7611 starts: {
7612 // value: everything until end of line (again, taking into account backslashes)
7613 className: 'string',
7614 end: /$/,
7615 relevance: 0,
7616 contains: [
7617 { begin: '\\\\\\\\'},
7618 { begin: '\\\\\\n' }
7619 ]
7620 }
7621 };
7622
7623 return {
7624 name: '.properties',
7625 case_insensitive: true,
7626 illegal: /\S/,
7627 contains: [
7628 hljs.COMMENT('^\\s*[!#]', '$'),
7629 // key: everything until whitespace or = or : (taking into account backslashes)
7630 // case of a "normal" key
7631 {
7632 returnBegin: true,
7633 variants: [
7634 { begin: KEY_ALPHANUM + EQUAL_DELIM, relevance: 1 },
7635 { begin: KEY_ALPHANUM + WS_DELIM, relevance: 0 }
7636 ],
7637 contains: [
7638 {
7639 className: 'attr',
7640 begin: KEY_ALPHANUM,
7641 endsParent: true,
7642 relevance: 0
7643 }
7644 ],
7645 starts: DELIM_AND_VALUE
7646 },
7647 // case of key containing non-alphanumeric chars => relevance = 0
7648 {
7649 begin: KEY_OTHER + DELIM,
7650 returnBegin: true,
7651 relevance: 0,
7652 contains: [
7653 {
7654 className: 'meta',
7655 begin: KEY_OTHER,
7656 endsParent: true,
7657 relevance: 0
7658 }
7659 ],
7660 starts: DELIM_AND_VALUE
7661 },
7662 // case of an empty key
7663 {
7664 className: 'attr',
7665 relevance: 0,
7666 begin: KEY_OTHER + WS0 + '$'
7667 }
7668 ]
7669 };
7670 }
7671
7672 return properties;
7673
7674 return module.exports.definer || module.exports;
7675
7676}());
7677
7678hljs.registerLanguage('python', function () {
7679 'use strict';
7680
7681 /*
7682 Language: Python
7683 Description: Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
7684 Website: https://www.python.org
7685 Category: common
7686 */
7687
7688 function python(hljs) {
7689 const RESERVED_WORDS = [
7690 'and',
7691 'as',
7692 'assert',
7693 'async',
7694 'await',
7695 'break',
7696 'class',
7697 'continue',
7698 'def',
7699 'del',
7700 'elif',
7701 'else',
7702 'except',
7703 'finally',
7704 'for',
7705 '',
7706 'from',
7707 'global',
7708 'if',
7709 'import',
7710 'in',
7711 'is',
7712 'lambda',
7713 'nonlocal|10',
7714 'not',
7715 'or',
7716 'pass',
7717 'raise',
7718 'return',
7719 'try',
7720 'while',
7721 'with',
7722 'yield',
7723 ];
7724
7725 const BUILT_INS = [
7726 '__import__',
7727 'abs',
7728 'all',
7729 'any',
7730 'ascii',
7731 'bin',
7732 'bool',
7733 'breakpoint',
7734 'bytearray',
7735 'bytes',
7736 'callable',
7737 'chr',
7738 'classmethod',
7739 'compile',
7740 'complex',
7741 'delattr',
7742 'dict',
7743 'dir',
7744 'divmod',
7745 'enumerate',
7746 'eval',
7747 'exec',
7748 'filter',
7749 'float',
7750 'format',
7751 'frozenset',
7752 'getattr',
7753 'globals',
7754 'hasattr',
7755 'hash',
7756 'help',
7757 'hex',
7758 'id',
7759 'input',
7760 'int',
7761 'isinstance',
7762 'issubclass',
7763 'iter',
7764 'len',
7765 'list',
7766 'locals',
7767 'map',
7768 'max',
7769 'memoryview',
7770 'min',
7771 'next',
7772 'object',
7773 'oct',
7774 'open',
7775 'ord',
7776 'pow',
7777 'print',
7778 'property',
7779 'range',
7780 'repr',
7781 'reversed',
7782 'round',
7783 'set',
7784 'setattr',
7785 'slice',
7786 'sorted',
7787 'staticmethod',
7788 'str',
7789 'sum',
7790 'super',
7791 'tuple',
7792 'type',
7793 'vars',
7794 'zip',
7795 ];
7796
7797 const LITERALS = [
7798 '__debug__',
7799 'Ellipsis',
7800 'False',
7801 'None',
7802 'NotImplemented',
7803 'True',
7804 ];
7805
7806 const KEYWORDS = {
7807 keyword: RESERVED_WORDS.join(' '),
7808 built_in: BUILT_INS.join(' '),
7809 literal: LITERALS.join(' ')
7810 };
7811
7812 const PROMPT = {
7813 className: 'meta', begin: /^(>>>|\.\.\.) /
7814 };
7815
7816 const SUBST = {
7817 className: 'subst',
7818 begin: /\{/, end: /\}/,
7819 keywords: KEYWORDS,
7820 illegal: /#/
7821 };
7822
7823 const LITERAL_BRACKET = {
7824 begin: /\{\{/,
7825 relevance: 0
7826 };
7827
7828 const STRING = {
7829 className: 'string',
7830 contains: [hljs.BACKSLASH_ESCAPE],
7831 variants: [
7832 {
7833 begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/, end: /'''/,
7834 contains: [hljs.BACKSLASH_ESCAPE, PROMPT],
7835 relevance: 10
7836 },
7837 {
7838 begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/, end: /"""/,
7839 contains: [hljs.BACKSLASH_ESCAPE, PROMPT],
7840 relevance: 10
7841 },
7842 {
7843 begin: /([fF][rR]|[rR][fF]|[fF])'''/, end: /'''/,
7844 contains: [hljs.BACKSLASH_ESCAPE, PROMPT, LITERAL_BRACKET, SUBST]
7845 },
7846 {
7847 begin: /([fF][rR]|[rR][fF]|[fF])"""/, end: /"""/,
7848 contains: [hljs.BACKSLASH_ESCAPE, PROMPT, LITERAL_BRACKET, SUBST]
7849 },
7850 {
7851 begin: /([uU]|[rR])'/, end: /'/,
7852 relevance: 10
7853 },
7854 {
7855 begin: /([uU]|[rR])"/, end: /"/,
7856 relevance: 10
7857 },
7858 {
7859 begin: /([bB]|[bB][rR]|[rR][bB])'/, end: /'/
7860 },
7861 {
7862 begin: /([bB]|[bB][rR]|[rR][bB])"/, end: /"/
7863 },
7864 {
7865 begin: /([fF][rR]|[rR][fF]|[fF])'/, end: /'/,
7866 contains: [hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET, SUBST]
7867 },
7868 {
7869 begin: /([fF][rR]|[rR][fF]|[fF])"/, end: /"/,
7870 contains: [hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET, SUBST]
7871 },
7872 hljs.APOS_STRING_MODE,
7873 hljs.QUOTE_STRING_MODE
7874 ]
7875 };
7876
7877 // https://docs.python.org/3.9/reference/lexical_analysis.html#numeric-literals
7878 const digitpart = '[0-9](_?[0-9])*';
7879 const pointfloat = `(\\b(${digitpart}))?\\.(${digitpart})|\\b(${digitpart})\\.`;
7880 const NUMBER = {
7881 className: 'number', relevance: 0,
7882 variants: [
7883 // exponentfloat, pointfloat
7884 // https://docs.python.org/3.9/reference/lexical_analysis.html#floating-point-literals
7885 // optionally imaginary
7886 // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
7887 // Note: no leading \b because floats can start with a decimal point
7888 // and we don't want to mishandle e.g. `fn(.5)`,
7889 // no trailing \b for pointfloat because it can end with a decimal point
7890 // and we don't want to mishandle e.g. `0..hex()`; this should be safe
7891 // because both MUST contain a decimal point and so cannot be confused with
7892 // the interior part of an identifier
7893 { begin: `(\\b(${digitpart})|(${pointfloat}))[eE][+-]?(${digitpart})[jJ]?\\b` },
7894 { begin: `(${pointfloat})[jJ]?` },
7895
7896 // decinteger, bininteger, octinteger, hexinteger
7897 // https://docs.python.org/3.9/reference/lexical_analysis.html#integer-literals
7898 // optionally "long" in Python 2
7899 // https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals
7900 // decinteger is optionally imaginary
7901 // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
7902 { begin: '\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?\\b' },
7903 { begin: '\\b0[bB](_?[01])+[lL]?\\b' },
7904 { begin: '\\b0[oO](_?[0-7])+[lL]?\\b' },
7905 { begin: '\\b0[xX](_?[0-9a-fA-F])+[lL]?\\b' },
7906
7907 // imagnumber (digitpart-based)
7908 // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
7909 { begin: `\\b(${digitpart})[jJ]\\b` },
7910 ]
7911 };
7912
7913 const PARAMS = {
7914 className: 'params',
7915 variants: [
7916 // Exclude params at functions without params
7917 {begin: /\(\s*\)/, skip: true, className: null },
7918 {
7919 begin: /\(/, end: /\)/, excludeBegin: true, excludeEnd: true,
7920 keywords: KEYWORDS,
7921 contains: ['self', PROMPT, NUMBER, STRING, hljs.HASH_COMMENT_MODE],
7922 },
7923 ],
7924 };
7925 SUBST.contains = [STRING, NUMBER, PROMPT];
7926
7927 return {
7928 name: 'Python',
7929 aliases: ['py', 'gyp', 'ipython'],
7930 keywords: KEYWORDS,
7931 illegal: /(<\/|->|\?)|=>/,
7932 contains: [
7933 PROMPT,
7934 NUMBER,
7935 // eat "if" prior to string so that it won't accidentally be
7936 // labeled as an f-string as in:
7937 { begin: /\bself\b/, }, // very common convention
7938 { beginKeywords: "if", relevance: 0 },
7939 STRING,
7940 hljs.HASH_COMMENT_MODE,
7941 {
7942 variants: [
7943 {className: 'function', beginKeywords: 'def'},
7944 {className: 'class', beginKeywords: 'class'}
7945 ],
7946 end: /:/,
7947 illegal: /[${=;\n,]/,
7948 contains: [
7949 hljs.UNDERSCORE_TITLE_MODE,
7950 PARAMS,
7951 {
7952 begin: /->/, endsWithParent: true,
7953 keywords: 'None'
7954 }
7955 ]
7956 },
7957 {
7958 className: 'meta',
7959 begin: /^[\t ]*@/, end: /(?=#)|$/,
7960 contains: [NUMBER, PARAMS, STRING]
7961 },
7962 {
7963 begin: /\b(print|exec)\(/ // don’t highlight keywords-turned-functions in Python 3
7964 }
7965 ]
7966 };
7967 }
7968
7969 return python;
7970
7971 return module.exports.definer || module.exports;
7972
7973}());
7974
7975hljs.registerLanguage('python-repl', function () {
7976 'use strict';
7977
7978 /*
7979 Language: Python REPL
7980 Requires: python.js
7981 Author: Josh Goebel <hello@joshgoebel.com>
7982 Category: common
7983 */
7984
7985 function pythonRepl(hljs) {
7986 return {
7987 aliases: [ 'pycon' ],
7988 contains: [
7989 {
7990 className: 'meta',
7991 starts: {
7992 // a space separates the REPL prefix from the actual code
7993 // this is purely for cleaner HTML output
7994 end: / |$/,
7995 starts: {
7996 end: '$',
7997 subLanguage: 'python'
7998 }
7999 },
8000 variants: [
8001 {
8002 begin: /^>>>(?=[ ]|$)/
8003 },
8004 {
8005 begin: /^\.\.\.(?=[ ]|$)/
8006 }
8007 ]
8008 }
8009 ]
8010 };
8011 }
8012
8013 return pythonRepl;
8014
8015 return module.exports.definer || module.exports;
8016
8017}());
8018
8019hljs.registerLanguage('r', function () {
8020 'use strict';
8021
8022 /**
8023 * @param {string} value
8024 * @returns {RegExp}
8025 * */
8026
8027 /**
8028 * @param {RegExp | string } re
8029 * @returns {string}
8030 */
8031 function source(re) {
8032 if (!re) return null;
8033 if (typeof re === "string") return re;
8034
8035 return re.source;
8036 }
8037
8038 /**
8039 * @param {RegExp | string } re
8040 * @returns {string}
8041 */
8042 function lookahead(re) {
8043 return concat('(?=', re, ')');
8044 }
8045
8046 /**
8047 * @param {...(RegExp | string) } args
8048 * @returns {string}
8049 */
8050 function concat(...args) {
8051 const joined = args.map((x) => source(x)).join("");
8052 return joined;
8053 }
8054
8055 /*
8056 Language: R
8057 Description: R is a free software environment for statistical computing and graphics.
8058 Author: Joe Cheng <joe@rstudio.org>
8059 Contributors: Konrad Rudolph <konrad.rudolph@gmail.com>
8060 Website: https://www.r-project.org
8061 Category: common,scientific
8062 */
8063
8064 /** @type LanguageFn */
8065 function r(hljs) {
8066 // Identifiers in R cannot start with `_`, but they can start with `.` if it
8067 // is not immediately followed by a digit.
8068 // R also supports quoted identifiers, which are near-arbitrary sequences
8069 // delimited by backticks (`…`), which may contain escape sequences. These are
8070 // handled in a separate mode. See `test/markup/r/names.txt` for examples.
8071 // FIXME: Support Unicode identifiers.
8072 const IDENT_RE = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/;
8073 const SIMPLE_IDENT = /[a-zA-Z][a-zA-Z_0-9]*/;
8074
8075 return {
8076 name: 'R',
8077
8078 // only in Haskell, not R
8079 illegal: /->/,
8080 keywords: {
8081 $pattern: IDENT_RE,
8082 keyword:
8083 'function if in break next repeat else for while',
8084 literal:
8085 'NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 ' +
8086 'NA_character_|10 NA_complex_|10',
8087 built_in:
8088 // Builtin constants
8089 'LETTERS letters month.abb month.name pi T F ' +
8090 // Primitive functions
8091 // These are all the functions in `base` that are implemented as a
8092 // `.Primitive`, minus those functions that are also keywords.
8093 'abs acos acosh all any anyNA Arg as.call as.character ' +
8094 'as.complex as.double as.environment as.integer as.logical ' +
8095 'as.null.default as.numeric as.raw asin asinh atan atanh attr ' +
8096 'attributes baseenv browser c call ceiling class Conj cos cosh ' +
8097 'cospi cummax cummin cumprod cumsum digamma dim dimnames ' +
8098 'emptyenv exp expression floor forceAndCall gamma gc.time ' +
8099 'globalenv Im interactive invisible is.array is.atomic is.call ' +
8100 'is.character is.complex is.double is.environment is.expression ' +
8101 'is.finite is.function is.infinite is.integer is.language ' +
8102 'is.list is.logical is.matrix is.na is.name is.nan is.null ' +
8103 'is.numeric is.object is.pairlist is.raw is.recursive is.single ' +
8104 'is.symbol lazyLoadDBfetch length lgamma list log max min ' +
8105 'missing Mod names nargs nzchar oldClass on.exit pos.to.env ' +
8106 'proc.time prod quote range Re rep retracemem return round ' +
8107 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt ' +
8108 'standardGeneric substitute sum switch tan tanh tanpi tracemem ' +
8109 'trigamma trunc unclass untracemem UseMethod xtfrm',
8110 },
8111 compilerExtensions: [
8112 // allow beforeMatch to act as a "qualifier" for the match
8113 // the full match begin must be [beforeMatch][begin]
8114 (mode, parent) => {
8115 if (!mode.beforeMatch) return;
8116 // starts conflicts with endsParent which we need to make sure the child
8117 // rule is not matched multiple times
8118 if (mode.starts) throw new Error("beforeMatch cannot be used with starts");
8119
8120 const originalMode = Object.assign({}, mode);
8121 Object.keys(mode).forEach((key) => { delete mode[key]; });
8122
8123 mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
8124 mode.starts = {
8125 relevance: 0,
8126 contains: [
8127 Object.assign(originalMode, { endsParent: true })
8128 ]
8129 };
8130 mode.relevance = 0;
8131
8132 delete originalMode.beforeMatch;
8133 }
8134 ],
8135 contains: [
8136 // Roxygen comments
8137 hljs.COMMENT(
8138 /#'/,
8139 /$/,
8140 {
8141 contains: [
8142 {
8143 // Handle `@examples` separately to cause all subsequent code
8144 // until the next `@`-tag on its own line to be kept as-is,
8145 // preventing highlighting. This code is example R code, so nested
8146 // doctags shouldn’t be treated as such. See
8147 // `test/markup/r/roxygen.txt` for an example.
8148 className: 'doctag',
8149 begin: '@examples',
8150 starts: {
8151 contains: [
8152 { begin: /\n/ },
8153 {
8154 begin: /#'\s*(?=@[a-zA-Z]+)/,
8155 endsParent: true,
8156 },
8157 {
8158 begin: /#'/,
8159 end: /$/,
8160 excludeBegin: true,
8161 }
8162 ]
8163 }
8164 },
8165 {
8166 // Handle `@param` to highlight the parameter name following
8167 // after.
8168 className: 'doctag',
8169 begin: '@param',
8170 end: /$/,
8171 contains: [
8172 {
8173 className: 'variable',
8174 variants: [
8175 { begin: IDENT_RE },
8176 { begin: /`(?:\\.|[^`\\])+`/ }
8177 ],
8178 endsParent: true
8179 }
8180 ]
8181 },
8182 {
8183 className: 'doctag',
8184 begin: /@[a-zA-Z]+/
8185 },
8186 {
8187 className: 'meta-keyword',
8188 begin: /\\[a-zA-Z]+/,
8189 }
8190 ]
8191 }
8192 ),
8193
8194 hljs.HASH_COMMENT_MODE,
8195
8196 {
8197 className: 'string',
8198 contains: [hljs.BACKSLASH_ESCAPE],
8199 variants: [
8200 hljs.END_SAME_AS_BEGIN({ begin: /[rR]"(-*)\(/, end: /\)(-*)"/ }),
8201 hljs.END_SAME_AS_BEGIN({ begin: /[rR]"(-*)\{/, end: /\}(-*)"/ }),
8202 hljs.END_SAME_AS_BEGIN({ begin: /[rR]"(-*)\[/, end: /\](-*)"/ }),
8203 hljs.END_SAME_AS_BEGIN({ begin: /[rR]'(-*)\(/, end: /\)(-*)'/ }),
8204 hljs.END_SAME_AS_BEGIN({ begin: /[rR]'(-*)\{/, end: /\}(-*)'/ }),
8205 hljs.END_SAME_AS_BEGIN({ begin: /[rR]'(-*)\[/, end: /\](-*)'/ }),
8206 {begin: '"', end: '"', relevance: 0},
8207 {begin: "'", end: "'", relevance: 0}
8208 ],
8209 },
8210 {
8211 className: 'number',
8212 relevance: 0,
8213 beforeMatch: /([^a-zA-Z0-9._])/, // not part of an identifier
8214 variants: [
8215 // TODO: replace with negative look-behind when available
8216 // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/ },
8217 // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/ },
8218 // { begin: /(?<![a-zA-Z0-9._])(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/ }
8219 {
8220 // Special case: only hexadecimal binary powers can contain fractions.
8221 match: /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,
8222 },
8223 {
8224 match: /0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/
8225 },
8226 {
8227 match: /(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/,
8228 }
8229 ],
8230 },
8231 {
8232 // infix operator
8233 begin: '%',
8234 end: '%'
8235 },
8236 // relevance boost for assignment
8237 {
8238 begin: concat(SIMPLE_IDENT, "\\s+<-\\s+")
8239 },
8240 {
8241 // escaped identifier
8242 begin: '`',
8243 end: '`',
8244 contains: [
8245 { begin: /\\./ }
8246 ]
8247 }
8248 ]
8249 };
8250 }
8251
8252 return r;
8253
8254 return module.exports.definer || module.exports;
8255
8256}());
8257
8258hljs.registerLanguage('ruby', function () {
8259 'use strict';
8260
8261 /**
8262 * @param {string} value
8263 * @returns {RegExp}
8264 * */
8265
8266 /**
8267 * @param {RegExp | string } re
8268 * @returns {string}
8269 */
8270 function source(re) {
8271 if (!re) return null;
8272 if (typeof re === "string") return re;
8273
8274 return re.source;
8275 }
8276
8277 /**
8278 * @param {RegExp | string } re
8279 * @returns {string}
8280 */
8281 function lookahead(re) {
8282 return concat('(?=', re, ')');
8283 }
8284
8285 /**
8286 * @param {...(RegExp | string) } args
8287 * @returns {string}
8288 */
8289 function concat(...args) {
8290 const joined = args.map((x) => source(x)).join("");
8291 return joined;
8292 }
8293
8294 /*
8295 Language: Ruby
8296 Description: Ruby is a dynamic, open source programming language with a focus on simplicity and productivity.
8297 Website: https://www.ruby-lang.org/
8298 Author: Anton Kovalyov <anton@kovalyov.net>
8299 Contributors: Peter Leonov <gojpeg@yandex.ru>, Vasily Polovnyov <vast@whiteants.net>, Loren Segal <lsegal@soen.ca>, Pascal Hurni <phi@ruby-reactive.org>, Cedric Sohrauer <sohrauer@googlemail.com>
8300 Category: common
8301 */
8302
8303 function ruby(hljs) {
8304 var RUBY_METHOD_RE = '([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)';
8305 var RUBY_KEYWORDS = {
8306 keyword:
8307 'and then defined module in return redo if BEGIN retry end for self when ' +
8308 'next until do begin unless END rescue else break undef not super class case ' +
8309 'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor ' +
8310 '__FILE__',
8311 built_in: 'proc lambda',
8312 literal:
8313 'true false nil'
8314 };
8315 var YARDOCTAG = {
8316 className: 'doctag',
8317 begin: '@[A-Za-z]+'
8318 };
8319 var IRB_OBJECT = {
8320 begin: '#<', end: '>'
8321 };
8322 var COMMENT_MODES = [
8323 hljs.COMMENT(
8324 '#',
8325 '$',
8326 {
8327 contains: [YARDOCTAG]
8328 }
8329 ),
8330 hljs.COMMENT(
8331 '^=begin',
8332 '^=end',
8333 {
8334 contains: [YARDOCTAG],
8335 relevance: 10
8336 }
8337 ),
8338 hljs.COMMENT('^__END__', '\\n$')
8339 ];
8340 var SUBST = {
8341 className: 'subst',
8342 begin: /#\{/, end: /\}/,
8343 keywords: RUBY_KEYWORDS
8344 };
8345 var STRING = {
8346 className: 'string',
8347 contains: [hljs.BACKSLASH_ESCAPE, SUBST],
8348 variants: [
8349 {begin: /'/, end: /'/},
8350 {begin: /"/, end: /"/},
8351 {begin: /`/, end: /`/},
8352 {begin: /%[qQwWx]?\(/, end: /\)/},
8353 {begin: /%[qQwWx]?\[/, end: /\]/},
8354 {begin: /%[qQwWx]?\{/, end: /\}/},
8355 {begin: /%[qQwWx]?</, end: />/},
8356 {begin: /%[qQwWx]?\//, end: /\//},
8357 {begin: /%[qQwWx]?%/, end: /%/},
8358 {begin: /%[qQwWx]?-/, end: /-/},
8359 {begin: /%[qQwWx]?\|/, end: /\|/},
8360 {
8361 // \B in the beginning suppresses recognition of ?-sequences where ?
8362 // is the last character of a preceding identifier, as in: `func?4`
8363 begin: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/
8364 },
8365 { // heredocs
8366 begin: /<<[-~]?'?(\w+)\n(?:[^\n]*\n)*?\s*\1\b/,
8367 returnBegin: true,
8368 contains: [
8369 { begin: /<<[-~]?'?/ },
8370 hljs.END_SAME_AS_BEGIN({
8371 begin: /(\w+)/, end: /(\w+)/,
8372 contains: [hljs.BACKSLASH_ESCAPE, SUBST],
8373 })
8374 ]
8375 }
8376 ]
8377 };
8378
8379 // Ruby syntax is underdocumented, but this grammar seems to be accurate
8380 // as of version 2.7.2 (confirmed with (irb and `Ripper.sexp(...)`)
8381 // https://docs.ruby-lang.org/en/2.7.0/doc/syntax/literals_rdoc.html#label-Numbers
8382 var decimal = '[1-9](_?[0-9])*|0';
8383 var digits = '[0-9](_?[0-9])*';
8384 var NUMBER = {
8385 className: 'number', relevance: 0,
8386 variants: [
8387 // decimal integer/float, optionally exponential or rational, optionally imaginary
8388 { begin: `\\b(${decimal})(\\.(${digits}))?([eE][+-]?(${digits})|r)?i?\\b` },
8389
8390 // explicit decimal/binary/octal/hexadecimal integer,
8391 // optionally rational and/or imaginary
8392 { begin: "\\b0[dD][0-9](_?[0-9])*r?i?\\b" },
8393 { begin: "\\b0[bB][0-1](_?[0-1])*r?i?\\b" },
8394 { begin: "\\b0[oO][0-7](_?[0-7])*r?i?\\b" },
8395 { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b" },
8396
8397 // 0-prefixed implicit octal integer, optionally rational and/or imaginary
8398 { begin: "\\b0(_?[0-7])+r?i?\\b" },
8399 ]
8400 };
8401
8402 var PARAMS = {
8403 className: 'params',
8404 begin: '\\(', end: '\\)', endsParent: true,
8405 keywords: RUBY_KEYWORDS
8406 };
8407
8408 var RUBY_DEFAULT_CONTAINS = [
8409 STRING,
8410 {
8411 className: 'class',
8412 beginKeywords: 'class module', end: '$|;',
8413 illegal: /=/,
8414 contains: [
8415 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|!)?'}),
8416 {
8417 begin: '<\\s*',
8418 contains: [{
8419 begin: '(' + hljs.IDENT_RE + '::)?' + hljs.IDENT_RE
8420 }]
8421 }
8422 ].concat(COMMENT_MODES)
8423 },
8424 {
8425 className: 'function',
8426 // def method_name(
8427 // def method_name;
8428 // def method_name (end of line)
8429 begin: concat(/def\s*/, lookahead(RUBY_METHOD_RE + "\\s*(\\(|;|$)")),
8430 keywords: "def",
8431 end: '$|;',
8432 contains: [
8433 hljs.inherit(hljs.TITLE_MODE, {begin: RUBY_METHOD_RE}),
8434 PARAMS
8435 ].concat(COMMENT_MODES)
8436 },
8437 {
8438 // swallow namespace qualifiers before symbols
8439 begin: hljs.IDENT_RE + '::'
8440 },
8441 {
8442 className: 'symbol',
8443 begin: hljs.UNDERSCORE_IDENT_RE + '(!|\\?)?:',
8444 relevance: 0
8445 },
8446 {
8447 className: 'symbol',
8448 begin: ':(?!\\s)',
8449 contains: [STRING, {begin: RUBY_METHOD_RE}],
8450 relevance: 0
8451 },
8452 NUMBER,
8453 {
8454 // negative-look forward attemps to prevent false matches like:
8455 // @ident@ or $ident$ that might indicate this is not ruby at all
8456 className: "variable",
8457 begin: '(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])' + `(?![A-Za-z])(?![@$?'])`
8458 },
8459 {
8460 className: 'params',
8461 begin: /\|/,
8462 end: /\|/,
8463 relevance:0, // this could be a lot of things (in other languages) other than params
8464 keywords: RUBY_KEYWORDS
8465 },
8466 { // regexp container
8467 begin: '(' + hljs.RE_STARTERS_RE + '|unless)\\s*',
8468 keywords: 'unless',
8469 contains: [
8470 {
8471 className: 'regexp',
8472 contains: [hljs.BACKSLASH_ESCAPE, SUBST],
8473 illegal: /\n/,
8474 variants: [
8475 {begin: '/', end: '/[a-z]*'},
8476 {begin: /%r\{/, end: /\}[a-z]*/},
8477 {begin: '%r\\(', end: '\\)[a-z]*'},
8478 {begin: '%r!', end: '![a-z]*'},
8479 {begin: '%r\\[', end: '\\][a-z]*'}
8480 ]
8481 }
8482 ].concat(IRB_OBJECT, COMMENT_MODES),
8483 relevance: 0
8484 }
8485 ].concat(IRB_OBJECT, COMMENT_MODES);
8486
8487 SUBST.contains = RUBY_DEFAULT_CONTAINS;
8488 PARAMS.contains = RUBY_DEFAULT_CONTAINS;
8489
8490 // >>
8491 // ?>
8492 var SIMPLE_PROMPT = "[>?]>";
8493 // irb(main):001:0>
8494 var DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+>";
8495 var RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>";
8496
8497 var IRB_DEFAULT = [
8498 {
8499 begin: /^\s*=>/,
8500 starts: {
8501 end: '$', contains: RUBY_DEFAULT_CONTAINS
8502 }
8503 },
8504 {
8505 className: 'meta',
8506 begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')(?=[ ])',
8507 starts: {
8508 end: '$', contains: RUBY_DEFAULT_CONTAINS
8509 }
8510 }
8511 ];
8512
8513 COMMENT_MODES.unshift(IRB_OBJECT);
8514
8515 return {
8516 name: 'Ruby',
8517 aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'],
8518 keywords: RUBY_KEYWORDS,
8519 illegal: /\/\*/,
8520 contains: [
8521 hljs.SHEBANG({binary:"ruby"}),
8522 ]
8523 .concat(IRB_DEFAULT)
8524 .concat(COMMENT_MODES)
8525 .concat(RUBY_DEFAULT_CONTAINS)
8526 };
8527 }
8528
8529 return ruby;
8530
8531 return module.exports.definer || module.exports;
8532
8533}());
8534
8535hljs.registerLanguage('rust', function () {
8536 'use strict';
8537
8538 /*
8539 Language: Rust
8540 Author: Andrey Vlasovskikh <andrey.vlasovskikh@gmail.com>
8541 Contributors: Roman Shmatov <romanshmatov@gmail.com>, Kasper Andersen <kma_untrusted@protonmail.com>
8542 Website: https://www.rust-lang.org
8543 Category: common, system
8544 */
8545
8546 function rust(hljs) {
8547 const NUM_SUFFIX = '([ui](8|16|32|64|128|size)|f(32|64))\?';
8548 const KEYWORDS =
8549 'abstract as async await become box break const continue crate do dyn ' +
8550 'else enum extern false final fn for if impl in let loop macro match mod ' +
8551 'move mut override priv pub ref return self Self static struct super ' +
8552 'trait true try type typeof unsafe unsized use virtual where while yield';
8553 const BUILTINS =
8554 // functions
8555 'drop ' +
8556 // types
8557 'i8 i16 i32 i64 i128 isize ' +
8558 'u8 u16 u32 u64 u128 usize ' +
8559 'f32 f64 ' +
8560 'str char bool ' +
8561 'Box Option Result String Vec ' +
8562 // traits
8563 'Copy Send Sized Sync Drop Fn FnMut FnOnce ToOwned Clone Debug ' +
8564 'PartialEq PartialOrd Eq Ord AsRef AsMut Into From Default Iterator ' +
8565 'Extend IntoIterator DoubleEndedIterator ExactSizeIterator ' +
8566 'SliceConcatExt ToString ' +
8567 // macros
8568 'assert! assert_eq! bitflags! bytes! cfg! col! concat! concat_idents! ' +
8569 'debug_assert! debug_assert_eq! env! panic! file! format! format_args! ' +
8570 'include_bin! include_str! line! local_data_key! module_path! ' +
8571 'option_env! print! println! select! stringify! try! unimplemented! ' +
8572 'unreachable! vec! write! writeln! macro_rules! assert_ne! debug_assert_ne!';
8573 return {
8574 name: 'Rust',
8575 aliases: [ 'rs' ],
8576 keywords: {
8577 $pattern: hljs.IDENT_RE + '!?',
8578 keyword:
8579 KEYWORDS,
8580 literal:
8581 'true false Some None Ok Err',
8582 built_in:
8583 BUILTINS
8584 },
8585 illegal: '</',
8586 contains: [
8587 hljs.C_LINE_COMMENT_MODE,
8588 hljs.COMMENT('/\\*', '\\*/', {
8589 contains: [ 'self' ]
8590 }),
8591 hljs.inherit(hljs.QUOTE_STRING_MODE, {
8592 begin: /b?"/,
8593 illegal: null
8594 }),
8595 {
8596 className: 'string',
8597 variants: [
8598 {
8599 begin: /r(#*)"(.|\n)*?"\1(?!#)/
8600 },
8601 {
8602 begin: /b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/
8603 }
8604 ]
8605 },
8606 {
8607 className: 'symbol',
8608 begin: /'[a-zA-Z_][a-zA-Z0-9_]*/
8609 },
8610 {
8611 className: 'number',
8612 variants: [
8613 {
8614 begin: '\\b0b([01_]+)' + NUM_SUFFIX
8615 },
8616 {
8617 begin: '\\b0o([0-7_]+)' + NUM_SUFFIX
8618 },
8619 {
8620 begin: '\\b0x([A-Fa-f0-9_]+)' + NUM_SUFFIX
8621 },
8622 {
8623 begin: '\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)' +
8624 NUM_SUFFIX
8625 }
8626 ],
8627 relevance: 0
8628 },
8629 {
8630 className: 'function',
8631 beginKeywords: 'fn',
8632 end: '(\\(|<)',
8633 excludeEnd: true,
8634 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
8635 },
8636 {
8637 className: 'meta',
8638 begin: '#!?\\[',
8639 end: '\\]',
8640 contains: [
8641 {
8642 className: 'meta-string',
8643 begin: /"/,
8644 end: /"/
8645 }
8646 ]
8647 },
8648 {
8649 className: 'class',
8650 beginKeywords: 'type',
8651 end: ';',
8652 contains: [
8653 hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, {
8654 endsParent: true
8655 })
8656 ],
8657 illegal: '\\S'
8658 },
8659 {
8660 className: 'class',
8661 beginKeywords: 'trait enum struct union',
8662 end: /\{/,
8663 contains: [
8664 hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, {
8665 endsParent: true
8666 })
8667 ],
8668 illegal: '[\\w\\d]'
8669 },
8670 {
8671 begin: hljs.IDENT_RE + '::',
8672 keywords: {
8673 built_in: BUILTINS
8674 }
8675 },
8676 {
8677 begin: '->'
8678 }
8679 ]
8680 };
8681 }
8682
8683 return rust;
8684
8685 return module.exports.definer || module.exports;
8686
8687}());
8688
8689hljs.registerLanguage('scss', function () {
8690 'use strict';
8691
8692 /*
8693 Language: SCSS
8694 Description: Scss is an extension of the syntax of CSS.
8695 Author: Kurt Emch <kurt@kurtemch.com>
8696 Website: https://sass-lang.com
8697 Category: common, css
8698 */
8699 function scss(hljs) {
8700 var AT_IDENTIFIER = '@[a-z-]+'; // @font-face
8701 var AT_MODIFIERS = "and or not only";
8702 var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
8703 var VARIABLE = {
8704 className: 'variable',
8705 begin: '(\\$' + IDENT_RE + ')\\b'
8706 };
8707 var HEXCOLOR = {
8708 className: 'number', begin: '#[0-9A-Fa-f]+'
8709 };
8710 var DEF_INTERNALS = {
8711 className: 'attribute',
8712 begin: '[A-Z\\_\\.\\-]+', end: ':',
8713 excludeEnd: true,
8714 illegal: '[^\\s]',
8715 starts: {
8716 endsWithParent: true, excludeEnd: true,
8717 contains: [
8718 HEXCOLOR,
8719 hljs.CSS_NUMBER_MODE,
8720 hljs.QUOTE_STRING_MODE,
8721 hljs.APOS_STRING_MODE,
8722 hljs.C_BLOCK_COMMENT_MODE,
8723 {
8724 className: 'meta', begin: '!important'
8725 }
8726 ]
8727 }
8728 };
8729 return {
8730 name: 'SCSS',
8731 case_insensitive: true,
8732 illegal: '[=/|\']',
8733 contains: [
8734 hljs.C_LINE_COMMENT_MODE,
8735 hljs.C_BLOCK_COMMENT_MODE,
8736 {
8737 className: 'selector-id', begin: '#[A-Za-z0-9_-]+',
8738 relevance: 0
8739 },
8740 {
8741 className: 'selector-class', begin: '\\.[A-Za-z0-9_-]+',
8742 relevance: 0
8743 },
8744 {
8745 className: 'selector-attr', begin: '\\[', end: '\\]',
8746 illegal: '$'
8747 },
8748 {
8749 className: 'selector-tag', // begin: IDENT_RE, end: '[,|\\s]'
8750 begin: '\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b',
8751 relevance: 0
8752 },
8753 {
8754 className: 'selector-pseudo',
8755 begin: ':(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)'
8756 },
8757 {
8758 className: 'selector-pseudo',
8759 begin: '::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)'
8760 },
8761 VARIABLE,
8762 {
8763 className: 'attribute',
8764 begin: '\\b(src|z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b',
8765 illegal: '[^\\s]'
8766 },
8767 {
8768 begin: '\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b'
8769 },
8770 {
8771 begin: ':', end: ';',
8772 contains: [
8773 VARIABLE,
8774 HEXCOLOR,
8775 hljs.CSS_NUMBER_MODE,
8776 hljs.QUOTE_STRING_MODE,
8777 hljs.APOS_STRING_MODE,
8778 {
8779 className: 'meta', begin: '!important'
8780 }
8781 ]
8782 },
8783 // matching these here allows us to treat them more like regular CSS
8784 // rules so everything between the {} gets regular rule highlighting,
8785 // which is what we want for page and font-face
8786 {
8787 begin: '@(page|font-face)',
8788 lexemes: AT_IDENTIFIER,
8789 keywords: '@page @font-face'
8790 },
8791 {
8792 begin: '@', end: '[{;]',
8793 returnBegin: true,
8794 keywords: AT_MODIFIERS,
8795 contains: [
8796 {
8797 begin: AT_IDENTIFIER,
8798 className: "keyword"
8799 },
8800 VARIABLE,
8801 hljs.QUOTE_STRING_MODE,
8802 hljs.APOS_STRING_MODE,
8803 HEXCOLOR,
8804 hljs.CSS_NUMBER_MODE,
8805 // {
8806 // begin: '\\s[A-Za-z0-9_.-]+',
8807 // relevance: 0
8808 // }
8809 ]
8810 }
8811 ]
8812 };
8813 }
8814
8815 return scss;
8816
8817 return module.exports.definer || module.exports;
8818
8819}());
8820
8821hljs.registerLanguage('shell', function () {
8822 'use strict';
8823
8824 /*
8825 Language: Shell Session
8826 Requires: bash.js
8827 Author: TSUYUSATO Kitsune <make.just.on@gmail.com>
8828 Category: common
8829 Audit: 2020
8830 */
8831
8832 /** @type LanguageFn */
8833 function shell(hljs) {
8834 return {
8835 name: 'Shell Session',
8836 aliases: [ 'console' ],
8837 contains: [
8838 {
8839 className: 'meta',
8840 // We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result.
8841 // For instance, in the following example, it would match "echo /path/to/home >" as a prompt:
8842 // echo /path/to/home > t.exe
8843 begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#]/,
8844 starts: {
8845 end: /[^\\](?=\s*$)/,
8846 subLanguage: 'bash'
8847 }
8848 }
8849 ]
8850 };
8851 }
8852
8853 return shell;
8854
8855 return module.exports.definer || module.exports;
8856
8857}());
8858
8859hljs.registerLanguage('sql', function () {
8860 'use strict';
8861
8862 /**
8863 * @param {string} value
8864 * @returns {RegExp}
8865 * */
8866
8867 /**
8868 * @param {RegExp | string } re
8869 * @returns {string}
8870 */
8871 function source(re) {
8872 if (!re) return null;
8873 if (typeof re === "string") return re;
8874
8875 return re.source;
8876 }
8877
8878 /**
8879 * @param {...(RegExp | string) } args
8880 * @returns {string}
8881 */
8882 function concat(...args) {
8883 const joined = args.map((x) => source(x)).join("");
8884 return joined;
8885 }
8886
8887 /**
8888 * Any of the passed expresssions may match
8889 *
8890 * Creates a huge this | this | that | that match
8891 * @param {(RegExp | string)[] } args
8892 * @returns {string}
8893 */
8894 function either(...args) {
8895 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
8896 return joined;
8897 }
8898
8899 /*
8900 Language: SQL
8901 Website: https://en.wikipedia.org/wiki/SQL
8902 Category: common, database
8903 */
8904
8905 function sql(hljs) {
8906 const COMMENT_MODE = hljs.COMMENT('--', '$');
8907 const STRING = {
8908 className: 'string',
8909 variants: [
8910 {
8911 begin: /'/,
8912 end: /'/,
8913 contains: [
8914 {begin: /''/ }
8915 ]
8916 }
8917 ]
8918 };
8919 const QUOTED_IDENTIFIER = {
8920 begin: /"/,
8921 end: /"/,
8922 contains: [ { begin: /""/ } ]
8923 };
8924
8925 const LITERALS = [
8926 "true",
8927 "false",
8928 // Not sure it's correct to call NULL literal, and clauses like IS [NOT] NULL look strange that way.
8929 // "null",
8930 "unknown"
8931 ];
8932
8933 const MULTI_WORD_TYPES = [
8934 "double precision",
8935 "large object",
8936 "with timezone",
8937 "without timezone"
8938 ];
8939
8940 const TYPES = [
8941 'bigint',
8942 'binary',
8943 'blob',
8944 'boolean',
8945 'char',
8946 'character',
8947 'clob',
8948 'date',
8949 'dec',
8950 'decfloat',
8951 'decimal',
8952 'float',
8953 'int',
8954 'integer',
8955 'interval',
8956 'nchar',
8957 'nclob',
8958 'national',
8959 'numeric',
8960 'real',
8961 'row',
8962 'smallint',
8963 'time',
8964 'timestamp',
8965 'varchar',
8966 'varying', // modifier (character varying)
8967 'varbinary'
8968 ];
8969
8970 const NON_RESERVED_WORDS = [
8971 "add",
8972 "asc",
8973 "collation",
8974 "desc",
8975 "final",
8976 "first",
8977 "last",
8978 "view"
8979 ];
8980
8981 // https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#reserved-word
8982 const RESERVED_WORDS = [
8983 "abs",
8984 "acos",
8985 "all",
8986 "allocate",
8987 "alter",
8988 "and",
8989 "any",
8990 "are",
8991 "array",
8992 "array_agg",
8993 "array_max_cardinality",
8994 "as",
8995 "asensitive",
8996 "asin",
8997 "asymmetric",
8998 "at",
8999 "atan",
9000 "atomic",
9001 "authorization",
9002 "avg",
9003 "begin",
9004 "begin_frame",
9005 "begin_partition",
9006 "between",
9007 "bigint",
9008 "binary",
9009 "blob",
9010 "boolean",
9011 "both",
9012 "by",
9013 "call",
9014 "called",
9015 "cardinality",
9016 "cascaded",
9017 "case",
9018 "cast",
9019 "ceil",
9020 "ceiling",
9021 "char",
9022 "char_length",
9023 "character",
9024 "character_length",
9025 "check",
9026 "classifier",
9027 "clob",
9028 "close",
9029 "coalesce",
9030 "collate",
9031 "collect",
9032 "column",
9033 "commit",
9034 "condition",
9035 "connect",
9036 "constraint",
9037 "contains",
9038 "convert",
9039 "copy",
9040 "corr",
9041 "corresponding",
9042 "cos",
9043 "cosh",
9044 "count",
9045 "covar_pop",
9046 "covar_samp",
9047 "create",
9048 "cross",
9049 "cube",
9050 "cume_dist",
9051 "current",
9052 "current_catalog",
9053 "current_date",
9054 "current_default_transform_group",
9055 "current_path",
9056 "current_role",
9057 "current_row",
9058 "current_schema",
9059 "current_time",
9060 "current_timestamp",
9061 "current_path",
9062 "current_role",
9063 "current_transform_group_for_type",
9064 "current_user",
9065 "cursor",
9066 "cycle",
9067 "date",
9068 "day",
9069 "deallocate",
9070 "dec",
9071 "decimal",
9072 "decfloat",
9073 "declare",
9074 "default",
9075 "define",
9076 "delete",
9077 "dense_rank",
9078 "deref",
9079 "describe",
9080 "deterministic",
9081 "disconnect",
9082 "distinct",
9083 "double",
9084 "drop",
9085 "dynamic",
9086 "each",
9087 "element",
9088 "else",
9089 "empty",
9090 "end",
9091 "end_frame",
9092 "end_partition",
9093 "end-exec",
9094 "equals",
9095 "escape",
9096 "every",
9097 "except",
9098 "exec",
9099 "execute",
9100 "exists",
9101 "exp",
9102 "external",
9103 "extract",
9104 "false",
9105 "fetch",
9106 "filter",
9107 "first_value",
9108 "float",
9109 "floor",
9110 "for",
9111 "foreign",
9112 "frame_row",
9113 "free",
9114 "from",
9115 "full",
9116 "function",
9117 "fusion",
9118 "get",
9119 "global",
9120 "grant",
9121 "group",
9122 "grouping",
9123 "groups",
9124 "having",
9125 "hold",
9126 "hour",
9127 "identity",
9128 "in",
9129 "indicator",
9130 "initial",
9131 "inner",
9132 "inout",
9133 "insensitive",
9134 "insert",
9135 "int",
9136 "integer",
9137 "intersect",
9138 "intersection",
9139 "interval",
9140 "into",
9141 "is",
9142 "join",
9143 "json_array",
9144 "json_arrayagg",
9145 "json_exists",
9146 "json_object",
9147 "json_objectagg",
9148 "json_query",
9149 "json_table",
9150 "json_table_primitive",
9151 "json_value",
9152 "lag",
9153 "language",
9154 "large",
9155 "last_value",
9156 "lateral",
9157 "lead",
9158 "leading",
9159 "left",
9160 "like",
9161 "like_regex",
9162 "listagg",
9163 "ln",
9164 "local",
9165 "localtime",
9166 "localtimestamp",
9167 "log",
9168 "log10",
9169 "lower",
9170 "match",
9171 "match_number",
9172 "match_recognize",
9173 "matches",
9174 "max",
9175 "member",
9176 "merge",
9177 "method",
9178 "min",
9179 "minute",
9180 "mod",
9181 "modifies",
9182 "module",
9183 "month",
9184 "multiset",
9185 "national",
9186 "natural",
9187 "nchar",
9188 "nclob",
9189 "new",
9190 "no",
9191 "none",
9192 "normalize",
9193 "not",
9194 "nth_value",
9195 "ntile",
9196 "null",
9197 "nullif",
9198 "numeric",
9199 "octet_length",
9200 "occurrences_regex",
9201 "of",
9202 "offset",
9203 "old",
9204 "omit",
9205 "on",
9206 "one",
9207 "only",
9208 "open",
9209 "or",
9210 "order",
9211 "out",
9212 "outer",
9213 "over",
9214 "overlaps",
9215 "overlay",
9216 "parameter",
9217 "partition",
9218 "pattern",
9219 "per",
9220 "percent",
9221 "percent_rank",
9222 "percentile_cont",
9223 "percentile_disc",
9224 "period",
9225 "portion",
9226 "position",
9227 "position_regex",
9228 "power",
9229 "precedes",
9230 "precision",
9231 "prepare",
9232 "primary",
9233 "procedure",
9234 "ptf",
9235 "range",
9236 "rank",
9237 "reads",
9238 "real",
9239 "recursive",
9240 "ref",
9241 "references",
9242 "referencing",
9243 "regr_avgx",
9244 "regr_avgy",
9245 "regr_count",
9246 "regr_intercept",
9247 "regr_r2",
9248 "regr_slope",
9249 "regr_sxx",
9250 "regr_sxy",
9251 "regr_syy",
9252 "release",
9253 "result",
9254 "return",
9255 "returns",
9256 "revoke",
9257 "right",
9258 "rollback",
9259 "rollup",
9260 "row",
9261 "row_number",
9262 "rows",
9263 "running",
9264 "savepoint",
9265 "scope",
9266 "scroll",
9267 "search",
9268 "second",
9269 "seek",
9270 "select",
9271 "sensitive",
9272 "session_user",
9273 "set",
9274 "show",
9275 "similar",
9276 "sin",
9277 "sinh",
9278 "skip",
9279 "smallint",
9280 "some",
9281 "specific",
9282 "specifictype",
9283 "sql",
9284 "sqlexception",
9285 "sqlstate",
9286 "sqlwarning",
9287 "sqrt",
9288 "start",
9289 "static",
9290 "stddev_pop",
9291 "stddev_samp",
9292 "submultiset",
9293 "subset",
9294 "substring",
9295 "substring_regex",
9296 "succeeds",
9297 "sum",
9298 "symmetric",
9299 "system",
9300 "system_time",
9301 "system_user",
9302 "table",
9303 "tablesample",
9304 "tan",
9305 "tanh",
9306 "then",
9307 "time",
9308 "timestamp",
9309 "timezone_hour",
9310 "timezone_minute",
9311 "to",
9312 "trailing",
9313 "translate",
9314 "translate_regex",
9315 "translation",
9316 "treat",
9317 "trigger",
9318 "trim",
9319 "trim_array",
9320 "true",
9321 "truncate",
9322 "uescape",
9323 "union",
9324 "unique",
9325 "unknown",
9326 "unnest",
9327 "update ",
9328 "upper",
9329 "user",
9330 "using",
9331 "value",
9332 "values",
9333 "value_of",
9334 "var_pop",
9335 "var_samp",
9336 "varbinary",
9337 "varchar",
9338 "varying",
9339 "versioning",
9340 "when",
9341 "whenever",
9342 "where",
9343 "width_bucket",
9344 "window",
9345 "with",
9346 "within",
9347 "without",
9348 "year",
9349 ];
9350
9351 // these are reserved words we have identified to be functions
9352 // and should only be highlighted in a dispatch-like context
9353 // ie, array_agg(...), etc.
9354 const RESERVED_FUNCTIONS = [
9355 "abs",
9356 "acos",
9357 "array_agg",
9358 "asin",
9359 "atan",
9360 "avg",
9361 "cast",
9362 "ceil",
9363 "ceiling",
9364 "coalesce",
9365 "corr",
9366 "cos",
9367 "cosh",
9368 "count",
9369 "covar_pop",
9370 "covar_samp",
9371 "cume_dist",
9372 "dense_rank",
9373 "deref",
9374 "element",
9375 "exp",
9376 "extract",
9377 "first_value",
9378 "floor",
9379 "json_array",
9380 "json_arrayagg",
9381 "json_exists",
9382 "json_object",
9383 "json_objectagg",
9384 "json_query",
9385 "json_table",
9386 "json_table_primitive",
9387 "json_value",
9388 "lag",
9389 "last_value",
9390 "lead",
9391 "listagg",
9392 "ln",
9393 "log",
9394 "log10",
9395 "lower",
9396 "max",
9397 "min",
9398 "mod",
9399 "nth_value",
9400 "ntile",
9401 "nullif",
9402 "percent_rank",
9403 "percentile_cont",
9404 "percentile_disc",
9405 "position",
9406 "position_regex",
9407 "power",
9408 "rank",
9409 "regr_avgx",
9410 "regr_avgy",
9411 "regr_count",
9412 "regr_intercept",
9413 "regr_r2",
9414 "regr_slope",
9415 "regr_sxx",
9416 "regr_sxy",
9417 "regr_syy",
9418 "row_number",
9419 "sin",
9420 "sinh",
9421 "sqrt",
9422 "stddev_pop",
9423 "stddev_samp",
9424 "substring",
9425 "substring_regex",
9426 "sum",
9427 "tan",
9428 "tanh",
9429 "translate",
9430 "translate_regex",
9431 "treat",
9432 "trim",
9433 "trim_array",
9434 "unnest",
9435 "upper",
9436 "value_of",
9437 "var_pop",
9438 "var_samp",
9439 "width_bucket",
9440 ];
9441
9442 // these functions can
9443 const POSSIBLE_WITHOUT_PARENS = [
9444 "current_catalog",
9445 "current_date",
9446 "current_default_transform_group",
9447 "current_path",
9448 "current_role",
9449 "current_schema",
9450 "current_transform_group_for_type",
9451 "current_user",
9452 "session_user",
9453 "system_time",
9454 "system_user",
9455 "current_time",
9456 "localtime",
9457 "current_timestamp",
9458 "localtimestamp"
9459 ];
9460
9461 // those exist to boost relevance making these very
9462 // "SQL like" keyword combos worth +1 extra relevance
9463 const COMBOS = [
9464 "create table",
9465 "insert into",
9466 "primary key",
9467 "foreign key",
9468 "not null",
9469 "alter table",
9470 "add constraint",
9471 "grouping sets",
9472 "on overflow",
9473 "character set",
9474 "respect nulls",
9475 "ignore nulls",
9476 "nulls first",
9477 "nulls last",
9478 "depth first",
9479 "breadth first"
9480 ];
9481
9482 const FUNCTIONS = RESERVED_FUNCTIONS;
9483
9484 const KEYWORDS = [...RESERVED_WORDS, ...NON_RESERVED_WORDS].filter((keyword) => {
9485 return !RESERVED_FUNCTIONS.includes(keyword);
9486 });
9487
9488 const VARIABLE = {
9489 className: "variable",
9490 begin: /@[a-z0-9]+/,
9491 };
9492
9493 const OPERATOR = {
9494 className: "operator",
9495 begin: /[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,
9496 relevance: 0,
9497 };
9498
9499 const FUNCTION_CALL = {
9500 begin: concat(/\b/, either(...FUNCTIONS), /\s*\(/),
9501 keywords: {
9502 built_in: FUNCTIONS.join(" ")
9503 }
9504 };
9505
9506 // keywords with less than 3 letters are reduced in relevancy
9507 function reduceRelevancy(list, {exceptions, when} = {}) {
9508 const qualifyFn = when;
9509 exceptions = exceptions || [];
9510 return list.map((item) => {
9511 if (item.match(/\|\d+$/) || exceptions.includes(item)) {
9512 return item;
9513 } else if (qualifyFn(item)) {
9514 return `${item}|0`;
9515 } else {
9516 return item;
9517 }
9518 });
9519 }
9520
9521 return {
9522 name: 'SQL',
9523 case_insensitive: true,
9524 // does not include {} or HTML tags `</`
9525 illegal: /[{}]|<\//,
9526 keywords: {
9527 $pattern: /\b[\w\.]+/,
9528 keyword:
9529 reduceRelevancy(KEYWORDS, { when: (x) => x.length < 3 }).join(" "),
9530 literal: LITERALS.join(" "),
9531 type: TYPES.join(" "),
9532 built_in: POSSIBLE_WITHOUT_PARENS.join(" ")
9533 },
9534 contains: [
9535 {
9536 begin: either(...COMBOS),
9537 keywords: {
9538 $pattern: /[\w\.]+/,
9539 keyword: KEYWORDS.concat(COMBOS).join(" "),
9540 literal: LITERALS.join(" "),
9541 type: TYPES.join(" ")
9542 },
9543 },
9544 {
9545 className: "type",
9546 begin: either(...MULTI_WORD_TYPES)
9547 },
9548 FUNCTION_CALL,
9549 VARIABLE,
9550 STRING,
9551 QUOTED_IDENTIFIER,
9552 hljs.C_NUMBER_MODE,
9553 hljs.C_BLOCK_COMMENT_MODE,
9554 COMMENT_MODE,
9555 OPERATOR
9556 ]
9557 };
9558 }
9559
9560 return sql;
9561
9562 return module.exports.definer || module.exports;
9563
9564}());
9565
9566hljs.registerLanguage('swift', function () {
9567 'use strict';
9568
9569 /**
9570 * @param {string} value
9571 * @returns {RegExp}
9572 * */
9573
9574 /**
9575 * @param {RegExp | string } re
9576 * @returns {string}
9577 */
9578 function source(re) {
9579 if (!re) return null;
9580 if (typeof re === "string") return re;
9581
9582 return re.source;
9583 }
9584
9585 /**
9586 * @param {RegExp | string } re
9587 * @returns {string}
9588 */
9589 function lookahead(re) {
9590 return concat('(?=', re, ')');
9591 }
9592
9593 /**
9594 * @param {...(RegExp | string) } args
9595 * @returns {string}
9596 */
9597 function concat(...args) {
9598 const joined = args.map((x) => source(x)).join("");
9599 return joined;
9600 }
9601
9602 /**
9603 * Any of the passed expresssions may match
9604 *
9605 * Creates a huge this | this | that | that match
9606 * @param {(RegExp | string)[] } args
9607 * @returns {string}
9608 */
9609 function either(...args) {
9610 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
9611 return joined;
9612 }
9613
9614 const keywordWrapper = keyword => concat(
9615 /\b/,
9616 keyword,
9617 /\w$/.test(keyword) ? /\b/ : /\B/
9618 );
9619
9620 // Keywords that require a leading dot.
9621 const dotKeywords = [
9622 'Protocol', // contextual
9623 'Type' // contextual
9624 ].map(keywordWrapper);
9625
9626 // Keywords that may have a leading dot.
9627 const optionalDotKeywords = [
9628 'init',
9629 'self'
9630 ].map(keywordWrapper);
9631
9632 // should register as keyword, not type
9633 const keywordTypes = [
9634 'Any',
9635 'Self'
9636 ];
9637
9638 // Regular keywords and literals.
9639 const keywords = [
9640 // strings below will be fed into the regular `keywords` engine while regex
9641 // will result in additional modes being created to scan for those keywords to
9642 // avoid conflicts with other rules
9643 'associatedtype',
9644 /as\?/, // operator
9645 /as!/, // operator
9646 'as', // operator
9647 'break',
9648 'case',
9649 'catch',
9650 'class',
9651 'continue',
9652 'convenience', // contextual
9653 'default',
9654 'defer',
9655 'deinit',
9656 'didSet', // contextual
9657 'do',
9658 'dynamic', // contextual
9659 'else',
9660 'enum',
9661 'extension',
9662 'fallthrough',
9663 'fileprivate(set)',
9664 'fileprivate',
9665 'final', // contextual
9666 'for',
9667 'func',
9668 'get', // contextual
9669 'guard',
9670 'if',
9671 'import',
9672 'indirect', // contextual
9673 'infix', // contextual
9674 /init\?/,
9675 /init!/,
9676 'inout',
9677 'internal(set)',
9678 'internal',
9679 'in',
9680 'is', // operator
9681 'lazy', // contextual
9682 'let',
9683 'mutating', // contextual
9684 'nonmutating', // contextual
9685 'open(set)', // contextual
9686 'open', // contextual
9687 'operator',
9688 'optional', // contextual
9689 'override', // contextual
9690 'postfix', // contextual
9691 'precedencegroup',
9692 'prefix', // contextual
9693 'private(set)',
9694 'private',
9695 'protocol',
9696 'public(set)',
9697 'public',
9698 'repeat',
9699 'required', // contextual
9700 'rethrows',
9701 'return',
9702 'set', // contextual
9703 'some', // contextual
9704 'static',
9705 'struct',
9706 'subscript',
9707 'super',
9708 'switch',
9709 'throws',
9710 'throw',
9711 /try\?/, // operator
9712 /try!/, // operator
9713 'try', // operator
9714 'typealias',
9715 'unowned(safe)', // contextual
9716 'unowned(unsafe)', // contextual
9717 'unowned', // contextual
9718 'var',
9719 'weak', // contextual
9720 'where',
9721 'while',
9722 'willSet' // contextual
9723 ];
9724
9725 // NOTE: Contextual keywords are reserved only in specific contexts.
9726 // Ideally, these should be matched using modes to avoid false positives.
9727
9728 // TODO: Create a PRECEDENCE_GROUP mode to match the remaining contextual keywords:
9729 // assignment associativity higherThan left lowerThan none right
9730 // These aren't included in the list because they result in mostly false positives.
9731
9732 // Literals.
9733 const literals = [
9734 'false',
9735 'nil',
9736 'true'
9737 ];
9738
9739 // Keywords that start with a number sign (#).
9740 // #available is handled separately.
9741 const numberSignKeywords = [
9742 '#colorLiteral',
9743 '#column',
9744 '#dsohandle',
9745 '#else',
9746 '#elseif',
9747 '#endif',
9748 '#error',
9749 '#file',
9750 '#fileID',
9751 '#fileLiteral',
9752 '#filePath',
9753 '#function',
9754 '#if',
9755 '#imageLiteral',
9756 '#keyPath',
9757 '#line',
9758 '#selector',
9759 '#sourceLocation',
9760 '#warn_unqualified_access',
9761 '#warning'
9762 ];
9763
9764 // Global functions in the Standard Library.
9765 const builtIns = [
9766 'abs',
9767 'all',
9768 'any',
9769 'assert',
9770 'assertionFailure',
9771 'debugPrint',
9772 'dump',
9773 'fatalError',
9774 'getVaList',
9775 'isKnownUniquelyReferenced',
9776 'max',
9777 'min',
9778 'numericCast',
9779 'pointwiseMax',
9780 'pointwiseMin',
9781 'precondition',
9782 'preconditionFailure',
9783 'print',
9784 'readLine',
9785 'repeatElement',
9786 'sequence',
9787 'stride',
9788 'swap',
9789 'swift_unboxFromSwiftValueWithType',
9790 'transcode',
9791 'type',
9792 'unsafeBitCast',
9793 'unsafeDowncast',
9794 'withExtendedLifetime',
9795 'withUnsafeMutablePointer',
9796 'withUnsafePointer',
9797 'withVaList',
9798 'withoutActuallyEscaping',
9799 'zip'
9800 ];
9801
9802 // Valid first characters for operators.
9803 const operatorHead = either(
9804 /[/=\-+!*%<>&|^~?]/,
9805 /[\u00A1-\u00A7]/,
9806 /[\u00A9\u00AB]/,
9807 /[\u00AC\u00AE]/,
9808 /[\u00B0\u00B1]/,
9809 /[\u00B6\u00BB\u00BF\u00D7\u00F7]/,
9810 /[\u2016-\u2017]/,
9811 /[\u2020-\u2027]/,
9812 /[\u2030-\u203E]/,
9813 /[\u2041-\u2053]/,
9814 /[\u2055-\u205E]/,
9815 /[\u2190-\u23FF]/,
9816 /[\u2500-\u2775]/,
9817 /[\u2794-\u2BFF]/,
9818 /[\u2E00-\u2E7F]/,
9819 /[\u3001-\u3003]/,
9820 /[\u3008-\u3020]/,
9821 /[\u3030]/
9822 );
9823
9824 // Valid characters for operators.
9825 const operatorCharacter = either(
9826 operatorHead,
9827 /[\u0300-\u036F]/,
9828 /[\u1DC0-\u1DFF]/,
9829 /[\u20D0-\u20FF]/,
9830 /[\uFE00-\uFE0F]/,
9831 /[\uFE20-\uFE2F]/
9832 // TODO: The following characters are also allowed, but the regex isn't supported yet.
9833 // /[\u{E0100}-\u{E01EF}]/u
9834 );
9835
9836 // Valid operator.
9837 const operator = concat(operatorHead, operatorCharacter, '*');
9838
9839 // Valid first characters for identifiers.
9840 const identifierHead = either(
9841 /[a-zA-Z_]/,
9842 /[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,
9843 /[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,
9844 /[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,
9845 /[\u1E00-\u1FFF]/,
9846 /[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,
9847 /[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,
9848 /[\u2C00-\u2DFF\u2E80-\u2FFF]/,
9849 /[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,
9850 /[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,
9851 /[\uFE47-\uFFFD]/
9852 // The following characters are also allowed, but the regexes aren't supported yet.
9853 // /[\u{10000}-\u{1FFFD}\u{20000-\u{2FFFD}\u{30000}-\u{3FFFD}\u{40000}-\u{4FFFD}]/u,
9854 // /[\u{50000}-\u{5FFFD}\u{60000-\u{6FFFD}\u{70000}-\u{7FFFD}\u{80000}-\u{8FFFD}]/u,
9855 // /[\u{90000}-\u{9FFFD}\u{A0000-\u{AFFFD}\u{B0000}-\u{BFFFD}\u{C0000}-\u{CFFFD}]/u,
9856 // /[\u{D0000}-\u{DFFFD}\u{E0000-\u{EFFFD}]/u
9857 );
9858
9859 // Valid characters for identifiers.
9860 const identifierCharacter = either(
9861 identifierHead,
9862 /\d/,
9863 /[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/
9864 );
9865
9866 // Valid identifier.
9867 const identifier = concat(identifierHead, identifierCharacter, '*');
9868
9869 // Valid type identifier.
9870 const typeIdentifier = concat(/[A-Z]/, identifierCharacter, '*');
9871
9872 // Built-in attributes, which are highlighted as keywords.
9873 // @available is handled separately.
9874 const keywordAttributes = [
9875 'autoclosure',
9876 concat(/convention\(/, either('swift', 'block', 'c'), /\)/),
9877 'discardableResult',
9878 'dynamicCallable',
9879 'dynamicMemberLookup',
9880 'escaping',
9881 'frozen',
9882 'GKInspectable',
9883 'IBAction',
9884 'IBDesignable',
9885 'IBInspectable',
9886 'IBOutlet',
9887 'IBSegueAction',
9888 'inlinable',
9889 'main',
9890 'nonobjc',
9891 'NSApplicationMain',
9892 'NSCopying',
9893 'NSManaged',
9894 concat(/objc\(/, identifier, /\)/),
9895 'objc',
9896 'objcMembers',
9897 'propertyWrapper',
9898 'requires_stored_property_inits',
9899 'testable',
9900 'UIApplicationMain',
9901 'unknown',
9902 'usableFromInline'
9903 ];
9904
9905 // Contextual keywords used in @available and #available.
9906 const availabilityKeywords = [
9907 'iOS',
9908 'iOSApplicationExtension',
9909 'macOS',
9910 'macOSApplicationExtension',
9911 'macCatalyst',
9912 'macCatalystApplicationExtension',
9913 'watchOS',
9914 'watchOSApplicationExtension',
9915 'tvOS',
9916 'tvOSApplicationExtension',
9917 'swift'
9918 ];
9919
9920 /*
9921 Language: Swift
9922 Description: Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
9923 Author: Steven Van Impe <steven.vanimpe@icloud.com>
9924 Contributors: Chris Eidhof <chris@eidhof.nl>, Nate Cook <natecook@gmail.com>, Alexander Lichter <manniL@gmx.net>, Richard Gibson <gibson042@github>
9925 Website: https://swift.org
9926 Category: common, system
9927 */
9928
9929 /** @type LanguageFn */
9930 function swift(hljs) {
9931 // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID411
9932 const BLOCK_COMMENT = hljs.COMMENT(
9933 '/\\*',
9934 '\\*/',
9935 {
9936 contains: [ 'self' ]
9937 }
9938 );
9939
9940 // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID413
9941 // https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html
9942 const DOT_KEYWORD = {
9943 className: 'keyword',
9944 begin: concat(/\./, lookahead(either(...dotKeywords, ...optionalDotKeywords))),
9945 end: either(...dotKeywords, ...optionalDotKeywords),
9946 excludeBegin: true
9947 };
9948 const KEYWORD_GUARD = {
9949 // Consume .keyword to prevent highlighting properties and methods as keywords.
9950 begin: concat(/\./, either(...keywords)),
9951 relevance: 0
9952 };
9953 const PLAIN_KEYWORDS = keywords
9954 .filter(kw => typeof kw === 'string')
9955 .concat([ "_|0" ]); // seems common, so 0 relevance
9956 const REGEX_KEYWORDS = keywords
9957 .filter(kw => typeof kw !== 'string') // find regex
9958 .concat(keywordTypes)
9959 .map(keywordWrapper);
9960 const KEYWORD = {
9961 variants: [
9962 {
9963 className: 'keyword',
9964 begin: either(...REGEX_KEYWORDS, ...optionalDotKeywords)
9965 }
9966 ]
9967 };
9968 // find all the regular keywords
9969 const KEYWORDS = {
9970 $pattern: either(
9971 /\b\w+(\(\w+\))?/, // kw or kw(arg)
9972 /#\w+/ // number keywords
9973 ),
9974 keyword: PLAIN_KEYWORDS
9975 .concat(numberSignKeywords)
9976 .join(" "),
9977 literal: literals.join(" ")
9978 };
9979 const KEYWORD_MODES = [
9980 DOT_KEYWORD,
9981 KEYWORD_GUARD,
9982 KEYWORD
9983 ];
9984
9985 // https://github.com/apple/swift/tree/main/stdlib/public/core
9986 const BUILT_IN_GUARD = {
9987 // Consume .built_in to prevent highlighting properties and methods.
9988 begin: concat(/\./, either(...builtIns)),
9989 relevance: 0
9990 };
9991 const BUILT_IN = {
9992 className: 'built_in',
9993 begin: concat(/\b/, either(...builtIns), /(?=\()/)
9994 };
9995 const BUILT_INS = [
9996 BUILT_IN_GUARD,
9997 BUILT_IN
9998 ];
9999
10000 // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID418
10001 const OPERATOR_GUARD = {
10002 // Prevent -> from being highlighting as an operator.
10003 begin: /->/,
10004 relevance: 0
10005 };
10006 const OPERATOR = {
10007 className: 'operator',
10008 relevance: 0,
10009 variants: [
10010 {
10011 begin: operator
10012 },
10013 {
10014 // dot-operator: only operators that start with a dot are allowed to use dots as
10015 // characters (..., ...<, .*, etc). So there rule here is: a dot followed by one or more
10016 // characters that may also include dots.
10017 begin: `\\.(\\.|${operatorCharacter})+`
10018 }
10019 ]
10020 };
10021 const OPERATORS = [
10022 OPERATOR_GUARD,
10023 OPERATOR
10024 ];
10025
10026 // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#grammar_numeric-literal
10027 // TODO: Update for leading `-` after lookbehind is supported everywhere
10028 const decimalDigits = '([0-9]_*)+';
10029 const hexDigits = '([0-9a-fA-F]_*)+';
10030 const NUMBER = {
10031 className: 'number',
10032 relevance: 0,
10033 variants: [
10034 // decimal floating-point-literal (subsumes decimal-literal)
10035 {
10036 begin: `\\b(${decimalDigits})(\\.(${decimalDigits}))?` + `([eE][+-]?(${decimalDigits}))?\\b`
10037 },
10038 // hexadecimal floating-point-literal (subsumes hexadecimal-literal)
10039 {
10040 begin: `\\b0x(${hexDigits})(\\.(${hexDigits}))?` + `([pP][+-]?(${decimalDigits}))?\\b`
10041 },
10042 // octal-literal
10043 {
10044 begin: /\b0o([0-7]_*)+\b/
10045 },
10046 // binary-literal
10047 {
10048 begin: /\b0b([01]_*)+\b/
10049 }
10050 ]
10051 };
10052
10053 // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#grammar_string-literal
10054 const ESCAPED_CHARACTER = (rawDelimiter = "") => ({
10055 className: 'subst',
10056 variants: [
10057 {
10058 begin: concat(/\\/, rawDelimiter, /[0\\tnr"']/)
10059 },
10060 {
10061 begin: concat(/\\/, rawDelimiter, /u\{[0-9a-fA-F]{1,8}\}/)
10062 }
10063 ]
10064 });
10065 const ESCAPED_NEWLINE = (rawDelimiter = "") => ({
10066 className: 'subst',
10067 begin: concat(/\\/, rawDelimiter, /[\t ]*(?:[\r\n]|\r\n)/)
10068 });
10069 const INTERPOLATION = (rawDelimiter = "") => ({
10070 className: 'subst',
10071 label: "interpol",
10072 begin: concat(/\\/, rawDelimiter, /\(/),
10073 end: /\)/
10074 });
10075 const MULTILINE_STRING = (rawDelimiter = "") => ({
10076 begin: concat(rawDelimiter, /"""/),
10077 end: concat(/"""/, rawDelimiter),
10078 contains: [
10079 ESCAPED_CHARACTER(rawDelimiter),
10080 ESCAPED_NEWLINE(rawDelimiter),
10081 INTERPOLATION(rawDelimiter)
10082 ]
10083 });
10084 const SINGLE_LINE_STRING = (rawDelimiter = "") => ({
10085 begin: concat(rawDelimiter, /"/),
10086 end: concat(/"/, rawDelimiter),
10087 contains: [
10088 ESCAPED_CHARACTER(rawDelimiter),
10089 INTERPOLATION(rawDelimiter)
10090 ]
10091 });
10092 const STRING = {
10093 className: 'string',
10094 variants: [
10095 MULTILINE_STRING(),
10096 MULTILINE_STRING("#"),
10097 MULTILINE_STRING("##"),
10098 MULTILINE_STRING("###"),
10099 SINGLE_LINE_STRING(),
10100 SINGLE_LINE_STRING("#"),
10101 SINGLE_LINE_STRING("##"),
10102 SINGLE_LINE_STRING("###")
10103 ]
10104 };
10105
10106 // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID412
10107 const QUOTED_IDENTIFIER = {
10108 begin: concat(/`/, identifier, /`/)
10109 };
10110 const IMPLICIT_PARAMETER = {
10111 className: 'variable',
10112 begin: /\$\d+/
10113 };
10114 const PROPERTY_WRAPPER_PROJECTION = {
10115 className: 'variable',
10116 begin: `\\$${identifierCharacter}+`
10117 };
10118 const IDENTIFIERS = [
10119 QUOTED_IDENTIFIER,
10120 IMPLICIT_PARAMETER,
10121 PROPERTY_WRAPPER_PROJECTION
10122 ];
10123
10124 // https://docs.swift.org/swift-book/ReferenceManual/Attributes.html
10125 const AVAILABLE_ATTRIBUTE = {
10126 begin: /(@|#)available\(/,
10127 end: /\)/,
10128 keywords: {
10129 $pattern: /[@#]?\w+/,
10130 keyword: availabilityKeywords
10131 .concat([
10132 "@available",
10133 "#available"
10134 ])
10135 .join(' ')
10136 },
10137 contains: [
10138 ...OPERATORS,
10139 NUMBER,
10140 STRING
10141 ]
10142 };
10143 const KEYWORD_ATTRIBUTE = {
10144 className: 'keyword',
10145 begin: concat(/@/, either(...keywordAttributes))
10146 };
10147 const USER_DEFINED_ATTRIBUTE = {
10148 className: 'meta',
10149 begin: concat(/@/, identifier)
10150 };
10151 const ATTRIBUTES = [
10152 AVAILABLE_ATTRIBUTE,
10153 KEYWORD_ATTRIBUTE,
10154 USER_DEFINED_ATTRIBUTE
10155 ];
10156
10157 // https://docs.swift.org/swift-book/ReferenceManual/Types.html
10158 const TYPE = {
10159 begin: lookahead(/\b[A-Z]/),
10160 relevance: 0,
10161 contains: [
10162 { // Common Apple frameworks, for relevance boost
10163 className: 'type',
10164 begin: concat(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/, identifierCharacter, '+')
10165 },
10166 { // Type identifier
10167 className: 'type',
10168 begin: typeIdentifier,
10169 relevance: 0
10170 },
10171 { // Optional type
10172 begin: /[?!]+/,
10173 relevance: 0
10174 },
10175 { // Variadic parameter
10176 begin: /\.\.\./,
10177 relevance: 0
10178 },
10179 { // Protocol composition
10180 begin: concat(/\s+&\s+/, lookahead(typeIdentifier)),
10181 relevance: 0
10182 }
10183 ]
10184 };
10185 const GENERIC_ARGUMENTS = {
10186 begin: /</,
10187 end: />/,
10188 keywords: KEYWORDS,
10189 contains: [
10190 ...KEYWORD_MODES,
10191 ...ATTRIBUTES,
10192 OPERATOR_GUARD,
10193 TYPE
10194 ]
10195 };
10196 TYPE.contains.push(GENERIC_ARGUMENTS);
10197
10198 // Add supported submodes to string interpolation.
10199 for (const variant of STRING.variants) {
10200 const interpolation = variant.contains.find(mode => mode.label === "interpol");
10201 // TODO: Interpolation can contain any expression, so there's room for improvement here.
10202 interpolation.keywords = KEYWORDS;
10203 const submodes = [
10204 ...KEYWORD_MODES,
10205 ...BUILT_INS,
10206 ...OPERATORS,
10207 NUMBER,
10208 STRING,
10209 ...IDENTIFIERS
10210 ];
10211 interpolation.contains = [
10212 ...submodes,
10213 {
10214 begin: /\(/,
10215 end: /\)/,
10216 contains: [
10217 'self',
10218 ...submodes
10219 ]
10220 }
10221 ];
10222 }
10223
10224 return {
10225 name: 'Swift',
10226 keywords: KEYWORDS,
10227 contains: [
10228 hljs.C_LINE_COMMENT_MODE,
10229 BLOCK_COMMENT,
10230 {
10231 className: 'function',
10232 beginKeywords: 'func',
10233 end: /\{/,
10234 excludeEnd: true,
10235 contains: [
10236 hljs.inherit(hljs.TITLE_MODE, {
10237 begin: /[A-Za-z$_][0-9A-Za-z$_]*/
10238 }),
10239 {
10240 begin: /</,
10241 end: />/
10242 },
10243 {
10244 className: 'params',
10245 begin: /\(/,
10246 end: /\)/,
10247 endsParent: true,
10248 keywords: KEYWORDS,
10249 contains: [
10250 'self',
10251 ...KEYWORD_MODES,
10252 NUMBER,
10253 STRING,
10254 hljs.C_BLOCK_COMMENT_MODE,
10255 { // relevance booster
10256 begin: ':'
10257 }
10258 ],
10259 illegal: /["']/
10260 }
10261 ],
10262 illegal: /\[|%/
10263 },
10264 {
10265 className: 'class',
10266 beginKeywords: 'struct protocol class extension enum',
10267 end: '\\{',
10268 excludeEnd: true,
10269 keywords: KEYWORDS,
10270 contains: [
10271 hljs.inherit(hljs.TITLE_MODE, {
10272 begin: /[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/
10273 }),
10274 ...KEYWORD_MODES
10275 ]
10276 },
10277 {
10278 beginKeywords: 'import',
10279 end: /$/,
10280 contains: [
10281 hljs.C_LINE_COMMENT_MODE,
10282 BLOCK_COMMENT
10283 ],
10284 relevance: 0
10285 },
10286 ...KEYWORD_MODES,
10287 ...BUILT_INS,
10288 ...OPERATORS,
10289 NUMBER,
10290 STRING,
10291 ...IDENTIFIERS,
10292 ...ATTRIBUTES,
10293 TYPE
10294 ]
10295 };
10296 }
10297
10298 return swift;
10299
10300 return module.exports.definer || module.exports;
10301
10302}());
10303
10304hljs.registerLanguage('typescript', function () {
10305 'use strict';
10306
10307 const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
10308 const KEYWORDS = [
10309 "as", // for exports
10310 "in",
10311 "of",
10312 "if",
10313 "for",
10314 "while",
10315 "finally",
10316 "var",
10317 "new",
10318 "function",
10319 "do",
10320 "return",
10321 "void",
10322 "else",
10323 "break",
10324 "catch",
10325 "instanceof",
10326 "with",
10327 "throw",
10328 "case",
10329 "default",
10330 "try",
10331 "switch",
10332 "continue",
10333 "typeof",
10334 "delete",
10335 "let",
10336 "yield",
10337 "const",
10338 "class",
10339 // JS handles these with a special rule
10340 // "get",
10341 // "set",
10342 "debugger",
10343 "async",
10344 "await",
10345 "static",
10346 "import",
10347 "from",
10348 "export",
10349 "extends"
10350 ];
10351 const LITERALS = [
10352 "true",
10353 "false",
10354 "null",
10355 "undefined",
10356 "NaN",
10357 "Infinity"
10358 ];
10359
10360 const TYPES = [
10361 "Intl",
10362 "DataView",
10363 "Number",
10364 "Math",
10365 "Date",
10366 "String",
10367 "RegExp",
10368 "Object",
10369 "Function",
10370 "Boolean",
10371 "Error",
10372 "Symbol",
10373 "Set",
10374 "Map",
10375 "WeakSet",
10376 "WeakMap",
10377 "Proxy",
10378 "Reflect",
10379 "JSON",
10380 "Promise",
10381 "Float64Array",
10382 "Int16Array",
10383 "Int32Array",
10384 "Int8Array",
10385 "Uint16Array",
10386 "Uint32Array",
10387 "Float32Array",
10388 "Array",
10389 "Uint8Array",
10390 "Uint8ClampedArray",
10391 "ArrayBuffer"
10392 ];
10393
10394 const ERROR_TYPES = [
10395 "EvalError",
10396 "InternalError",
10397 "RangeError",
10398 "ReferenceError",
10399 "SyntaxError",
10400 "TypeError",
10401 "URIError"
10402 ];
10403
10404 const BUILT_IN_GLOBALS = [
10405 "setInterval",
10406 "setTimeout",
10407 "clearInterval",
10408 "clearTimeout",
10409
10410 "require",
10411 "exports",
10412
10413 "eval",
10414 "isFinite",
10415 "isNaN",
10416 "parseFloat",
10417 "parseInt",
10418 "decodeURI",
10419 "decodeURIComponent",
10420 "encodeURI",
10421 "encodeURIComponent",
10422 "escape",
10423 "unescape"
10424 ];
10425
10426 const BUILT_IN_VARIABLES = [
10427 "arguments",
10428 "this",
10429 "super",
10430 "console",
10431 "window",
10432 "document",
10433 "localStorage",
10434 "module",
10435 "global" // Node.js
10436 ];
10437
10438 const BUILT_INS = [].concat(
10439 BUILT_IN_GLOBALS,
10440 BUILT_IN_VARIABLES,
10441 TYPES,
10442 ERROR_TYPES
10443 );
10444
10445 /**
10446 * @param {string} value
10447 * @returns {RegExp}
10448 * */
10449
10450 /**
10451 * @param {RegExp | string } re
10452 * @returns {string}
10453 */
10454 function source(re) {
10455 if (!re) return null;
10456 if (typeof re === "string") return re;
10457
10458 return re.source;
10459 }
10460
10461 /**
10462 * @param {RegExp | string } re
10463 * @returns {string}
10464 */
10465 function lookahead(re) {
10466 return concat('(?=', re, ')');
10467 }
10468
10469 /**
10470 * @param {...(RegExp | string) } args
10471 * @returns {string}
10472 */
10473 function concat(...args) {
10474 const joined = args.map((x) => source(x)).join("");
10475 return joined;
10476 }
10477
10478 /*
10479 Language: JavaScript
10480 Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
10481 Category: common, scripting
10482 Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
10483 */
10484
10485 /** @type LanguageFn */
10486 function javascript(hljs) {
10487 /**
10488 * Takes a string like "<Booger" and checks to see
10489 * if we can find a matching "</Booger" later in the
10490 * content.
10491 * @param {RegExpMatchArray} match
10492 * @param {{after:number}} param1
10493 */
10494 const hasClosingTag = (match, { after }) => {
10495 const tag = "</" + match[0].slice(1);
10496 const pos = match.input.indexOf(tag, after);
10497 return pos !== -1;
10498 };
10499
10500 const IDENT_RE$1 = IDENT_RE;
10501 const FRAGMENT = {
10502 begin: '<>',
10503 end: '</>'
10504 };
10505 const XML_TAG = {
10506 begin: /<[A-Za-z0-9\\._:-]+/,
10507 end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
10508 /**
10509 * @param {RegExpMatchArray} match
10510 * @param {CallbackResponse} response
10511 */
10512 isTrulyOpeningTag: (match, response) => {
10513 const afterMatchIndex = match[0].length + match.index;
10514 const nextChar = match.input[afterMatchIndex];
10515 // nested type?
10516 // HTML should not include another raw `<` inside a tag
10517 // But a type might: `<Array<Array<number>>`, etc.
10518 if (nextChar === "<") {
10519 response.ignoreMatch();
10520 return;
10521 }
10522 // <something>
10523 // This is now either a tag or a type.
10524 if (nextChar === ">") {
10525 // if we cannot find a matching closing tag, then we
10526 // will ignore it
10527 if (!hasClosingTag(match, { after: afterMatchIndex })) {
10528 response.ignoreMatch();
10529 }
10530 }
10531 }
10532 };
10533 const KEYWORDS$1 = {
10534 $pattern: IDENT_RE,
10535 keyword: KEYWORDS.join(" "),
10536 literal: LITERALS.join(" "),
10537 built_in: BUILT_INS.join(" ")
10538 };
10539
10540 // https://tc39.es/ecma262/#sec-literals-numeric-literals
10541 const decimalDigits = '[0-9](_?[0-9])*';
10542 const frac = `\\.(${decimalDigits})`;
10543 // DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
10544 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
10545 const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
10546 const NUMBER = {
10547 className: 'number',
10548 variants: [
10549 // DecimalLiteral
10550 { begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))` +
10551 `[eE][+-]?(${decimalDigits})\\b` },
10552 { begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
10553
10554 // DecimalBigIntegerLiteral
10555 { begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
10556
10557 // NonDecimalIntegerLiteral
10558 { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
10559 { begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
10560 { begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
10561
10562 // LegacyOctalIntegerLiteral (does not include underscore separators)
10563 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
10564 { begin: "\\b0[0-7]+n?\\b" },
10565 ],
10566 relevance: 0
10567 };
10568
10569 const SUBST = {
10570 className: 'subst',
10571 begin: '\\$\\{',
10572 end: '\\}',
10573 keywords: KEYWORDS$1,
10574 contains: [] // defined later
10575 };
10576 const HTML_TEMPLATE = {
10577 begin: 'html`',
10578 end: '',
10579 starts: {
10580 end: '`',
10581 returnEnd: false,
10582 contains: [
10583 hljs.BACKSLASH_ESCAPE,
10584 SUBST
10585 ],
10586 subLanguage: 'xml'
10587 }
10588 };
10589 const CSS_TEMPLATE = {
10590 begin: 'css`',
10591 end: '',
10592 starts: {
10593 end: '`',
10594 returnEnd: false,
10595 contains: [
10596 hljs.BACKSLASH_ESCAPE,
10597 SUBST
10598 ],
10599 subLanguage: 'css'
10600 }
10601 };
10602 const TEMPLATE_STRING = {
10603 className: 'string',
10604 begin: '`',
10605 end: '`',
10606 contains: [
10607 hljs.BACKSLASH_ESCAPE,
10608 SUBST
10609 ]
10610 };
10611 const JSDOC_COMMENT = hljs.COMMENT(
10612 /\/\*\*(?!\/)/,
10613 '\\*/',
10614 {
10615 relevance: 0,
10616 contains: [
10617 {
10618 className: 'doctag',
10619 begin: '@[A-Za-z]+',
10620 contains: [
10621 {
10622 className: 'type',
10623 begin: '\\{',
10624 end: '\\}',
10625 relevance: 0
10626 },
10627 {
10628 className: 'variable',
10629 begin: IDENT_RE$1 + '(?=\\s*(-)|$)',
10630 endsParent: true,
10631 relevance: 0
10632 },
10633 // eat spaces (not newlines) so we can find
10634 // types or variables
10635 {
10636 begin: /(?=[^\n])\s/,
10637 relevance: 0
10638 }
10639 ]
10640 }
10641 ]
10642 }
10643 );
10644 const COMMENT = {
10645 className: "comment",
10646 variants: [
10647 JSDOC_COMMENT,
10648 hljs.C_BLOCK_COMMENT_MODE,
10649 hljs.C_LINE_COMMENT_MODE
10650 ]
10651 };
10652 const SUBST_INTERNALS = [
10653 hljs.APOS_STRING_MODE,
10654 hljs.QUOTE_STRING_MODE,
10655 HTML_TEMPLATE,
10656 CSS_TEMPLATE,
10657 TEMPLATE_STRING,
10658 NUMBER,
10659 hljs.REGEXP_MODE
10660 ];
10661 SUBST.contains = SUBST_INTERNALS
10662 .concat({
10663 // we need to pair up {} inside our subst to prevent
10664 // it from ending too early by matching another }
10665 begin: /\{/,
10666 end: /\}/,
10667 keywords: KEYWORDS$1,
10668 contains: [
10669 "self"
10670 ].concat(SUBST_INTERNALS)
10671 });
10672 const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
10673 const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
10674 // eat recursive parens in sub expressions
10675 {
10676 begin: /\(/,
10677 end: /\)/,
10678 keywords: KEYWORDS$1,
10679 contains: ["self"].concat(SUBST_AND_COMMENTS)
10680 }
10681 ]);
10682 const PARAMS = {
10683 className: 'params',
10684 begin: /\(/,
10685 end: /\)/,
10686 excludeBegin: true,
10687 excludeEnd: true,
10688 keywords: KEYWORDS$1,
10689 contains: PARAMS_CONTAINS
10690 };
10691
10692 return {
10693 name: 'Javascript',
10694 aliases: ['js', 'jsx', 'mjs', 'cjs'],
10695 keywords: KEYWORDS$1,
10696 // this will be extended by TypeScript
10697 exports: { PARAMS_CONTAINS },
10698 illegal: /#(?![$_A-z])/,
10699 contains: [
10700 hljs.SHEBANG({
10701 label: "shebang",
10702 binary: "node",
10703 relevance: 5
10704 }),
10705 {
10706 label: "use_strict",
10707 className: 'meta',
10708 relevance: 10,
10709 begin: /^\s*['"]use (strict|asm)['"]/
10710 },
10711 hljs.APOS_STRING_MODE,
10712 hljs.QUOTE_STRING_MODE,
10713 HTML_TEMPLATE,
10714 CSS_TEMPLATE,
10715 TEMPLATE_STRING,
10716 COMMENT,
10717 NUMBER,
10718 { // object attr container
10719 begin: concat(/[{,\n]\s*/,
10720 // we need to look ahead to make sure that we actually have an
10721 // attribute coming up so we don't steal a comma from a potential
10722 // "value" container
10723 //
10724 // NOTE: this might not work how you think. We don't actually always
10725 // enter this mode and stay. Instead it might merely match `,
10726 // <comments up next>` and then immediately end after the , because it
10727 // fails to find any actual attrs. But this still does the job because
10728 // it prevents the value contain rule from grabbing this instead and
10729 // prevening this rule from firing when we actually DO have keys.
10730 lookahead(concat(
10731 // we also need to allow for multiple possible comments inbetween
10732 // the first key:value pairing
10733 /(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,
10734 IDENT_RE$1 + '\\s*:'))),
10735 relevance: 0,
10736 contains: [
10737 {
10738 className: 'attr',
10739 begin: IDENT_RE$1 + lookahead('\\s*:'),
10740 relevance: 0
10741 }
10742 ]
10743 },
10744 { // "value" container
10745 begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
10746 keywords: 'return throw case',
10747 contains: [
10748 COMMENT,
10749 hljs.REGEXP_MODE,
10750 {
10751 className: 'function',
10752 // we have to count the parens to make sure we actually have the
10753 // correct bounding ( ) before the =>. There could be any number of
10754 // sub-expressions inside also surrounded by parens.
10755 begin: '(\\(' +
10756 '[^()]*(\\(' +
10757 '[^()]*(\\(' +
10758 '[^()]*' +
10759 '\\)[^()]*)*' +
10760 '\\)[^()]*)*' +
10761 '\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>',
10762 returnBegin: true,
10763 end: '\\s*=>',
10764 contains: [
10765 {
10766 className: 'params',
10767 variants: [
10768 {
10769 begin: hljs.UNDERSCORE_IDENT_RE,
10770 relevance: 0
10771 },
10772 {
10773 className: null,
10774 begin: /\(\s*\)/,
10775 skip: true
10776 },
10777 {
10778 begin: /\(/,
10779 end: /\)/,
10780 excludeBegin: true,
10781 excludeEnd: true,
10782 keywords: KEYWORDS$1,
10783 contains: PARAMS_CONTAINS
10784 }
10785 ]
10786 }
10787 ]
10788 },
10789 { // could be a comma delimited list of params to a function call
10790 begin: /,/, relevance: 0
10791 },
10792 {
10793 className: '',
10794 begin: /\s/,
10795 end: /\s*/,
10796 skip: true
10797 },
10798 { // JSX
10799 variants: [
10800 { begin: FRAGMENT.begin, end: FRAGMENT.end },
10801 {
10802 begin: XML_TAG.begin,
10803 // we carefully check the opening tag to see if it truly
10804 // is a tag and not a false positive
10805 'on:begin': XML_TAG.isTrulyOpeningTag,
10806 end: XML_TAG.end
10807 }
10808 ],
10809 subLanguage: 'xml',
10810 contains: [
10811 {
10812 begin: XML_TAG.begin,
10813 end: XML_TAG.end,
10814 skip: true,
10815 contains: ['self']
10816 }
10817 ]
10818 }
10819 ],
10820 relevance: 0
10821 },
10822 {
10823 className: 'function',
10824 beginKeywords: 'function',
10825 end: /[{;]/,
10826 excludeEnd: true,
10827 keywords: KEYWORDS$1,
10828 contains: [
10829 'self',
10830 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
10831 PARAMS
10832 ],
10833 illegal: /%/
10834 },
10835 {
10836 // prevent this from getting swallowed up by function
10837 // since they appear "function like"
10838 beginKeywords: "while if switch catch for"
10839 },
10840 {
10841 className: 'function',
10842 // we have to count the parens to make sure we actually have the correct
10843 // bounding ( ). There could be any number of sub-expressions inside
10844 // also surrounded by parens.
10845 begin: hljs.UNDERSCORE_IDENT_RE +
10846 '\\(' + // first parens
10847 '[^()]*(\\(' +
10848 '[^()]*(\\(' +
10849 '[^()]*' +
10850 '\\)[^()]*)*' +
10851 '\\)[^()]*)*' +
10852 '\\)\\s*\\{', // end parens
10853 returnBegin:true,
10854 contains: [
10855 PARAMS,
10856 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
10857 ]
10858 },
10859 // hack: prevents detection of keywords in some circumstances
10860 // .keyword()
10861 // $keyword = x
10862 {
10863 variants: [
10864 { begin: '\\.' + IDENT_RE$1 },
10865 { begin: '\\$' + IDENT_RE$1 }
10866 ],
10867 relevance: 0
10868 },
10869 { // ES6 class
10870 className: 'class',
10871 beginKeywords: 'class',
10872 end: /[{;=]/,
10873 excludeEnd: true,
10874 illegal: /[:"[\]]/,
10875 contains: [
10876 { beginKeywords: 'extends' },
10877 hljs.UNDERSCORE_TITLE_MODE
10878 ]
10879 },
10880 {
10881 begin: /\b(?=constructor)/,
10882 end: /[{;]/,
10883 excludeEnd: true,
10884 contains: [
10885 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
10886 'self',
10887 PARAMS
10888 ]
10889 },
10890 {
10891 begin: '(get|set)\\s+(?=' + IDENT_RE$1 + '\\()',
10892 end: /\{/,
10893 keywords: "get set",
10894 contains: [
10895 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
10896 { begin: /\(\)/ }, // eat to avoid empty params
10897 PARAMS
10898 ]
10899 },
10900 {
10901 begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
10902 }
10903 ]
10904 };
10905 }
10906
10907 /*
10908 Language: TypeScript
10909 Author: Panu Horsmalahti <panu.horsmalahti@iki.fi>
10910 Contributors: Ike Ku <dempfi@yahoo.com>
10911 Description: TypeScript is a strict superset of JavaScript
10912 Website: https://www.typescriptlang.org
10913 Category: common, scripting
10914 */
10915
10916 /** @type LanguageFn */
10917 function typescript(hljs) {
10918 const IDENT_RE$1 = IDENT_RE;
10919 const NAMESPACE = {
10920 beginKeywords: 'namespace', end: /\{/, excludeEnd: true
10921 };
10922 const INTERFACE = {
10923 beginKeywords: 'interface', end: /\{/, excludeEnd: true,
10924 keywords: 'interface extends'
10925 };
10926 const USE_STRICT = {
10927 className: 'meta',
10928 relevance: 10,
10929 begin: /^\s*['"]use strict['"]/
10930 };
10931 const TYPES = [
10932 "any",
10933 "void",
10934 "number",
10935 "boolean",
10936 "string",
10937 "object",
10938 "never",
10939 "enum"
10940 ];
10941 const TS_SPECIFIC_KEYWORDS = [
10942 "type",
10943 "namespace",
10944 "typedef",
10945 "interface",
10946 "public",
10947 "private",
10948 "protected",
10949 "implements",
10950 "declare",
10951 "abstract",
10952 "readonly"
10953 ];
10954 const KEYWORDS$1 = {
10955 $pattern: IDENT_RE,
10956 keyword: KEYWORDS.concat(TS_SPECIFIC_KEYWORDS).join(" "),
10957 literal: LITERALS.join(" "),
10958 built_in: BUILT_INS.concat(TYPES).join(" ")
10959 };
10960 const DECORATOR = {
10961 className: 'meta',
10962 begin: '@' + IDENT_RE$1,
10963 };
10964
10965 const swapMode = (mode, label, replacement) => {
10966 const indx = mode.contains.findIndex(m => m.label === label);
10967 if (indx === -1) { throw new Error("can not find mode to replace"); }
10968 mode.contains.splice(indx, 1, replacement);
10969 };
10970
10971 const tsLanguage = javascript(hljs);
10972
10973 // this should update anywhere keywords is used since
10974 // it will be the same actual JS object
10975 Object.assign(tsLanguage.keywords, KEYWORDS$1);
10976
10977 tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR);
10978 tsLanguage.contains = tsLanguage.contains.concat([
10979 DECORATOR,
10980 NAMESPACE,
10981 INTERFACE,
10982 ]);
10983
10984 // TS gets a simpler shebang rule than JS
10985 swapMode(tsLanguage, "shebang", hljs.SHEBANG());
10986 // JS use strict rule purposely excludes `asm` which makes no sense
10987 swapMode(tsLanguage, "use_strict", USE_STRICT);
10988
10989 const functionDeclaration = tsLanguage.contains.find(m => m.className === "function");
10990 functionDeclaration.relevance = 0; // () => {} is more typical in TypeScript
10991
10992 Object.assign(tsLanguage, {
10993 name: 'TypeScript',
10994 aliases: ['ts']
10995 });
10996
10997 return tsLanguage;
10998 }
10999
11000 return typescript;
11001
11002 return module.exports.definer || module.exports;
11003
11004}());
11005
11006hljs.registerLanguage('vbnet', function () {
11007 'use strict';
11008
11009 /**
11010 * @param {string} value
11011 * @returns {RegExp}
11012 * */
11013
11014 /**
11015 * @param {RegExp | string } re
11016 * @returns {string}
11017 */
11018 function source(re) {
11019 if (!re) return null;
11020 if (typeof re === "string") return re;
11021
11022 return re.source;
11023 }
11024
11025 /**
11026 * @param {...(RegExp | string) } args
11027 * @returns {string}
11028 */
11029 function concat(...args) {
11030 const joined = args.map((x) => source(x)).join("");
11031 return joined;
11032 }
11033
11034 /**
11035 * Any of the passed expresssions may match
11036 *
11037 * Creates a huge this | this | that | that match
11038 * @param {(RegExp | string)[] } args
11039 * @returns {string}
11040 */
11041 function either(...args) {
11042 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
11043 return joined;
11044 }
11045
11046 /*
11047 Language: Visual Basic .NET
11048 Description: Visual Basic .NET (VB.NET) is a multi-paradigm, object-oriented programming language, implemented on the .NET Framework.
11049 Authors: Poren Chiang <ren.chiang@gmail.com>, Jan Pilzer
11050 Website: https://docs.microsoft.com/dotnet/visual-basic/getting-started
11051 Category: common
11052 */
11053
11054 /** @type LanguageFn */
11055 function vbnet(hljs) {
11056 /**
11057 * Character Literal
11058 * Either a single character ("a"C) or an escaped double quote (""""C).
11059 */
11060 const CHARACTER = {
11061 className: 'string',
11062 begin: /"(""|[^/n])"C\b/
11063 };
11064
11065 const STRING = {
11066 className: 'string',
11067 begin: /"/,
11068 end: /"/,
11069 illegal: /\n/,
11070 contains: [
11071 {
11072 // double quote escape
11073 begin: /""/
11074 }
11075 ]
11076 };
11077
11078 /** Date Literals consist of a date, a time, or both separated by whitespace, surrounded by # */
11079 const MM_DD_YYYY = /\d{1,2}\/\d{1,2}\/\d{4}/;
11080 const YYYY_MM_DD = /\d{4}-\d{1,2}-\d{1,2}/;
11081 const TIME_12H = /(\d|1[012])(:\d+){0,2} *(AM|PM)/;
11082 const TIME_24H = /\d{1,2}(:\d{1,2}){1,2}/;
11083 const DATE = {
11084 className: 'literal',
11085 variants: [
11086 {
11087 // #YYYY-MM-DD# (ISO-Date) or #M/D/YYYY# (US-Date)
11088 begin: concat(/# */, either(YYYY_MM_DD, MM_DD_YYYY), / *#/)
11089 },
11090 {
11091 // #H:mm[:ss]# (24h Time)
11092 begin: concat(/# */, TIME_24H, / *#/)
11093 },
11094 {
11095 // #h[:mm[:ss]] A# (12h Time)
11096 begin: concat(/# */, TIME_12H, / *#/)
11097 },
11098 {
11099 // date plus time
11100 begin: concat(
11101 /# */,
11102 either(YYYY_MM_DD, MM_DD_YYYY),
11103 / +/,
11104 either(TIME_12H, TIME_24H),
11105 / *#/
11106 )
11107 }
11108 ]
11109 };
11110
11111 const NUMBER = {
11112 className: 'number',
11113 relevance: 0,
11114 variants: [
11115 {
11116 // Float
11117 begin: /\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/
11118 },
11119 {
11120 // Integer (base 10)
11121 begin: /\b\d[\d_]*((U?[SIL])|[%&])?/
11122 },
11123 {
11124 // Integer (base 16)
11125 begin: /&H[\dA-F_]+((U?[SIL])|[%&])?/
11126 },
11127 {
11128 // Integer (base 8)
11129 begin: /&O[0-7_]+((U?[SIL])|[%&])?/
11130 },
11131 {
11132 // Integer (base 2)
11133 begin: /&B[01_]+((U?[SIL])|[%&])?/
11134 }
11135 ]
11136 };
11137
11138 const LABEL = {
11139 className: 'label',
11140 begin: /^\w+:/
11141 };
11142
11143 const DOC_COMMENT = hljs.COMMENT(/'''/, /$/, {
11144 contains: [
11145 {
11146 className: 'doctag',
11147 begin: /<\/?/,
11148 end: />/
11149 }
11150 ]
11151 });
11152
11153 const COMMENT = hljs.COMMENT(null, /$/, {
11154 variants: [
11155 {
11156 begin: /'/
11157 },
11158 {
11159 // TODO: Use `beforeMatch:` for leading spaces
11160 begin: /([\t ]|^)REM(?=\s)/
11161 }
11162 ]
11163 });
11164
11165 const DIRECTIVES = {
11166 className: 'meta',
11167 // TODO: Use `beforeMatch:` for indentation once available
11168 begin: /[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,
11169 end: /$/,
11170 keywords: {
11171 'meta-keyword':
11172 'const disable else elseif enable end externalsource if region then'
11173 },
11174 contains: [ COMMENT ]
11175 };
11176
11177 return {
11178 name: 'Visual Basic .NET',
11179 aliases: [ 'vb' ],
11180 case_insensitive: true,
11181 classNameAliases: {
11182 label: 'symbol'
11183 },
11184 keywords: {
11185 keyword:
11186 'addhandler alias aggregate ansi as async assembly auto binary by byref byval ' + /* a-b */
11187 'call case catch class compare const continue custom declare default delegate dim distinct do ' + /* c-d */
11188 'each equals else elseif end enum erase error event exit explicit finally for friend from function ' + /* e-f */
11189 'get global goto group handles if implements imports in inherits interface into iterator ' + /* g-i */
11190 'join key let lib loop me mid module mustinherit mustoverride mybase myclass ' + /* j-m */
11191 'namespace narrowing new next notinheritable notoverridable ' + /* n */
11192 'of off on operator option optional order overloads overridable overrides ' + /* o */
11193 'paramarray partial preserve private property protected public ' + /* p */
11194 'raiseevent readonly redim removehandler resume return ' + /* r */
11195 'select set shadows shared skip static step stop structure strict sub synclock ' + /* s */
11196 'take text then throw to try unicode until using when where while widening with withevents writeonly yield' /* t-y */,
11197 built_in:
11198 // Operators https://docs.microsoft.com/dotnet/visual-basic/language-reference/operators
11199 'addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor ' +
11200 // Type Conversion Functions https://docs.microsoft.com/dotnet/visual-basic/language-reference/functions/type-conversion-functions
11201 'cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort',
11202 type:
11203 // Data types https://docs.microsoft.com/dotnet/visual-basic/language-reference/data-types
11204 'boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort',
11205 literal: 'true false nothing'
11206 },
11207 illegal:
11208 '//|\\{|\\}|endif|gosub|variant|wend|^\\$ ' /* reserved deprecated keywords */,
11209 contains: [
11210 CHARACTER,
11211 STRING,
11212 DATE,
11213 NUMBER,
11214 LABEL,
11215 DOC_COMMENT,
11216 COMMENT,
11217 DIRECTIVES
11218 ]
11219 };
11220 }
11221
11222 return vbnet;
11223
11224 return module.exports.definer || module.exports;
11225
11226}());
11227
11228hljs.registerLanguage('yaml', function () {
11229 'use strict';
11230
11231 /*
11232 Language: YAML
11233 Description: Yet Another Markdown Language
11234 Author: Stefan Wienert <stwienert@gmail.com>
11235 Contributors: Carl Baxter <carl@cbax.tech>
11236 Requires: ruby.js
11237 Website: https://yaml.org
11238 Category: common, config
11239 */
11240 function yaml(hljs) {
11241 var LITERALS = 'true false yes no null';
11242
11243 // YAML spec allows non-reserved URI characters in tags.
11244 var URI_CHARACTERS = '[\\w#;/?:@&=+$,.~*\'()[\\]]+';
11245
11246 // Define keys as starting with a word character
11247 // ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
11248 // ...and ending with a colon followed immediately by a space, tab or newline.
11249 // The YAML spec allows for much more than this, but this covers most use-cases.
11250 var KEY = {
11251 className: 'attr',
11252 variants: [
11253 { begin: '\\w[\\w :\\/.-]*:(?=[ \t]|$)' },
11254 { begin: '"\\w[\\w :\\/.-]*":(?=[ \t]|$)' }, // double quoted keys
11255 { begin: '\'\\w[\\w :\\/.-]*\':(?=[ \t]|$)' } // single quoted keys
11256 ]
11257 };
11258
11259 var TEMPLATE_VARIABLES = {
11260 className: 'template-variable',
11261 variants: [
11262 { begin: /\{\{/, end: /\}\}/ }, // jinja templates Ansible
11263 { begin: /%\{/, end: /\}/ } // Ruby i18n
11264 ]
11265 };
11266 var STRING = {
11267 className: 'string',
11268 relevance: 0,
11269 variants: [
11270 { begin: /'/, end: /'/ },
11271 { begin: /"/, end: /"/ },
11272 { begin: /\S+/ }
11273 ],
11274 contains: [
11275 hljs.BACKSLASH_ESCAPE,
11276 TEMPLATE_VARIABLES
11277 ]
11278 };
11279
11280 // Strings inside of value containers (objects) can't contain braces,
11281 // brackets, or commas
11282 var CONTAINER_STRING = hljs.inherit(STRING, {
11283 variants: [
11284 { begin: /'/, end: /'/ },
11285 { begin: /"/, end: /"/ },
11286 { begin: /[^\s,{}[\]]+/ }
11287 ]
11288 });
11289
11290 var DATE_RE = '[0-9]{4}(-[0-9][0-9]){0,2}';
11291 var TIME_RE = '([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?';
11292 var FRACTION_RE = '(\\.[0-9]*)?';
11293 var ZONE_RE = '([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?';
11294 var TIMESTAMP = {
11295 className: 'number',
11296 begin: '\\b' + DATE_RE + TIME_RE + FRACTION_RE + ZONE_RE + '\\b'
11297 };
11298
11299 var VALUE_CONTAINER = {
11300 end: ',',
11301 endsWithParent: true,
11302 excludeEnd: true,
11303 contains: [],
11304 keywords: LITERALS,
11305 relevance: 0
11306 };
11307 var OBJECT = {
11308 begin: /\{/,
11309 end: /\}/,
11310 contains: [VALUE_CONTAINER],
11311 illegal: '\\n',
11312 relevance: 0
11313 };
11314 var ARRAY = {
11315 begin: '\\[',
11316 end: '\\]',
11317 contains: [VALUE_CONTAINER],
11318 illegal: '\\n',
11319 relevance: 0
11320 };
11321
11322 var MODES = [
11323 KEY,
11324 {
11325 className: 'meta',
11326 begin: '^---\\s*$',
11327 relevance: 10
11328 },
11329 { // multi line string
11330 // Blocks start with a | or > followed by a newline
11331 //
11332 // Indentation of subsequent lines must be the same to
11333 // be considered part of the block
11334 className: 'string',
11335 begin: '[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*'
11336 },
11337 { // Ruby/Rails erb
11338 begin: '<%[%=-]?',
11339 end: '[%-]?%>',
11340 subLanguage: 'ruby',
11341 excludeBegin: true,
11342 excludeEnd: true,
11343 relevance: 0
11344 },
11345 { // named tags
11346 className: 'type',
11347 begin: '!\\w+!' + URI_CHARACTERS
11348 },
11349 // https://yaml.org/spec/1.2/spec.html#id2784064
11350 { // verbatim tags
11351 className: 'type',
11352 begin: '!<' + URI_CHARACTERS + ">"
11353 },
11354 { // primary tags
11355 className: 'type',
11356 begin: '!' + URI_CHARACTERS
11357 },
11358 { // secondary tags
11359 className: 'type',
11360 begin: '!!' + URI_CHARACTERS
11361 },
11362 { // fragment id &ref
11363 className: 'meta',
11364 begin: '&' + hljs.UNDERSCORE_IDENT_RE + '$'
11365 },
11366 { // fragment reference *ref
11367 className: 'meta',
11368 begin: '\\*' + hljs.UNDERSCORE_IDENT_RE + '$'
11369 },
11370 { // array listing
11371 className: 'bullet',
11372 // TODO: remove |$ hack when we have proper look-ahead support
11373 begin: '-(?=[ ]|$)',
11374 relevance: 0
11375 },
11376 hljs.HASH_COMMENT_MODE,
11377 {
11378 beginKeywords: LITERALS,
11379 keywords: { literal: LITERALS }
11380 },
11381 TIMESTAMP,
11382 // numbers are any valid C-style number that
11383 // sit isolated from other words
11384 {
11385 className: 'number',
11386 begin: hljs.C_NUMBER_RE + '\\b',
11387 relevance: 0
11388 },
11389 OBJECT,
11390 ARRAY,
11391 STRING
11392 ];
11393
11394 var VALUE_MODES = [...MODES];
11395 VALUE_MODES.pop();
11396 VALUE_MODES.push(CONTAINER_STRING);
11397 VALUE_CONTAINER.contains = VALUE_MODES;
11398
11399 return {
11400 name: 'YAML',
11401 case_insensitive: true,
11402 aliases: ['yml', 'YAML'],
11403 contains: MODES
11404 };
11405 }
11406
11407 return yaml;
11408
11409 return module.exports.definer || module.exports;
11410
11411}());