UNPKG

286 kBJavaScriptView Raw
1/*
2 Highlight.js 10.4.1 (e96b915a)
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 /* Stream merging */
90
91 /**
92 * @typedef Event
93 * @property {'start'|'stop'} event
94 * @property {number} offset
95 * @property {Node} node
96 */
97
98 /**
99 * @param {Node} node
100 */
101 function tag(node) {
102 return node.nodeName.toLowerCase();
103 }
104
105 /**
106 * @param {Node} node
107 */
108 function nodeStream(node) {
109 /** @type Event[] */
110 const result = [];
111 (function _nodeStream(node, offset) {
112 for (let child = node.firstChild; child; child = child.nextSibling) {
113 if (child.nodeType === 3) {
114 offset += child.nodeValue.length;
115 } else if (child.nodeType === 1) {
116 result.push({
117 event: 'start',
118 offset: offset,
119 node: child
120 });
121 offset = _nodeStream(child, offset);
122 // Prevent void elements from having an end tag that would actually
123 // double them in the output. There are more void elements in HTML
124 // but we list only those realistically expected in code display.
125 if (!tag(child).match(/br|hr|img|input/)) {
126 result.push({
127 event: 'stop',
128 offset: offset,
129 node: child
130 });
131 }
132 }
133 }
134 return offset;
135 })(node, 0);
136 return result;
137 }
138
139 /**
140 * @param {any} original - the original stream
141 * @param {any} highlighted - stream of the highlighted source
142 * @param {string} value - the original source itself
143 */
144 function mergeStreams(original, highlighted, value) {
145 let processed = 0;
146 let result = '';
147 const nodeStack = [];
148
149 function selectStream() {
150 if (!original.length || !highlighted.length) {
151 return original.length ? original : highlighted;
152 }
153 if (original[0].offset !== highlighted[0].offset) {
154 return (original[0].offset < highlighted[0].offset) ? original : highlighted;
155 }
156
157 /*
158 To avoid starting the stream just before it should stop the order is
159 ensured that original always starts first and closes last:
160
161 if (event1 == 'start' && event2 == 'start')
162 return original;
163 if (event1 == 'start' && event2 == 'stop')
164 return highlighted;
165 if (event1 == 'stop' && event2 == 'start')
166 return original;
167 if (event1 == 'stop' && event2 == 'stop')
168 return highlighted;
169
170 ... which is collapsed to:
171 */
172 return highlighted[0].event === 'start' ? original : highlighted;
173 }
174
175 /**
176 * @param {Node} node
177 */
178 function open(node) {
179 /** @param {Attr} attr */
180 function attributeString(attr) {
181 return ' ' + attr.nodeName + '="' + escapeHTML(attr.value) + '"';
182 }
183 // @ts-ignore
184 result += '<' + tag(node) + [].map.call(node.attributes, attributeString).join('') + '>';
185 }
186
187 /**
188 * @param {Node} node
189 */
190 function close(node) {
191 result += '</' + tag(node) + '>';
192 }
193
194 /**
195 * @param {Event} event
196 */
197 function render(event) {
198 (event.event === 'start' ? open : close)(event.node);
199 }
200
201 while (original.length || highlighted.length) {
202 let stream = selectStream();
203 result += escapeHTML(value.substring(processed, stream[0].offset));
204 processed = stream[0].offset;
205 if (stream === original) {
206 /*
207 On any opening or closing tag of the original markup we first close
208 the entire highlighted node stack, then render the original tag along
209 with all the following original tags at the same offset and then
210 reopen all the tags on the highlighted stack.
211 */
212 nodeStack.reverse().forEach(close);
213 do {
214 render(stream.splice(0, 1)[0]);
215 stream = selectStream();
216 } while (stream === original && stream.length && stream[0].offset === processed);
217 nodeStack.reverse().forEach(open);
218 } else {
219 if (stream[0].event === 'start') {
220 nodeStack.push(stream[0].node);
221 } else {
222 nodeStack.pop();
223 }
224 render(stream.splice(0, 1)[0]);
225 }
226 }
227 return result + escapeHTML(value.substr(processed));
228 }
229
230 var utils = /*#__PURE__*/Object.freeze({
231 __proto__: null,
232 escapeHTML: escapeHTML,
233 inherit: inherit,
234 nodeStream: nodeStream,
235 mergeStreams: mergeStreams
236 });
237
238 /**
239 * @typedef {object} Renderer
240 * @property {(text: string) => void} addText
241 * @property {(node: Node) => void} openNode
242 * @property {(node: Node) => void} closeNode
243 * @property {() => string} value
244 */
245
246 /** @typedef {{kind?: string, sublanguage?: boolean}} Node */
247 /** @typedef {{walk: (r: Renderer) => void}} Tree */
248 /** */
249
250 const SPAN_CLOSE = '</span>';
251
252 /**
253 * Determines if a node needs to be wrapped in <span>
254 *
255 * @param {Node} node */
256 const emitsWrappingTags = (node) => {
257 return !!node.kind;
258 };
259
260 /** @type {Renderer} */
261 class HTMLRenderer {
262 /**
263 * Creates a new HTMLRenderer
264 *
265 * @param {Tree} parseTree - the parse tree (must support `walk` API)
266 * @param {{classPrefix: string}} options
267 */
268 constructor(parseTree, options) {
269 this.buffer = "";
270 this.classPrefix = options.classPrefix;
271 parseTree.walk(this);
272 }
273
274 /**
275 * Adds texts to the output stream
276 *
277 * @param {string} text */
278 addText(text) {
279 this.buffer += escapeHTML(text);
280 }
281
282 /**
283 * Adds a node open to the output stream (if needed)
284 *
285 * @param {Node} node */
286 openNode(node) {
287 if (!emitsWrappingTags(node)) return;
288
289 let className = node.kind;
290 if (!node.sublanguage) {
291 className = `${this.classPrefix}${className}`;
292 }
293 this.span(className);
294 }
295
296 /**
297 * Adds a node close to the output stream (if needed)
298 *
299 * @param {Node} node */
300 closeNode(node) {
301 if (!emitsWrappingTags(node)) return;
302
303 this.buffer += SPAN_CLOSE;
304 }
305
306 /**
307 * returns the accumulated buffer
308 */
309 value() {
310 return this.buffer;
311 }
312
313 // helpers
314
315 /**
316 * Builds a span element
317 *
318 * @param {string} className */
319 span(className) {
320 this.buffer += `<span class="${className}">`;
321 }
322 }
323
324 /** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} | string} Node */
325 /** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} } DataNode */
326 /** */
327
328 class TokenTree {
329 constructor() {
330 /** @type DataNode */
331 this.rootNode = { children: [] };
332 this.stack = [this.rootNode];
333 }
334
335 get top() {
336 return this.stack[this.stack.length - 1];
337 }
338
339 get root() { return this.rootNode; }
340
341 /** @param {Node} node */
342 add(node) {
343 this.top.children.push(node);
344 }
345
346 /** @param {string} kind */
347 openNode(kind) {
348 /** @type Node */
349 const node = { kind, children: [] };
350 this.add(node);
351 this.stack.push(node);
352 }
353
354 closeNode() {
355 if (this.stack.length > 1) {
356 return this.stack.pop();
357 }
358 // eslint-disable-next-line no-undefined
359 return undefined;
360 }
361
362 closeAllNodes() {
363 while (this.closeNode());
364 }
365
366 toJSON() {
367 return JSON.stringify(this.rootNode, null, 4);
368 }
369
370 /**
371 * @typedef { import("./html_renderer").Renderer } Renderer
372 * @param {Renderer} builder
373 */
374 walk(builder) {
375 // this does not
376 return this.constructor._walk(builder, this.rootNode);
377 // this works
378 // return TokenTree._walk(builder, this.rootNode);
379 }
380
381 /**
382 * @param {Renderer} builder
383 * @param {Node} node
384 */
385 static _walk(builder, node) {
386 if (typeof node === "string") {
387 builder.addText(node);
388 } else if (node.children) {
389 builder.openNode(node);
390 node.children.forEach((child) => this._walk(builder, child));
391 builder.closeNode(node);
392 }
393 return builder;
394 }
395
396 /**
397 * @param {Node} node
398 */
399 static _collapse(node) {
400 if (typeof node === "string") return;
401 if (!node.children) return;
402
403 if (node.children.every(el => typeof el === "string")) {
404 // node.text = node.children.join("");
405 // delete node.children;
406 node.children = [node.children.join("")];
407 } else {
408 node.children.forEach((child) => {
409 TokenTree._collapse(child);
410 });
411 }
412 }
413 }
414
415 /**
416 Currently this is all private API, but this is the minimal API necessary
417 that an Emitter must implement to fully support the parser.
418
419 Minimal interface:
420
421 - addKeyword(text, kind)
422 - addText(text)
423 - addSublanguage(emitter, subLanguageName)
424 - finalize()
425 - openNode(kind)
426 - closeNode()
427 - closeAllNodes()
428 - toHTML()
429
430 */
431
432 /**
433 * @implements {Emitter}
434 */
435 class TokenTreeEmitter extends TokenTree {
436 /**
437 * @param {*} options
438 */
439 constructor(options) {
440 super();
441 this.options = options;
442 }
443
444 /**
445 * @param {string} text
446 * @param {string} kind
447 */
448 addKeyword(text, kind) {
449 if (text === "") { return; }
450
451 this.openNode(kind);
452 this.addText(text);
453 this.closeNode();
454 }
455
456 /**
457 * @param {string} text
458 */
459 addText(text) {
460 if (text === "") { return; }
461
462 this.add(text);
463 }
464
465 /**
466 * @param {Emitter & {root: DataNode}} emitter
467 * @param {string} name
468 */
469 addSublanguage(emitter, name) {
470 /** @type DataNode */
471 const node = emitter.root;
472 node.kind = name;
473 node.sublanguage = true;
474 this.add(node);
475 }
476
477 toHTML() {
478 const renderer = new HTMLRenderer(this, this.options);
479 return renderer.value();
480 }
481
482 finalize() {
483 return true;
484 }
485 }
486
487 /**
488 * @param {string} value
489 * @returns {RegExp}
490 * */
491 function escape(value) {
492 return new RegExp(value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'm');
493 }
494
495 /**
496 * @param {RegExp | string } re
497 * @returns {string}
498 */
499 function source(re) {
500 if (!re) return null;
501 if (typeof re === "string") return re;
502
503 return re.source;
504 }
505
506 /**
507 * @param {...(RegExp | string) } args
508 * @returns {string}
509 */
510 function concat(...args) {
511 const joined = args.map((x) => source(x)).join("");
512 return joined;
513 }
514
515 /**
516 * @param {RegExp} re
517 * @returns {number}
518 */
519 function countMatchGroups(re) {
520 return (new RegExp(re.toString() + '|')).exec('').length - 1;
521 }
522
523 /**
524 * Does lexeme start with a regular expression match at the beginning
525 * @param {RegExp} re
526 * @param {string} lexeme
527 */
528 function startsWith(re, lexeme) {
529 const match = re && re.exec(lexeme);
530 return match && match.index === 0;
531 }
532
533 // join logically computes regexps.join(separator), but fixes the
534 // backreferences so they continue to match.
535 // it also places each individual regular expression into it's own
536 // match group, keeping track of the sequencing of those match groups
537 // is currently an exercise for the caller. :-)
538 /**
539 * @param {(string | RegExp)[]} regexps
540 * @param {string} separator
541 * @returns {string}
542 */
543 function join(regexps, separator = "|") {
544 // backreferenceRe matches an open parenthesis or backreference. To avoid
545 // an incorrect parse, it additionally matches the following:
546 // - [...] elements, where the meaning of parentheses and escapes change
547 // - other escape sequences, so we do not misparse escape sequences as
548 // interesting elements
549 // - non-matching or lookahead parentheses, which do not capture. These
550 // follow the '(' with a '?'.
551 const backreferenceRe = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
552 let numCaptures = 0;
553 let ret = '';
554 for (let i = 0; i < regexps.length; i++) {
555 numCaptures += 1;
556 const offset = numCaptures;
557 let re = source(regexps[i]);
558 if (i > 0) {
559 ret += separator;
560 }
561 ret += "(";
562 while (re.length > 0) {
563 const match = backreferenceRe.exec(re);
564 if (match == null) {
565 ret += re;
566 break;
567 }
568 ret += re.substring(0, match.index);
569 re = re.substring(match.index + match[0].length);
570 if (match[0][0] === '\\' && match[1]) {
571 // Adjust the backreference.
572 ret += '\\' + String(Number(match[1]) + offset);
573 } else {
574 ret += match[0];
575 if (match[0] === '(') {
576 numCaptures++;
577 }
578 }
579 }
580 ret += ")";
581 }
582 return ret;
583 }
584
585 // Common regexps
586 const IDENT_RE = '[a-zA-Z]\\w*';
587 const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
588 const NUMBER_RE = '\\b\\d+(\\.\\d+)?';
589 const C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
590 const BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
591 const RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
592
593 /**
594 * @param { Partial<Mode> & {binary?: string | RegExp} } opts
595 */
596 const SHEBANG = (opts = {}) => {
597 const beginShebang = /^#![ ]*\//;
598 if (opts.binary) {
599 opts.begin = concat(
600 beginShebang,
601 /.*\b/,
602 opts.binary,
603 /\b.*/);
604 }
605 return inherit({
606 className: 'meta',
607 begin: beginShebang,
608 end: /$/,
609 relevance: 0,
610 /** @type {ModeCallback} */
611 "on:begin": (m, resp) => {
612 if (m.index !== 0) resp.ignoreMatch();
613 }
614 }, opts);
615 };
616
617 // Common modes
618 const BACKSLASH_ESCAPE = {
619 begin: '\\\\[\\s\\S]', relevance: 0
620 };
621 const APOS_STRING_MODE = {
622 className: 'string',
623 begin: '\'',
624 end: '\'',
625 illegal: '\\n',
626 contains: [BACKSLASH_ESCAPE]
627 };
628 const QUOTE_STRING_MODE = {
629 className: 'string',
630 begin: '"',
631 end: '"',
632 illegal: '\\n',
633 contains: [BACKSLASH_ESCAPE]
634 };
635 const PHRASAL_WORDS_MODE = {
636 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/
637 };
638 /**
639 * Creates a comment mode
640 *
641 * @param {string | RegExp} begin
642 * @param {string | RegExp} end
643 * @param {Mode | {}} [modeOptions]
644 * @returns {Partial<Mode>}
645 */
646 const COMMENT = function(begin, end, modeOptions = {}) {
647 const mode = inherit(
648 {
649 className: 'comment',
650 begin,
651 end,
652 contains: []
653 },
654 modeOptions
655 );
656 mode.contains.push(PHRASAL_WORDS_MODE);
657 mode.contains.push({
658 className: 'doctag',
659 begin: '(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):',
660 relevance: 0
661 });
662 return mode;
663 };
664 const C_LINE_COMMENT_MODE = COMMENT('//', '$');
665 const C_BLOCK_COMMENT_MODE = COMMENT('/\\*', '\\*/');
666 const HASH_COMMENT_MODE = COMMENT('#', '$');
667 const NUMBER_MODE = {
668 className: 'number',
669 begin: NUMBER_RE,
670 relevance: 0
671 };
672 const C_NUMBER_MODE = {
673 className: 'number',
674 begin: C_NUMBER_RE,
675 relevance: 0
676 };
677 const BINARY_NUMBER_MODE = {
678 className: 'number',
679 begin: BINARY_NUMBER_RE,
680 relevance: 0
681 };
682 const CSS_NUMBER_MODE = {
683 className: 'number',
684 begin: NUMBER_RE + '(' +
685 '%|em|ex|ch|rem' +
686 '|vw|vh|vmin|vmax' +
687 '|cm|mm|in|pt|pc|px' +
688 '|deg|grad|rad|turn' +
689 '|s|ms' +
690 '|Hz|kHz' +
691 '|dpi|dpcm|dppx' +
692 ')?',
693 relevance: 0
694 };
695 const REGEXP_MODE = {
696 // this outer rule makes sure we actually have a WHOLE regex and not simply
697 // an expression such as:
698 //
699 // 3 / something
700 //
701 // (which will then blow up when regex's `illegal` sees the newline)
702 begin: /(?=\/[^/\n]*\/)/,
703 contains: [{
704 className: 'regexp',
705 begin: /\//,
706 end: /\/[gimuy]*/,
707 illegal: /\n/,
708 contains: [
709 BACKSLASH_ESCAPE,
710 {
711 begin: /\[/,
712 end: /\]/,
713 relevance: 0,
714 contains: [BACKSLASH_ESCAPE]
715 }
716 ]
717 }]
718 };
719 const TITLE_MODE = {
720 className: 'title',
721 begin: IDENT_RE,
722 relevance: 0
723 };
724 const UNDERSCORE_TITLE_MODE = {
725 className: 'title',
726 begin: UNDERSCORE_IDENT_RE,
727 relevance: 0
728 };
729 const METHOD_GUARD = {
730 // excludes method names from keyword processing
731 begin: '\\.\\s*' + UNDERSCORE_IDENT_RE,
732 relevance: 0
733 };
734
735 /**
736 * Adds end same as begin mechanics to a mode
737 *
738 * Your mode must include at least a single () match group as that first match
739 * group is what is used for comparison
740 * @param {Partial<Mode>} mode
741 */
742 const END_SAME_AS_BEGIN = function(mode) {
743 return Object.assign(mode,
744 {
745 /** @type {ModeCallback} */
746 'on:begin': (m, resp) => { resp.data._beginMatch = m[1]; },
747 /** @type {ModeCallback} */
748 'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); }
749 });
750 };
751
752 var MODES = /*#__PURE__*/Object.freeze({
753 __proto__: null,
754 IDENT_RE: IDENT_RE,
755 UNDERSCORE_IDENT_RE: UNDERSCORE_IDENT_RE,
756 NUMBER_RE: NUMBER_RE,
757 C_NUMBER_RE: C_NUMBER_RE,
758 BINARY_NUMBER_RE: BINARY_NUMBER_RE,
759 RE_STARTERS_RE: RE_STARTERS_RE,
760 SHEBANG: SHEBANG,
761 BACKSLASH_ESCAPE: BACKSLASH_ESCAPE,
762 APOS_STRING_MODE: APOS_STRING_MODE,
763 QUOTE_STRING_MODE: QUOTE_STRING_MODE,
764 PHRASAL_WORDS_MODE: PHRASAL_WORDS_MODE,
765 COMMENT: COMMENT,
766 C_LINE_COMMENT_MODE: C_LINE_COMMENT_MODE,
767 C_BLOCK_COMMENT_MODE: C_BLOCK_COMMENT_MODE,
768 HASH_COMMENT_MODE: HASH_COMMENT_MODE,
769 NUMBER_MODE: NUMBER_MODE,
770 C_NUMBER_MODE: C_NUMBER_MODE,
771 BINARY_NUMBER_MODE: BINARY_NUMBER_MODE,
772 CSS_NUMBER_MODE: CSS_NUMBER_MODE,
773 REGEXP_MODE: REGEXP_MODE,
774 TITLE_MODE: TITLE_MODE,
775 UNDERSCORE_TITLE_MODE: UNDERSCORE_TITLE_MODE,
776 METHOD_GUARD: METHOD_GUARD,
777 END_SAME_AS_BEGIN: END_SAME_AS_BEGIN
778 });
779
780 // keywords that should have no default relevance value
781 const COMMON_KEYWORDS = [
782 'of',
783 'and',
784 'for',
785 'in',
786 'not',
787 'or',
788 'if',
789 'then',
790 'parent', // common variable name
791 'list', // common variable name
792 'value' // common variable name
793 ];
794
795 // compilation
796
797 /**
798 * Compiles a language definition result
799 *
800 * Given the raw result of a language definition (Language), compiles this so
801 * that it is ready for highlighting code.
802 * @param {Language} language
803 * @returns {CompiledLanguage}
804 */
805 function compileLanguage(language) {
806 /**
807 * Builds a regex with the case sensativility of the current language
808 *
809 * @param {RegExp | string} value
810 * @param {boolean} [global]
811 */
812 function langRe(value, global) {
813 return new RegExp(
814 source(value),
815 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '')
816 );
817 }
818
819 /**
820 Stores multiple regular expressions and allows you to quickly search for
821 them all in a string simultaneously - returning the first match. It does
822 this by creating a huge (a|b|c) regex - each individual item wrapped with ()
823 and joined by `|` - using match groups to track position. When a match is
824 found checking which position in the array has content allows us to figure
825 out which of the original regexes / match groups triggered the match.
826
827 The match object itself (the result of `Regex.exec`) is returned but also
828 enhanced by merging in any meta-data that was registered with the regex.
829 This is how we keep track of which mode matched, and what type of rule
830 (`illegal`, `begin`, end, etc).
831 */
832 class MultiRegex {
833 constructor() {
834 this.matchIndexes = {};
835 // @ts-ignore
836 this.regexes = [];
837 this.matchAt = 1;
838 this.position = 0;
839 }
840
841 // @ts-ignore
842 addRule(re, opts) {
843 opts.position = this.position++;
844 // @ts-ignore
845 this.matchIndexes[this.matchAt] = opts;
846 this.regexes.push([opts, re]);
847 this.matchAt += countMatchGroups(re) + 1;
848 }
849
850 compile() {
851 if (this.regexes.length === 0) {
852 // avoids the need to check length every time exec is called
853 // @ts-ignore
854 this.exec = () => null;
855 }
856 const terminators = this.regexes.map(el => el[1]);
857 this.matcherRe = langRe(join(terminators), true);
858 this.lastIndex = 0;
859 }
860
861 /** @param {string} s */
862 exec(s) {
863 this.matcherRe.lastIndex = this.lastIndex;
864 const match = this.matcherRe.exec(s);
865 if (!match) { return null; }
866
867 // eslint-disable-next-line no-undefined
868 const i = match.findIndex((el, i) => i > 0 && el !== undefined);
869 // @ts-ignore
870 const matchData = this.matchIndexes[i];
871 // trim off any earlier non-relevant match groups (ie, the other regex
872 // match groups that make up the multi-matcher)
873 match.splice(0, i);
874
875 return Object.assign(match, matchData);
876 }
877 }
878
879 /*
880 Created to solve the key deficiently with MultiRegex - there is no way to
881 test for multiple matches at a single location. Why would we need to do
882 that? In the future a more dynamic engine will allow certain matches to be
883 ignored. An example: if we matched say the 3rd regex in a large group but
884 decided to ignore it - we'd need to started testing again at the 4th
885 regex... but MultiRegex itself gives us no real way to do that.
886
887 So what this class creates MultiRegexs on the fly for whatever search
888 position they are needed.
889
890 NOTE: These additional MultiRegex objects are created dynamically. For most
891 grammars most of the time we will never actually need anything more than the
892 first MultiRegex - so this shouldn't have too much overhead.
893
894 Say this is our search group, and we match regex3, but wish to ignore it.
895
896 regex1 | regex2 | regex3 | regex4 | regex5 ' ie, startAt = 0
897
898 What we need is a new MultiRegex that only includes the remaining
899 possibilities:
900
901 regex4 | regex5 ' ie, startAt = 3
902
903 This class wraps all that complexity up in a simple API... `startAt` decides
904 where in the array of expressions to start doing the matching. It
905 auto-increments, so if a match is found at position 2, then startAt will be
906 set to 3. If the end is reached startAt will return to 0.
907
908 MOST of the time the parser will be setting startAt manually to 0.
909 */
910 class ResumableMultiRegex {
911 constructor() {
912 // @ts-ignore
913 this.rules = [];
914 // @ts-ignore
915 this.multiRegexes = [];
916 this.count = 0;
917
918 this.lastIndex = 0;
919 this.regexIndex = 0;
920 }
921
922 // @ts-ignore
923 getMatcher(index) {
924 if (this.multiRegexes[index]) return this.multiRegexes[index];
925
926 const matcher = new MultiRegex();
927 this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
928 matcher.compile();
929 this.multiRegexes[index] = matcher;
930 return matcher;
931 }
932
933 resumingScanAtSamePosition() {
934 return this.regexIndex !== 0;
935 }
936
937 considerAll() {
938 this.regexIndex = 0;
939 }
940
941 // @ts-ignore
942 addRule(re, opts) {
943 this.rules.push([re, opts]);
944 if (opts.type === "begin") this.count++;
945 }
946
947 /** @param {string} s */
948 exec(s) {
949 const m = this.getMatcher(this.regexIndex);
950 m.lastIndex = this.lastIndex;
951 let result = m.exec(s);
952
953 // The following is because we have no easy way to say "resume scanning at the
954 // existing position but also skip the current rule ONLY". What happens is
955 // all prior rules are also skipped which can result in matching the wrong
956 // thing. Example of matching "booger":
957
958 // our matcher is [string, "booger", number]
959 //
960 // ....booger....
961
962 // if "booger" is ignored then we'd really need a regex to scan from the
963 // SAME position for only: [string, number] but ignoring "booger" (if it
964 // was the first match), a simple resume would scan ahead who knows how
965 // far looking only for "number", ignoring potential string matches (or
966 // future "booger" matches that might be valid.)
967
968 // So what we do: We execute two matchers, one resuming at the same
969 // position, but the second full matcher starting at the position after:
970
971 // /--- resume first regex match here (for [number])
972 // |/---- full match here for [string, "booger", number]
973 // vv
974 // ....booger....
975
976 // Which ever results in a match first is then used. So this 3-4 step
977 // process essentially allows us to say "match at this position, excluding
978 // a prior rule that was ignored".
979 //
980 // 1. Match "booger" first, ignore. Also proves that [string] does non match.
981 // 2. Resume matching for [number]
982 // 3. Match at index + 1 for [string, "booger", number]
983 // 4. If #2 and #3 result in matches, which came first?
984 if (this.resumingScanAtSamePosition()) {
985 if (result && result.index === this.lastIndex) ; else { // use the second matcher result
986 const m2 = this.getMatcher(0);
987 m2.lastIndex = this.lastIndex + 1;
988 result = m2.exec(s);
989 }
990 }
991
992 if (result) {
993 this.regexIndex += result.position + 1;
994 if (this.regexIndex === this.count) {
995 // wrap-around to considering all matches again
996 this.considerAll();
997 }
998 }
999
1000 return result;
1001 }
1002 }
1003
1004 /**
1005 * Given a mode, builds a huge ResumableMultiRegex that can be used to walk
1006 * the content and find matches.
1007 *
1008 * @param {CompiledMode} mode
1009 * @returns {ResumableMultiRegex}
1010 */
1011 function buildModeRegex(mode) {
1012 const mm = new ResumableMultiRegex();
1013
1014 mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type: "begin" }));
1015
1016 if (mode.terminator_end) {
1017 mm.addRule(mode.terminator_end, { type: "end" });
1018 }
1019 if (mode.illegal) {
1020 mm.addRule(mode.illegal, { type: "illegal" });
1021 }
1022
1023 return mm;
1024 }
1025
1026 // TODO: We need negative look-behind support to do this properly
1027 /**
1028 * Skip a match if it has a preceding dot
1029 *
1030 * This is used for `beginKeywords` to prevent matching expressions such as
1031 * `bob.keyword.do()`. The mode compiler automatically wires this up as a
1032 * special _internal_ 'on:begin' callback for modes with `beginKeywords`
1033 * @param {RegExpMatchArray} match
1034 * @param {CallbackResponse} response
1035 */
1036 function skipIfhasPrecedingDot(match, response) {
1037 const before = match.input[match.index - 1];
1038 if (before === ".") {
1039 response.ignoreMatch();
1040 }
1041 }
1042
1043 /** skip vs abort vs ignore
1044 *
1045 * @skip - The mode is still entered and exited normally (and contains rules apply),
1046 * but all content is held and added to the parent buffer rather than being
1047 * output when the mode ends. Mostly used with `sublanguage` to build up
1048 * a single large buffer than can be parsed by sublanguage.
1049 *
1050 * - The mode begin ands ends normally.
1051 * - Content matched is added to the parent mode buffer.
1052 * - The parser cursor is moved forward normally.
1053 *
1054 * @abort - A hack placeholder until we have ignore. Aborts the mode (as if it
1055 * never matched) but DOES NOT continue to match subsequent `contains`
1056 * modes. Abort is bad/suboptimal because it can result in modes
1057 * farther down not getting applied because an earlier rule eats the
1058 * content but then aborts.
1059 *
1060 * - The mode does not begin.
1061 * - Content matched by `begin` is added to the mode buffer.
1062 * - The parser cursor is moved forward accordingly.
1063 *
1064 * @ignore - Ignores the mode (as if it never matched) and continues to match any
1065 * subsequent `contains` modes. Ignore isn't technically possible with
1066 * the current parser implementation.
1067 *
1068 * - The mode does not begin.
1069 * - Content matched by `begin` is ignored.
1070 * - The parser cursor is not moved forward.
1071 */
1072
1073 /**
1074 * Compiles an individual mode
1075 *
1076 * This can raise an error if the mode contains certain detectable known logic
1077 * issues.
1078 * @param {Mode} mode
1079 * @param {CompiledMode | null} [parent]
1080 * @returns {CompiledMode | never}
1081 */
1082 function compileMode(mode, parent) {
1083 const cmode = /** @type CompiledMode */ (mode);
1084 if (mode.compiled) return cmode;
1085 mode.compiled = true;
1086
1087 // __beforeBegin is considered private API, internal use only
1088 mode.__beforeBegin = null;
1089
1090 mode.keywords = mode.keywords || mode.beginKeywords;
1091
1092 let keywordPattern = null;
1093 if (typeof mode.keywords === "object") {
1094 keywordPattern = mode.keywords.$pattern;
1095 delete mode.keywords.$pattern;
1096 }
1097
1098 if (mode.keywords) {
1099 mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
1100 }
1101
1102 // both are not allowed
1103 if (mode.lexemes && keywordPattern) {
1104 throw new Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ");
1105 }
1106
1107 // `mode.lexemes` was the old standard before we added and now recommend
1108 // using `keywords.$pattern` to pass the keyword pattern
1109 cmode.keywordPatternRe = langRe(mode.lexemes || keywordPattern || /\w+/, true);
1110
1111 if (parent) {
1112 if (mode.beginKeywords) {
1113 // for languages with keywords that include non-word characters checking for
1114 // a word boundary is not sufficient, so instead we check for a word boundary
1115 // or whitespace - this does no harm in any case since our keyword engine
1116 // doesn't allow spaces in keywords anyways and we still check for the boundary
1117 // first
1118 mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)';
1119 mode.__beforeBegin = skipIfhasPrecedingDot;
1120 }
1121 if (!mode.begin) mode.begin = /\B|\b/;
1122 cmode.beginRe = langRe(mode.begin);
1123 if (mode.endSameAsBegin) mode.end = mode.begin;
1124 if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
1125 if (mode.end) cmode.endRe = langRe(mode.end);
1126 cmode.terminator_end = source(mode.end) || '';
1127 if (mode.endsWithParent && parent.terminator_end) {
1128 cmode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end;
1129 }
1130 }
1131 if (mode.illegal) cmode.illegalRe = langRe(mode.illegal);
1132 // eslint-disable-next-line no-undefined
1133 if (mode.relevance === undefined) mode.relevance = 1;
1134 if (!mode.contains) mode.contains = [];
1135
1136 mode.contains = [].concat(...mode.contains.map(function(c) {
1137 return expandOrCloneMode(c === 'self' ? mode : c);
1138 }));
1139 mode.contains.forEach(function(c) { compileMode(/** @type Mode */ (c), cmode); });
1140
1141 if (mode.starts) {
1142 compileMode(mode.starts, parent);
1143 }
1144
1145 cmode.matcher = buildModeRegex(cmode);
1146 return cmode;
1147 }
1148
1149 // self is not valid at the top-level
1150 if (language.contains && language.contains.includes('self')) {
1151 throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
1152 }
1153
1154 // we need a null object, which inherit will guarantee
1155 language.classNameAliases = inherit(language.classNameAliases || {});
1156
1157 return compileMode(/** @type Mode */ (language));
1158 }
1159
1160 /**
1161 * Determines if a mode has a dependency on it's parent or not
1162 *
1163 * If a mode does have a parent dependency then often we need to clone it if
1164 * it's used in multiple places so that each copy points to the correct parent,
1165 * where-as modes without a parent can often safely be re-used at the bottom of
1166 * a mode chain.
1167 *
1168 * @param {Mode | null} mode
1169 * @returns {boolean} - is there a dependency on the parent?
1170 * */
1171 function dependencyOnParent(mode) {
1172 if (!mode) return false;
1173
1174 return mode.endsWithParent || dependencyOnParent(mode.starts);
1175 }
1176
1177 /**
1178 * Expands a mode or clones it if necessary
1179 *
1180 * This is necessary for modes with parental dependenceis (see notes on
1181 * `dependencyOnParent`) and for nodes that have `variants` - which must then be
1182 * exploded into their own individual modes at compile time.
1183 *
1184 * @param {Mode} mode
1185 * @returns {Mode | Mode[]}
1186 * */
1187 function expandOrCloneMode(mode) {
1188 if (mode.variants && !mode.cached_variants) {
1189 mode.cached_variants = mode.variants.map(function(variant) {
1190 return inherit(mode, { variants: null }, variant);
1191 });
1192 }
1193
1194 // EXPAND
1195 // if we have variants then essentially "replace" the mode with the variants
1196 // this happens in compileMode, where this function is called from
1197 if (mode.cached_variants) {
1198 return mode.cached_variants;
1199 }
1200
1201 // CLONE
1202 // if we have dependencies on parents then we need a unique
1203 // instance of ourselves, so we can be reused with many
1204 // different parents without issue
1205 if (dependencyOnParent(mode)) {
1206 return inherit(mode, { starts: mode.starts ? inherit(mode.starts) : null });
1207 }
1208
1209 if (Object.isFrozen(mode)) {
1210 return inherit(mode);
1211 }
1212
1213 // no special dependency issues, just return ourselves
1214 return mode;
1215 }
1216
1217 /***********************************************
1218 Keywords
1219 ***********************************************/
1220
1221 /**
1222 * Given raw keywords from a language definition, compile them.
1223 *
1224 * @param {string | Record<string,string>} rawKeywords
1225 * @param {boolean} caseInsensitive
1226 */
1227 function compileKeywords(rawKeywords, caseInsensitive) {
1228 /** @type KeywordDict */
1229 const compiledKeywords = {};
1230
1231 if (typeof rawKeywords === 'string') { // string
1232 splitAndCompile('keyword', rawKeywords);
1233 } else {
1234 Object.keys(rawKeywords).forEach(function(className) {
1235 splitAndCompile(className, rawKeywords[className]);
1236 });
1237 }
1238 return compiledKeywords;
1239
1240 // ---
1241
1242 /**
1243 * Compiles an individual list of keywords
1244 *
1245 * Ex: "for if when while|5"
1246 *
1247 * @param {string} className
1248 * @param {string} keywordList
1249 */
1250 function splitAndCompile(className, keywordList) {
1251 if (caseInsensitive) {
1252 keywordList = keywordList.toLowerCase();
1253 }
1254 keywordList.split(' ').forEach(function(keyword) {
1255 const pair = keyword.split('|');
1256 compiledKeywords[pair[0]] = [className, scoreForKeyword(pair[0], pair[1])];
1257 });
1258 }
1259 }
1260
1261 /**
1262 * Returns the proper score for a given keyword
1263 *
1264 * Also takes into account comment keywords, which will be scored 0 UNLESS
1265 * another score has been manually assigned.
1266 * @param {string} keyword
1267 * @param {string} [providedScore]
1268 */
1269 function scoreForKeyword(keyword, providedScore) {
1270 // manual scores always win over common keywords
1271 // so you can force a score of 1 if you really insist
1272 if (providedScore) {
1273 return Number(providedScore);
1274 }
1275
1276 return commonKeyword(keyword) ? 0 : 1;
1277 }
1278
1279 /**
1280 * Determines if a given keyword is common or not
1281 *
1282 * @param {string} keyword */
1283 function commonKeyword(keyword) {
1284 return COMMON_KEYWORDS.includes(keyword.toLowerCase());
1285 }
1286
1287 var version = "10.4.1";
1288
1289 // @ts-nocheck
1290
1291 function hasValueOrEmptyAttribute(value) {
1292 return Boolean(value || value === "");
1293 }
1294
1295 function BuildVuePlugin(hljs) {
1296 const Component = {
1297 props: ["language", "code", "autodetect"],
1298 data: function() {
1299 return {
1300 detectedLanguage: "",
1301 unknownLanguage: false
1302 };
1303 },
1304 computed: {
1305 className() {
1306 if (this.unknownLanguage) return "";
1307
1308 return "hljs " + this.detectedLanguage;
1309 },
1310 highlighted() {
1311 // no idea what language to use, return raw code
1312 if (!this.autoDetect && !hljs.getLanguage(this.language)) {
1313 console.warn(`The language "${this.language}" you specified could not be found.`);
1314 this.unknownLanguage = true;
1315 return escapeHTML(this.code);
1316 }
1317
1318 let result;
1319 if (this.autoDetect) {
1320 result = hljs.highlightAuto(this.code);
1321 this.detectedLanguage = result.language;
1322 } else {
1323 result = hljs.highlight(this.language, this.code, this.ignoreIllegals);
1324 this.detectedLanguage = this.language;
1325 }
1326 return result.value;
1327 },
1328 autoDetect() {
1329 return !this.language || hasValueOrEmptyAttribute(this.autodetect);
1330 },
1331 ignoreIllegals() {
1332 return true;
1333 }
1334 },
1335 // this avoids needing to use a whole Vue compilation pipeline just
1336 // to build Highlight.js
1337 render(createElement) {
1338 return createElement("pre", {}, [
1339 createElement("code", {
1340 class: this.className,
1341 domProps: { innerHTML: this.highlighted }})
1342 ]);
1343 }
1344 // template: `<pre><code :class="className" v-html="highlighted"></code></pre>`
1345 };
1346
1347 const VuePlugin = {
1348 install(Vue) {
1349 Vue.component('highlightjs', Component);
1350 }
1351 };
1352
1353 return { Component, VuePlugin };
1354 }
1355
1356 /*
1357 Syntax highlighting with language autodetection.
1358 https://highlightjs.org/
1359 */
1360
1361 const escape$1 = escapeHTML;
1362 const inherit$1 = inherit;
1363
1364 const { nodeStream: nodeStream$1, mergeStreams: mergeStreams$1 } = utils;
1365 const NO_MATCH = Symbol("nomatch");
1366
1367 /**
1368 * @param {any} hljs - object that is extended (legacy)
1369 * @returns {HLJSApi}
1370 */
1371 const HLJS = function(hljs) {
1372 // Convenience variables for build-in objects
1373 /** @type {unknown[]} */
1374 const ArrayProto = [];
1375
1376 // Global internal variables used within the highlight.js library.
1377 /** @type {Record<string, Language>} */
1378 const languages = Object.create(null);
1379 /** @type {Record<string, string>} */
1380 const aliases = Object.create(null);
1381 /** @type {HLJSPlugin[]} */
1382 const plugins = [];
1383
1384 // safe/production mode - swallows more errors, tries to keep running
1385 // even if a single syntax or parse hits a fatal error
1386 let SAFE_MODE = true;
1387 const fixMarkupRe = /(^(<[^>]+>|\t|)+|\n)/gm;
1388 const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
1389 /** @type {Language} */
1390 const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] };
1391
1392 // Global options used when within external APIs. This is modified when
1393 // calling the `hljs.configure` function.
1394 /** @type HLJSOptions */
1395 let options = {
1396 noHighlightRe: /^(no-?highlight)$/i,
1397 languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
1398 classPrefix: 'hljs-',
1399 tabReplace: null,
1400 useBR: false,
1401 languages: null,
1402 // beta configuration options, subject to change, welcome to discuss
1403 // https://github.com/highlightjs/highlight.js/issues/1086
1404 __emitter: TokenTreeEmitter
1405 };
1406
1407 /* Utility functions */
1408
1409 /**
1410 * Tests a language name to see if highlighting should be skipped
1411 * @param {string} languageName
1412 */
1413 function shouldNotHighlight(languageName) {
1414 return options.noHighlightRe.test(languageName);
1415 }
1416
1417 /**
1418 * @param {HighlightedHTMLElement} block - the HTML element to determine language for
1419 */
1420 function blockLanguage(block) {
1421 let classes = block.className + ' ';
1422
1423 classes += block.parentNode ? block.parentNode.className : '';
1424
1425 // language-* takes precedence over non-prefixed class names.
1426 const match = options.languageDetectRe.exec(classes);
1427 if (match) {
1428 const language = getLanguage(match[1]);
1429 if (!language) {
1430 console.warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
1431 console.warn("Falling back to no-highlight mode for this block.", block);
1432 }
1433 return language ? match[1] : 'no-highlight';
1434 }
1435
1436 return classes
1437 .split(/\s+/)
1438 .find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
1439 }
1440
1441 /**
1442 * Core highlighting function.
1443 *
1444 * @param {string} languageName - the language to use for highlighting
1445 * @param {string} code - the code to highlight
1446 * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1447 * @param {CompiledMode} [continuation] - current continuation mode, if any
1448 *
1449 * @returns {HighlightResult} Result - an object that represents the result
1450 * @property {string} language - the language name
1451 * @property {number} relevance - the relevance score
1452 * @property {string} value - the highlighted HTML code
1453 * @property {string} code - the original raw code
1454 * @property {CompiledMode} top - top of the current mode stack
1455 * @property {boolean} illegal - indicates whether any illegal matches were found
1456 */
1457 function highlight(languageName, code, ignoreIllegals, continuation) {
1458 /** @type {{ code: string, language: string, result?: any }} */
1459 const context = {
1460 code,
1461 language: languageName
1462 };
1463 // the plugin can change the desired language or the code to be highlighted
1464 // just be changing the object it was passed
1465 fire("before:highlight", context);
1466
1467 // a before plugin can usurp the result completely by providing it's own
1468 // in which case we don't even need to call highlight
1469 const result = context.result ?
1470 context.result :
1471 _highlight(context.language, context.code, ignoreIllegals, continuation);
1472
1473 result.code = context.code;
1474 // the plugin can change anything in result to suite it
1475 fire("after:highlight", result);
1476
1477 return result;
1478 }
1479
1480 /**
1481 * private highlight that's used internally and does not fire callbacks
1482 *
1483 * @param {string} languageName - the language to use for highlighting
1484 * @param {string} code - the code to highlight
1485 * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1486 * @param {CompiledMode} [continuation] - current continuation mode, if any
1487 * @returns {HighlightResult} - result of the highlight operation
1488 */
1489 function _highlight(languageName, code, ignoreIllegals, continuation) {
1490 const codeToHighlight = code;
1491
1492 /**
1493 * Return keyword data if a match is a keyword
1494 * @param {CompiledMode} mode - current mode
1495 * @param {RegExpMatchArray} match - regexp match data
1496 * @returns {KeywordData | false}
1497 */
1498 function keywordData(mode, match) {
1499 const matchText = language.case_insensitive ? match[0].toLowerCase() : match[0];
1500 return Object.prototype.hasOwnProperty.call(mode.keywords, matchText) && mode.keywords[matchText];
1501 }
1502
1503 function processKeywords() {
1504 if (!top.keywords) {
1505 emitter.addText(modeBuffer);
1506 return;
1507 }
1508
1509 let lastIndex = 0;
1510 top.keywordPatternRe.lastIndex = 0;
1511 let match = top.keywordPatternRe.exec(modeBuffer);
1512 let buf = "";
1513
1514 while (match) {
1515 buf += modeBuffer.substring(lastIndex, match.index);
1516 const data = keywordData(top, match);
1517 if (data) {
1518 const [kind, keywordRelevance] = data;
1519 emitter.addText(buf);
1520 buf = "";
1521
1522 relevance += keywordRelevance;
1523 const cssClass = language.classNameAliases[kind] || kind;
1524 emitter.addKeyword(match[0], cssClass);
1525 } else {
1526 buf += match[0];
1527 }
1528 lastIndex = top.keywordPatternRe.lastIndex;
1529 match = top.keywordPatternRe.exec(modeBuffer);
1530 }
1531 buf += modeBuffer.substr(lastIndex);
1532 emitter.addText(buf);
1533 }
1534
1535 function processSubLanguage() {
1536 if (modeBuffer === "") return;
1537 /** @type HighlightResult */
1538 let result = null;
1539
1540 if (typeof top.subLanguage === 'string') {
1541 if (!languages[top.subLanguage]) {
1542 emitter.addText(modeBuffer);
1543 return;
1544 }
1545 result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1546 continuations[top.subLanguage] = /** @type {CompiledMode} */ (result.top);
1547 } else {
1548 result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1549 }
1550
1551 // Counting embedded language score towards the host language may be disabled
1552 // with zeroing the containing mode relevance. Use case in point is Markdown that
1553 // allows XML everywhere and makes every XML snippet to have a much larger Markdown
1554 // score.
1555 if (top.relevance > 0) {
1556 relevance += result.relevance;
1557 }
1558 emitter.addSublanguage(result.emitter, result.language);
1559 }
1560
1561 function processBuffer() {
1562 if (top.subLanguage != null) {
1563 processSubLanguage();
1564 } else {
1565 processKeywords();
1566 }
1567 modeBuffer = '';
1568 }
1569
1570 /**
1571 * @param {Mode} mode - new mode to start
1572 */
1573 function startNewMode(mode) {
1574 if (mode.className) {
1575 emitter.openNode(language.classNameAliases[mode.className] || mode.className);
1576 }
1577 top = Object.create(mode, { parent: { value: top } });
1578 return top;
1579 }
1580
1581 /**
1582 * @param {CompiledMode } mode - the mode to potentially end
1583 * @param {RegExpMatchArray} match - the latest match
1584 * @param {string} matchPlusRemainder - match plus remainder of content
1585 * @returns {CompiledMode | void} - the next mode, or if void continue on in current mode
1586 */
1587 function endOfMode(mode, match, matchPlusRemainder) {
1588 let matched = startsWith(mode.endRe, matchPlusRemainder);
1589
1590 if (matched) {
1591 if (mode["on:end"]) {
1592 const resp = new Response(mode);
1593 mode["on:end"](match, resp);
1594 if (resp.ignore) matched = false;
1595 }
1596
1597 if (matched) {
1598 while (mode.endsParent && mode.parent) {
1599 mode = mode.parent;
1600 }
1601 return mode;
1602 }
1603 }
1604 // even if on:end fires an `ignore` it's still possible
1605 // that we might trigger the end node because of a parent mode
1606 if (mode.endsWithParent) {
1607 return endOfMode(mode.parent, match, matchPlusRemainder);
1608 }
1609 }
1610
1611 /**
1612 * Handle matching but then ignoring a sequence of text
1613 *
1614 * @param {string} lexeme - string containing full match text
1615 */
1616 function doIgnore(lexeme) {
1617 if (top.matcher.regexIndex === 0) {
1618 // no more regexs to potentially match here, so we move the cursor forward one
1619 // space
1620 modeBuffer += lexeme[0];
1621 return 1;
1622 } else {
1623 // no need to move the cursor, we still have additional regexes to try and
1624 // match at this very spot
1625 resumeScanAtSamePosition = true;
1626 return 0;
1627 }
1628 }
1629
1630 /**
1631 * Handle the start of a new potential mode match
1632 *
1633 * @param {EnhancedMatch} match - the current match
1634 * @returns {number} how far to advance the parse cursor
1635 */
1636 function doBeginMatch(match) {
1637 const lexeme = match[0];
1638 const newMode = match.rule;
1639
1640 const resp = new Response(newMode);
1641 // first internal before callbacks, then the public ones
1642 const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1643 for (const cb of beforeCallbacks) {
1644 if (!cb) continue;
1645 cb(match, resp);
1646 if (resp.ignore) return doIgnore(lexeme);
1647 }
1648
1649 if (newMode && newMode.endSameAsBegin) {
1650 newMode.endRe = escape(lexeme);
1651 }
1652
1653 if (newMode.skip) {
1654 modeBuffer += lexeme;
1655 } else {
1656 if (newMode.excludeBegin) {
1657 modeBuffer += lexeme;
1658 }
1659 processBuffer();
1660 if (!newMode.returnBegin && !newMode.excludeBegin) {
1661 modeBuffer = lexeme;
1662 }
1663 }
1664 startNewMode(newMode);
1665 // if (mode["after:begin"]) {
1666 // let resp = new Response(mode);
1667 // mode["after:begin"](match, resp);
1668 // }
1669 return newMode.returnBegin ? 0 : lexeme.length;
1670 }
1671
1672 /**
1673 * Handle the potential end of mode
1674 *
1675 * @param {RegExpMatchArray} match - the current match
1676 */
1677 function doEndMatch(match) {
1678 const lexeme = match[0];
1679 const matchPlusRemainder = codeToHighlight.substr(match.index);
1680
1681 const endMode = endOfMode(top, match, matchPlusRemainder);
1682 if (!endMode) { return NO_MATCH; }
1683
1684 const origin = top;
1685 if (origin.skip) {
1686 modeBuffer += lexeme;
1687 } else {
1688 if (!(origin.returnEnd || origin.excludeEnd)) {
1689 modeBuffer += lexeme;
1690 }
1691 processBuffer();
1692 if (origin.excludeEnd) {
1693 modeBuffer = lexeme;
1694 }
1695 }
1696 do {
1697 if (top.className) {
1698 emitter.closeNode();
1699 }
1700 if (!top.skip && !top.subLanguage) {
1701 relevance += top.relevance;
1702 }
1703 top = top.parent;
1704 } while (top !== endMode.parent);
1705 if (endMode.starts) {
1706 if (endMode.endSameAsBegin) {
1707 endMode.starts.endRe = endMode.endRe;
1708 }
1709 startNewMode(endMode.starts);
1710 }
1711 return origin.returnEnd ? 0 : lexeme.length;
1712 }
1713
1714 function processContinuations() {
1715 const list = [];
1716 for (let current = top; current !== language; current = current.parent) {
1717 if (current.className) {
1718 list.unshift(current.className);
1719 }
1720 }
1721 list.forEach(item => emitter.openNode(item));
1722 }
1723
1724 /** @type {{type?: MatchType, index?: number, rule?: Mode}}} */
1725 let lastMatch = {};
1726
1727 /**
1728 * Process an individual match
1729 *
1730 * @param {string} textBeforeMatch - text preceeding the match (since the last match)
1731 * @param {EnhancedMatch} [match] - the match itself
1732 */
1733 function processLexeme(textBeforeMatch, match) {
1734 const lexeme = match && match[0];
1735
1736 // add non-matched text to the current mode buffer
1737 modeBuffer += textBeforeMatch;
1738
1739 if (lexeme == null) {
1740 processBuffer();
1741 return 0;
1742 }
1743
1744 // we've found a 0 width match and we're stuck, so we need to advance
1745 // this happens when we have badly behaved rules that have optional matchers to the degree that
1746 // sometimes they can end up matching nothing at all
1747 // Ref: https://github.com/highlightjs/highlight.js/issues/2140
1748 if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1749 // spit the "skipped" character that our regex choked on back into the output sequence
1750 modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1751 if (!SAFE_MODE) {
1752 /** @type {AnnotatedError} */
1753 const err = new Error('0 width match regex');
1754 err.languageName = languageName;
1755 err.badRule = lastMatch.rule;
1756 throw err;
1757 }
1758 return 1;
1759 }
1760 lastMatch = match;
1761
1762 if (match.type === "begin") {
1763 return doBeginMatch(match);
1764 } else if (match.type === "illegal" && !ignoreIllegals) {
1765 // illegal match, we do not continue processing
1766 /** @type {AnnotatedError} */
1767 const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
1768 err.mode = top;
1769 throw err;
1770 } else if (match.type === "end") {
1771 const processed = doEndMatch(match);
1772 if (processed !== NO_MATCH) {
1773 return processed;
1774 }
1775 }
1776
1777 // edge case for when illegal matches $ (end of line) which is technically
1778 // a 0 width match but not a begin/end match so it's not caught by the
1779 // first handler (when ignoreIllegals is true)
1780 if (match.type === "illegal" && lexeme === "") {
1781 // advance so we aren't stuck in an infinite loop
1782 return 1;
1783 }
1784
1785 // infinite loops are BAD, this is a last ditch catch all. if we have a
1786 // decent number of iterations yet our index (cursor position in our
1787 // parsing) still 3x behind our index then something is very wrong
1788 // so we bail
1789 if (iterations > 100000 && iterations > match.index * 3) {
1790 const err = new Error('potential infinite loop, way more iterations than matches');
1791 throw err;
1792 }
1793
1794 /*
1795 Why might be find ourselves here? Only one occasion now. An end match that was
1796 triggered but could not be completed. When might this happen? When an `endSameasBegin`
1797 rule sets the end rule to a specific match. Since the overall mode termination rule that's
1798 being used to scan the text isn't recompiled that means that any match that LOOKS like
1799 the end (but is not, because it is not an exact match to the beginning) will
1800 end up here. A definite end match, but when `doEndMatch` tries to "reapply"
1801 the end rule and fails to match, we wind up here, and just silently ignore the end.
1802
1803 This causes no real harm other than stopping a few times too many.
1804 */
1805
1806 modeBuffer += lexeme;
1807 return lexeme.length;
1808 }
1809
1810 const language = getLanguage(languageName);
1811 if (!language) {
1812 console.error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1813 throw new Error('Unknown language: "' + languageName + '"');
1814 }
1815
1816 const md = compileLanguage(language);
1817 let result = '';
1818 /** @type {CompiledMode} */
1819 let top = continuation || md;
1820 /** @type Record<string,CompiledMode> */
1821 const continuations = {}; // keep continuations for sub-languages
1822 const emitter = new options.__emitter(options);
1823 processContinuations();
1824 let modeBuffer = '';
1825 let relevance = 0;
1826 let index = 0;
1827 let iterations = 0;
1828 let resumeScanAtSamePosition = false;
1829
1830 try {
1831 top.matcher.considerAll();
1832
1833 for (;;) {
1834 iterations++;
1835 if (resumeScanAtSamePosition) {
1836 // only regexes not matched previously will now be
1837 // considered for a potential match
1838 resumeScanAtSamePosition = false;
1839 } else {
1840 top.matcher.considerAll();
1841 }
1842 top.matcher.lastIndex = index;
1843
1844 const match = top.matcher.exec(codeToHighlight);
1845 // console.log("match", match[0], match.rule && match.rule.begin)
1846
1847 if (!match) break;
1848
1849 const beforeMatch = codeToHighlight.substring(index, match.index);
1850 const processedCount = processLexeme(beforeMatch, match);
1851 index = match.index + processedCount;
1852 }
1853 processLexeme(codeToHighlight.substr(index));
1854 emitter.closeAllNodes();
1855 emitter.finalize();
1856 result = emitter.toHTML();
1857
1858 return {
1859 relevance: relevance,
1860 value: result,
1861 language: languageName,
1862 illegal: false,
1863 emitter: emitter,
1864 top: top
1865 };
1866 } catch (err) {
1867 if (err.message && err.message.includes('Illegal')) {
1868 return {
1869 illegal: true,
1870 illegalBy: {
1871 msg: err.message,
1872 context: codeToHighlight.slice(index - 100, index + 100),
1873 mode: err.mode
1874 },
1875 sofar: result,
1876 relevance: 0,
1877 value: escape$1(codeToHighlight),
1878 emitter: emitter
1879 };
1880 } else if (SAFE_MODE) {
1881 return {
1882 illegal: false,
1883 relevance: 0,
1884 value: escape$1(codeToHighlight),
1885 emitter: emitter,
1886 language: languageName,
1887 top: top,
1888 errorRaised: err
1889 };
1890 } else {
1891 throw err;
1892 }
1893 }
1894 }
1895
1896 /**
1897 * returns a valid highlight result, without actually doing any actual work,
1898 * auto highlight starts with this and it's possible for small snippets that
1899 * auto-detection may not find a better match
1900 * @param {string} code
1901 * @returns {HighlightResult}
1902 */
1903 function justTextHighlightResult(code) {
1904 const result = {
1905 relevance: 0,
1906 emitter: new options.__emitter(options),
1907 value: escape$1(code),
1908 illegal: false,
1909 top: PLAINTEXT_LANGUAGE
1910 };
1911 result.emitter.addText(code);
1912 return result;
1913 }
1914
1915 /**
1916 Highlighting with language detection. Accepts a string with the code to
1917 highlight. Returns an object with the following properties:
1918
1919 - language (detected language)
1920 - relevance (int)
1921 - value (an HTML string with highlighting markup)
1922 - second_best (object with the same structure for second-best heuristically
1923 detected language, may be absent)
1924
1925 @param {string} code
1926 @param {Array<string>} [languageSubset]
1927 @returns {AutoHighlightResult}
1928 */
1929 function highlightAuto(code, languageSubset) {
1930 languageSubset = languageSubset || options.languages || Object.keys(languages);
1931 const plaintext = justTextHighlightResult(code);
1932
1933 const results = languageSubset.filter(getLanguage).filter(autoDetection).map(name =>
1934 _highlight(name, code, false)
1935 );
1936 results.unshift(plaintext); // plaintext is always an option
1937
1938 const sorted = results.sort((a, b) => {
1939 // sort base on relevance
1940 if (a.relevance !== b.relevance) return b.relevance - a.relevance;
1941
1942 // always award the tie to the base language
1943 // ie if C++ and Arduino are tied, it's more likely to be C++
1944 if (a.language && b.language) {
1945 if (getLanguage(a.language).supersetOf === b.language) {
1946 return 1;
1947 } else if (getLanguage(b.language).supersetOf === a.language) {
1948 return -1;
1949 }
1950 }
1951
1952 // otherwise say they are equal, which has the effect of sorting on
1953 // relevance while preserving the original ordering - which is how ties
1954 // have historically been settled, ie the language that comes first always
1955 // wins in the case of a tie
1956 return 0;
1957 });
1958
1959 const [best, secondBest] = sorted;
1960
1961 /** @type {AutoHighlightResult} */
1962 const result = best;
1963 result.second_best = secondBest;
1964
1965 return result;
1966 }
1967
1968 /**
1969 Post-processing of the highlighted markup:
1970
1971 - replace TABs with something more useful
1972 - replace real line-breaks with '<br>' for non-pre containers
1973
1974 @param {string} html
1975 @returns {string}
1976 */
1977 function fixMarkup(html) {
1978 if (!(options.tabReplace || options.useBR)) {
1979 return html;
1980 }
1981
1982 return html.replace(fixMarkupRe, match => {
1983 if (match === '\n') {
1984 return options.useBR ? '<br>' : match;
1985 } else if (options.tabReplace) {
1986 return match.replace(/\t/g, options.tabReplace);
1987 }
1988 return match;
1989 });
1990 }
1991
1992 /**
1993 * Builds new class name for block given the language name
1994 *
1995 * @param {string} prevClassName
1996 * @param {string} [currentLang]
1997 * @param {string} [resultLang]
1998 */
1999 function buildClassName(prevClassName, currentLang, resultLang) {
2000 const language = currentLang ? aliases[currentLang] : resultLang;
2001 const result = [prevClassName.trim()];
2002
2003 if (!prevClassName.match(/\bhljs\b/)) {
2004 result.push('hljs');
2005 }
2006
2007 if (!prevClassName.includes(language)) {
2008 result.push(language);
2009 }
2010
2011 return result.join(' ').trim();
2012 }
2013
2014 /**
2015 * Applies highlighting to a DOM node containing code. Accepts a DOM node and
2016 * two optional parameters for fixMarkup.
2017 *
2018 * @param {HighlightedHTMLElement} element - the HTML element to highlight
2019 */
2020 function highlightBlock(element) {
2021 /** @type HTMLElement */
2022 let node = null;
2023 const language = blockLanguage(element);
2024
2025 if (shouldNotHighlight(language)) return;
2026
2027 fire("before:highlightBlock",
2028 { block: element, language: language });
2029
2030 if (options.useBR) {
2031 node = document.createElement('div');
2032 node.innerHTML = element.innerHTML.replace(/\n/g, '').replace(/<br[ /]*>/g, '\n');
2033 } else {
2034 node = element;
2035 }
2036 const text = node.textContent;
2037 const result = language ? highlight(language, text, true) : highlightAuto(text);
2038
2039 const originalStream = nodeStream$1(node);
2040 if (originalStream.length) {
2041 const resultNode = document.createElement('div');
2042 resultNode.innerHTML = result.value;
2043 result.value = mergeStreams$1(originalStream, nodeStream$1(resultNode), text);
2044 }
2045 result.value = fixMarkup(result.value);
2046
2047 fire("after:highlightBlock", { block: element, result: result });
2048
2049 element.innerHTML = result.value;
2050 element.className = buildClassName(element.className, language, result.language);
2051 element.result = {
2052 language: result.language,
2053 // TODO: remove with version 11.0
2054 re: result.relevance,
2055 relavance: result.relevance
2056 };
2057 if (result.second_best) {
2058 element.second_best = {
2059 language: result.second_best.language,
2060 // TODO: remove with version 11.0
2061 re: result.second_best.relevance,
2062 relavance: result.second_best.relevance
2063 };
2064 }
2065 }
2066
2067 /**
2068 * Updates highlight.js global options with the passed options
2069 *
2070 * @param {Partial<HLJSOptions>} userOptions
2071 */
2072 function configure(userOptions) {
2073 if (userOptions.useBR) {
2074 console.warn("'useBR' option is deprecated and will be removed entirely in v11.0");
2075 console.warn("Please see https://github.com/highlightjs/highlight.js/issues/2559");
2076 }
2077 options = inherit$1(options, userOptions);
2078 }
2079
2080 /**
2081 * Highlights to all <pre><code> blocks on a page
2082 *
2083 * @type {Function & {called?: boolean}}
2084 */
2085 const initHighlighting = () => {
2086 if (initHighlighting.called) return;
2087 initHighlighting.called = true;
2088
2089 const blocks = document.querySelectorAll('pre code');
2090 ArrayProto.forEach.call(blocks, highlightBlock);
2091 };
2092
2093 // Higlights all when DOMContentLoaded fires
2094 function initHighlightingOnLoad() {
2095 // @ts-ignore
2096 window.addEventListener('DOMContentLoaded', initHighlighting, false);
2097 }
2098
2099 /**
2100 * Register a language grammar module
2101 *
2102 * @param {string} languageName
2103 * @param {LanguageFn} languageDefinition
2104 */
2105 function registerLanguage(languageName, languageDefinition) {
2106 let lang = null;
2107 try {
2108 lang = languageDefinition(hljs);
2109 } catch (error) {
2110 console.error("Language definition for '{}' could not be registered.".replace("{}", languageName));
2111 // hard or soft error
2112 if (!SAFE_MODE) { throw error; } else { console.error(error); }
2113 // languages that have serious errors are replaced with essentially a
2114 // "plaintext" stand-in so that the code blocks will still get normal
2115 // css classes applied to them - and one bad language won't break the
2116 // entire highlighter
2117 lang = PLAINTEXT_LANGUAGE;
2118 }
2119 // give it a temporary name if it doesn't have one in the meta-data
2120 if (!lang.name) lang.name = languageName;
2121 languages[languageName] = lang;
2122 lang.rawDefinition = languageDefinition.bind(null, hljs);
2123
2124 if (lang.aliases) {
2125 registerAliases(lang.aliases, { languageName });
2126 }
2127 }
2128
2129 /**
2130 * @returns {string[]} List of language internal names
2131 */
2132 function listLanguages() {
2133 return Object.keys(languages);
2134 }
2135
2136 /**
2137 intended usage: When one language truly requires another
2138
2139 Unlike `getLanguage`, this will throw when the requested language
2140 is not available.
2141
2142 @param {string} name - name of the language to fetch/require
2143 @returns {Language | never}
2144 */
2145 function requireLanguage(name) {
2146 console.warn("requireLanguage is deprecated and will be removed entirely in the future.");
2147 console.warn("Please see https://github.com/highlightjs/highlight.js/pull/2844");
2148
2149 const lang = getLanguage(name);
2150 if (lang) { return lang; }
2151
2152 const err = new Error('The \'{}\' language is required, but not loaded.'.replace('{}', name));
2153 throw err;
2154 }
2155
2156 /**
2157 * @param {string} name - name of the language to retrieve
2158 * @returns {Language | undefined}
2159 */
2160 function getLanguage(name) {
2161 name = (name || '').toLowerCase();
2162 return languages[name] || languages[aliases[name]];
2163 }
2164
2165 /**
2166 *
2167 * @param {string|string[]} aliasList - single alias or list of aliases
2168 * @param {{languageName: string}} opts
2169 */
2170 function registerAliases(aliasList, { languageName }) {
2171 if (typeof aliasList === 'string') {
2172 aliasList = [aliasList];
2173 }
2174 aliasList.forEach(alias => { aliases[alias] = languageName; });
2175 }
2176
2177 /**
2178 * Determines if a given language has auto-detection enabled
2179 * @param {string} name - name of the language
2180 */
2181 function autoDetection(name) {
2182 const lang = getLanguage(name);
2183 return lang && !lang.disableAutodetect;
2184 }
2185
2186 /**
2187 * @param {HLJSPlugin} plugin
2188 */
2189 function addPlugin(plugin) {
2190 plugins.push(plugin);
2191 }
2192
2193 /**
2194 *
2195 * @param {PluginEvent} event
2196 * @param {any} args
2197 */
2198 function fire(event, args) {
2199 const cb = event;
2200 plugins.forEach(function(plugin) {
2201 if (plugin[cb]) {
2202 plugin[cb](args);
2203 }
2204 });
2205 }
2206
2207 /**
2208 Note: fixMarkup is deprecated and will be removed entirely in v11
2209
2210 @param {string} arg
2211 @returns {string}
2212 */
2213 function deprecateFixMarkup(arg) {
2214 console.warn("fixMarkup is deprecated and will be removed entirely in v11.0");
2215 console.warn("Please see https://github.com/highlightjs/highlight.js/issues/2534");
2216
2217 return fixMarkup(arg);
2218 }
2219
2220 /* Interface definition */
2221 Object.assign(hljs, {
2222 highlight,
2223 highlightAuto,
2224 fixMarkup: deprecateFixMarkup,
2225 highlightBlock,
2226 configure,
2227 initHighlighting,
2228 initHighlightingOnLoad,
2229 registerLanguage,
2230 listLanguages,
2231 getLanguage,
2232 registerAliases,
2233 requireLanguage,
2234 autoDetection,
2235 inherit: inherit$1,
2236 addPlugin,
2237 // plugins for frameworks
2238 vuePlugin: BuildVuePlugin(hljs).VuePlugin
2239 });
2240
2241 hljs.debugMode = function() { SAFE_MODE = false; };
2242 hljs.safeMode = function() { SAFE_MODE = true; };
2243 hljs.versionString = version;
2244
2245 for (const key in MODES) {
2246 // @ts-ignore
2247 if (typeof MODES[key] === "object") {
2248 // @ts-ignore
2249 deepFreezeEs6(MODES[key]);
2250 }
2251 }
2252
2253 // merge all the modes/regexs into our main object
2254 Object.assign(hljs, MODES);
2255
2256 return hljs;
2257 };
2258
2259 // export an "instance" of the highlighter
2260 var highlight = HLJS({});
2261
2262 return highlight;
2263
2264}());
2265if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = hljs; }
2266
2267hljs.registerLanguage('apache', function () {
2268 'use strict';
2269
2270 /*
2271 Language: Apache config
2272 Author: Ruslan Keba <rukeba@gmail.com>
2273 Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
2274 Website: https://httpd.apache.org
2275 Description: language definition for Apache configuration files (httpd.conf & .htaccess)
2276 Category: common, config
2277 */
2278
2279 /** @type LanguageFn */
2280 function apache(hljs) {
2281 const NUMBER_REF = {
2282 className: 'number',
2283 begin: '[\\$%]\\d+'
2284 };
2285 const NUMBER = {
2286 className: 'number',
2287 begin: '\\d+'
2288 };
2289 const IP_ADDRESS = {
2290 className: "number",
2291 begin: '\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?'
2292 };
2293 const PORT_NUMBER = {
2294 className: "number",
2295 begin: ":\\d{1,5}"
2296 };
2297 return {
2298 name: 'Apache config',
2299 aliases: ['apacheconf'],
2300 case_insensitive: true,
2301 contains: [
2302 hljs.HASH_COMMENT_MODE,
2303 {
2304 className: 'section',
2305 begin: '</?',
2306 end: '>',
2307 contains: [
2308 IP_ADDRESS,
2309 PORT_NUMBER,
2310 // low relevance prevents us from claming XML/HTML where this rule would
2311 // match strings inside of XML tags
2312 hljs.inherit(hljs.QUOTE_STRING_MODE, { relevance: 0 })
2313 ]
2314 },
2315 {
2316 className: 'attribute',
2317 begin: /\w+/,
2318 relevance: 0,
2319 // keywords aren’t needed for highlighting per se, they only boost relevance
2320 // for a very generally defined mode (starts with a word, ends with line-end
2321 keywords: { nomarkup:
2322 'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
2323 'sethandler errordocument loadmodule options header listen serverroot ' +
2324 'servername' },
2325 starts: {
2326 end: /$/,
2327 relevance: 0,
2328 keywords: { literal: 'on off all deny allow' },
2329 contains: [
2330 {
2331 className: 'meta',
2332 begin: '\\s\\[',
2333 end: '\\]$'
2334 },
2335 {
2336 className: 'variable',
2337 begin: '[\\$%]\\{',
2338 end: '\\}',
2339 contains: ['self',
2340 NUMBER_REF]
2341 },
2342 IP_ADDRESS,
2343 NUMBER,
2344 hljs.QUOTE_STRING_MODE
2345 ]
2346 }
2347 }
2348 ],
2349 illegal: /\S/
2350 };
2351 }
2352
2353 return apache;
2354
2355 return module.exports.definer || module.exports;
2356
2357}());
2358
2359hljs.registerLanguage('bash', function () {
2360 'use strict';
2361
2362 /**
2363 * @param {string} value
2364 * @returns {RegExp}
2365 * */
2366
2367 /**
2368 * @param {RegExp | string } re
2369 * @returns {string}
2370 */
2371 function source(re) {
2372 if (!re) return null;
2373 if (typeof re === "string") return re;
2374
2375 return re.source;
2376 }
2377
2378 /**
2379 * @param {...(RegExp | string) } args
2380 * @returns {string}
2381 */
2382 function concat(...args) {
2383 const joined = args.map((x) => source(x)).join("");
2384 return joined;
2385 }
2386
2387 /*
2388 Language: Bash
2389 Author: vah <vahtenberg@gmail.com>
2390 Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
2391 Website: https://www.gnu.org/software/bash/
2392 Category: common
2393 */
2394
2395 /** @type LanguageFn */
2396 function bash(hljs) {
2397 const VAR = {};
2398 const BRACED_VAR = {
2399 begin: /\$\{/,
2400 end:/\}/,
2401 contains: [
2402 "self",
2403 {
2404 begin: /:-/,
2405 contains: [ VAR ]
2406 } // default values
2407 ]
2408 };
2409 Object.assign(VAR,{
2410 className: 'variable',
2411 variants: [
2412 {begin: concat(/\$[\w\d#@][\w\d_]*/,
2413 // negative look-ahead tries to avoid matching patterns that are not
2414 // Perl at all like $ident$, @ident@, etc.
2415 `(?![\\w\\d])(?![$])`) },
2416 BRACED_VAR
2417 ]
2418 });
2419
2420 const SUBST = {
2421 className: 'subst',
2422 begin: /\$\(/, end: /\)/,
2423 contains: [hljs.BACKSLASH_ESCAPE]
2424 };
2425 const HERE_DOC = {
2426 begin: /<<-?\s*(?=\w+)/,
2427 starts: {
2428 contains: [
2429 hljs.END_SAME_AS_BEGIN({
2430 begin: /(\w+)/,
2431 end: /(\w+)/,
2432 className: 'string'
2433 })
2434 ]
2435 }
2436 };
2437 const QUOTE_STRING = {
2438 className: 'string',
2439 begin: /"/, end: /"/,
2440 contains: [
2441 hljs.BACKSLASH_ESCAPE,
2442 VAR,
2443 SUBST
2444 ]
2445 };
2446 SUBST.contains.push(QUOTE_STRING);
2447 const ESCAPED_QUOTE = {
2448 className: '',
2449 begin: /\\"/
2450
2451 };
2452 const APOS_STRING = {
2453 className: 'string',
2454 begin: /'/, end: /'/
2455 };
2456 const ARITHMETIC = {
2457 begin: /\$\(\(/,
2458 end: /\)\)/,
2459 contains: [
2460 { begin: /\d+#[0-9a-f]+/, className: "number" },
2461 hljs.NUMBER_MODE,
2462 VAR
2463 ]
2464 };
2465 const SH_LIKE_SHELLS = [
2466 "fish",
2467 "bash",
2468 "zsh",
2469 "sh",
2470 "csh",
2471 "ksh",
2472 "tcsh",
2473 "dash",
2474 "scsh",
2475 ];
2476 const KNOWN_SHEBANG = hljs.SHEBANG({
2477 binary: `(${SH_LIKE_SHELLS.join("|")})`,
2478 relevance: 10
2479 });
2480 const FUNCTION = {
2481 className: 'function',
2482 begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
2483 returnBegin: true,
2484 contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
2485 relevance: 0
2486 };
2487
2488 return {
2489 name: 'Bash',
2490 aliases: ['sh', 'zsh'],
2491 keywords: {
2492 $pattern: /\b[a-z._-]+\b/,
2493 keyword:
2494 'if then else elif fi for while in do done case esac function',
2495 literal:
2496 'true false',
2497 built_in:
2498 // Shell built-ins
2499 // http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
2500 'break cd continue eval exec exit export getopts hash pwd readonly return shift test times ' +
2501 'trap umask unset ' +
2502 // Bash built-ins
2503 'alias bind builtin caller command declare echo enable help let local logout mapfile printf ' +
2504 'read readarray source type typeset ulimit unalias ' +
2505 // Shell modifiers
2506 'set shopt ' +
2507 // Zsh built-ins
2508 'autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles ' +
2509 'compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate ' +
2510 'fc fg float functions getcap getln history integer jobs kill limit log noglob popd print ' +
2511 'pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit ' +
2512 'unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof ' +
2513 'zpty zregexparse zsocket zstyle ztcp'
2514 },
2515 contains: [
2516 KNOWN_SHEBANG, // to catch known shells and boost relevancy
2517 hljs.SHEBANG(), // to catch unknown shells but still highlight the shebang
2518 FUNCTION,
2519 ARITHMETIC,
2520 hljs.HASH_COMMENT_MODE,
2521 HERE_DOC,
2522 QUOTE_STRING,
2523 ESCAPED_QUOTE,
2524 APOS_STRING,
2525 VAR
2526 ]
2527 };
2528 }
2529
2530 return bash;
2531
2532 return module.exports.definer || module.exports;
2533
2534}());
2535
2536hljs.registerLanguage('c', function () {
2537 'use strict';
2538
2539 /**
2540 * @param {string} value
2541 * @returns {RegExp}
2542 * */
2543
2544 /**
2545 * @param {RegExp | string } re
2546 * @returns {string}
2547 */
2548 function source(re) {
2549 if (!re) return null;
2550 if (typeof re === "string") return re;
2551
2552 return re.source;
2553 }
2554
2555 /**
2556 * @param {RegExp | string } re
2557 * @returns {string}
2558 */
2559 function optional(re) {
2560 return concat('(', re, ')?');
2561 }
2562
2563 /**
2564 * @param {...(RegExp | string) } args
2565 * @returns {string}
2566 */
2567 function concat(...args) {
2568 const joined = args.map((x) => source(x)).join("");
2569 return joined;
2570 }
2571
2572 /*
2573 Language: C-like foundation grammar for C/C++ grammars
2574 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
2575 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>
2576 */
2577
2578 /** @type LanguageFn */
2579 function cLike(hljs) {
2580 // added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
2581 // not include such support nor can we be sure all the grammars depending
2582 // on it would desire this behavior
2583 const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', {
2584 contains: [
2585 {
2586 begin: /\\\n/
2587 }
2588 ]
2589 });
2590 const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
2591 const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
2592 const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
2593 const FUNCTION_TYPE_RE = '(' +
2594 DECLTYPE_AUTO_RE + '|' +
2595 optional(NAMESPACE_RE) +
2596 '[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) +
2597 ')';
2598 const CPP_PRIMITIVE_TYPES = {
2599 className: 'keyword',
2600 begin: '\\b[a-z\\d_]*_t\\b'
2601 };
2602
2603 // https://en.cppreference.com/w/cpp/language/escape
2604 // \\ \x \xFF \u2837 \u00323747 \374
2605 const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
2606 const STRINGS = {
2607 className: 'string',
2608 variants: [
2609 {
2610 begin: '(u8?|U|L)?"',
2611 end: '"',
2612 illegal: '\\n',
2613 contains: [ hljs.BACKSLASH_ESCAPE ]
2614 },
2615 {
2616 begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + "|.)",
2617 end: '\'',
2618 illegal: '.'
2619 },
2620 hljs.END_SAME_AS_BEGIN({
2621 begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
2622 end: /\)([^()\\ ]{0,16})"/
2623 })
2624 ]
2625 };
2626
2627 const NUMBERS = {
2628 className: 'number',
2629 variants: [
2630 {
2631 begin: '\\b(0b[01\']+)'
2632 },
2633 {
2634 begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)'
2635 },
2636 {
2637 begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)'
2638 }
2639 ],
2640 relevance: 0
2641 };
2642
2643 const PREPROCESSOR = {
2644 className: 'meta',
2645 begin: /#\s*[a-z]+\b/,
2646 end: /$/,
2647 keywords: {
2648 'meta-keyword':
2649 'if else elif endif define undef warning error line ' +
2650 'pragma _Pragma ifdef ifndef include'
2651 },
2652 contains: [
2653 {
2654 begin: /\\\n/,
2655 relevance: 0
2656 },
2657 hljs.inherit(STRINGS, {
2658 className: 'meta-string'
2659 }),
2660 {
2661 className: 'meta-string',
2662 begin: /<.*?>/,
2663 end: /$/,
2664 illegal: '\\n'
2665 },
2666 C_LINE_COMMENT_MODE,
2667 hljs.C_BLOCK_COMMENT_MODE
2668 ]
2669 };
2670
2671 const TITLE_MODE = {
2672 className: 'title',
2673 begin: optional(NAMESPACE_RE) + hljs.IDENT_RE,
2674 relevance: 0
2675 };
2676
2677 const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
2678
2679 const CPP_KEYWORDS = {
2680 keyword: 'int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof ' +
2681 'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace ' +
2682 'unsigned long volatile static protected bool template mutable if public friend ' +
2683 'do goto auto void enum else break extern using asm case typeid wchar_t ' +
2684 'short reinterpret_cast|10 default double register explicit signed typename try this ' +
2685 'switch continue inline delete alignas alignof constexpr consteval constinit decltype ' +
2686 'concept co_await co_return co_yield requires ' +
2687 'noexcept static_assert thread_local restrict final override ' +
2688 'atomic_bool atomic_char atomic_schar ' +
2689 'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
2690 'atomic_ullong new throw return ' +
2691 'and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq',
2692 built_in: 'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' +
2693 'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set ' +
2694 'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos ' +
2695 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
2696 'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
2697 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
2698 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
2699 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
2700 'vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary',
2701 literal: 'true false nullptr NULL'
2702 };
2703
2704 const EXPRESSION_CONTAINS = [
2705 PREPROCESSOR,
2706 CPP_PRIMITIVE_TYPES,
2707 C_LINE_COMMENT_MODE,
2708 hljs.C_BLOCK_COMMENT_MODE,
2709 NUMBERS,
2710 STRINGS
2711 ];
2712
2713 const EXPRESSION_CONTEXT = {
2714 // This mode covers expression context where we can't expect a function
2715 // definition and shouldn't highlight anything that looks like one:
2716 // `return some()`, `else if()`, `(x*sum(1, 2))`
2717 variants: [
2718 {
2719 begin: /=/,
2720 end: /;/
2721 },
2722 {
2723 begin: /\(/,
2724 end: /\)/
2725 },
2726 {
2727 beginKeywords: 'new throw return else',
2728 end: /;/
2729 }
2730 ],
2731 keywords: CPP_KEYWORDS,
2732 contains: EXPRESSION_CONTAINS.concat([
2733 {
2734 begin: /\(/,
2735 end: /\)/,
2736 keywords: CPP_KEYWORDS,
2737 contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
2738 relevance: 0
2739 }
2740 ]),
2741 relevance: 0
2742 };
2743
2744 const FUNCTION_DECLARATION = {
2745 className: 'function',
2746 begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
2747 returnBegin: true,
2748 end: /[{;=]/,
2749 excludeEnd: true,
2750 keywords: CPP_KEYWORDS,
2751 illegal: /[^\w\s\*&:<>]/,
2752 contains: [
2753 { // to prevent it from being confused as the function title
2754 begin: DECLTYPE_AUTO_RE,
2755 keywords: CPP_KEYWORDS,
2756 relevance: 0
2757 },
2758 {
2759 begin: FUNCTION_TITLE,
2760 returnBegin: true,
2761 contains: [ TITLE_MODE ],
2762 relevance: 0
2763 },
2764 {
2765 className: 'params',
2766 begin: /\(/,
2767 end: /\)/,
2768 keywords: CPP_KEYWORDS,
2769 relevance: 0,
2770 contains: [
2771 C_LINE_COMMENT_MODE,
2772 hljs.C_BLOCK_COMMENT_MODE,
2773 STRINGS,
2774 NUMBERS,
2775 CPP_PRIMITIVE_TYPES,
2776 // Count matching parentheses.
2777 {
2778 begin: /\(/,
2779 end: /\)/,
2780 keywords: CPP_KEYWORDS,
2781 relevance: 0,
2782 contains: [
2783 'self',
2784 C_LINE_COMMENT_MODE,
2785 hljs.C_BLOCK_COMMENT_MODE,
2786 STRINGS,
2787 NUMBERS,
2788 CPP_PRIMITIVE_TYPES
2789 ]
2790 }
2791 ]
2792 },
2793 CPP_PRIMITIVE_TYPES,
2794 C_LINE_COMMENT_MODE,
2795 hljs.C_BLOCK_COMMENT_MODE,
2796 PREPROCESSOR
2797 ]
2798 };
2799
2800 return {
2801 aliases: [
2802 'c',
2803 'cc',
2804 'h',
2805 'c++',
2806 'h++',
2807 'hpp',
2808 'hh',
2809 'hxx',
2810 'cxx'
2811 ],
2812 keywords: CPP_KEYWORDS,
2813 // the base c-like language will NEVER be auto-detected, rather the
2814 // derivitives: c, c++, arduino turn auto-detect back on for themselves
2815 disableAutodetect: true,
2816 illegal: '</',
2817 contains: [].concat(
2818 EXPRESSION_CONTEXT,
2819 FUNCTION_DECLARATION,
2820 EXPRESSION_CONTAINS,
2821 [
2822 PREPROCESSOR,
2823 { // containers: ie, `vector <int> rooms (9);`
2824 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*<',
2825 end: '>',
2826 keywords: CPP_KEYWORDS,
2827 contains: [
2828 'self',
2829 CPP_PRIMITIVE_TYPES
2830 ]
2831 },
2832 {
2833 begin: hljs.IDENT_RE + '::',
2834 keywords: CPP_KEYWORDS
2835 },
2836 {
2837 className: 'class',
2838 beginKeywords: 'enum class struct union',
2839 end: /[{;:<>=]/,
2840 contains: [
2841 {
2842 beginKeywords: "final class struct"
2843 },
2844 hljs.TITLE_MODE
2845 ]
2846 }
2847 ]),
2848 exports: {
2849 preprocessor: PREPROCESSOR,
2850 strings: STRINGS,
2851 keywords: CPP_KEYWORDS
2852 }
2853 };
2854 }
2855
2856 /*
2857 Language: C
2858 Category: common, system
2859 Website: https://en.wikipedia.org/wiki/C_(programming_language)
2860 */
2861
2862 /** @type LanguageFn */
2863 function c(hljs) {
2864 const lang = cLike(hljs);
2865 // Until C is actually different than C++ there is no reason to auto-detect C
2866 // as it's own language since it would just fail auto-detect testing or
2867 // simply match with C++.
2868 //
2869 // See further comments in c-like.js.
2870
2871 // lang.disableAutodetect = false;
2872 lang.name = 'C';
2873 lang.aliases = ['c', 'h'];
2874 return lang;
2875 }
2876
2877 return c;
2878
2879 return module.exports.definer || module.exports;
2880
2881}());
2882
2883hljs.registerLanguage('coffeescript', function () {
2884 'use strict';
2885
2886 const KEYWORDS = [
2887 "as", // for exports
2888 "in",
2889 "of",
2890 "if",
2891 "for",
2892 "while",
2893 "finally",
2894 "var",
2895 "new",
2896 "function",
2897 "do",
2898 "return",
2899 "void",
2900 "else",
2901 "break",
2902 "catch",
2903 "instanceof",
2904 "with",
2905 "throw",
2906 "case",
2907 "default",
2908 "try",
2909 "switch",
2910 "continue",
2911 "typeof",
2912 "delete",
2913 "let",
2914 "yield",
2915 "const",
2916 "class",
2917 // JS handles these with a special rule
2918 // "get",
2919 // "set",
2920 "debugger",
2921 "async",
2922 "await",
2923 "static",
2924 "import",
2925 "from",
2926 "export",
2927 "extends"
2928 ];
2929 const LITERALS = [
2930 "true",
2931 "false",
2932 "null",
2933 "undefined",
2934 "NaN",
2935 "Infinity"
2936 ];
2937
2938 const TYPES = [
2939 "Intl",
2940 "DataView",
2941 "Number",
2942 "Math",
2943 "Date",
2944 "String",
2945 "RegExp",
2946 "Object",
2947 "Function",
2948 "Boolean",
2949 "Error",
2950 "Symbol",
2951 "Set",
2952 "Map",
2953 "WeakSet",
2954 "WeakMap",
2955 "Proxy",
2956 "Reflect",
2957 "JSON",
2958 "Promise",
2959 "Float64Array",
2960 "Int16Array",
2961 "Int32Array",
2962 "Int8Array",
2963 "Uint16Array",
2964 "Uint32Array",
2965 "Float32Array",
2966 "Array",
2967 "Uint8Array",
2968 "Uint8ClampedArray",
2969 "ArrayBuffer"
2970 ];
2971
2972 const ERROR_TYPES = [
2973 "EvalError",
2974 "InternalError",
2975 "RangeError",
2976 "ReferenceError",
2977 "SyntaxError",
2978 "TypeError",
2979 "URIError"
2980 ];
2981
2982 const BUILT_IN_GLOBALS = [
2983 "setInterval",
2984 "setTimeout",
2985 "clearInterval",
2986 "clearTimeout",
2987
2988 "require",
2989 "exports",
2990
2991 "eval",
2992 "isFinite",
2993 "isNaN",
2994 "parseFloat",
2995 "parseInt",
2996 "decodeURI",
2997 "decodeURIComponent",
2998 "encodeURI",
2999 "encodeURIComponent",
3000 "escape",
3001 "unescape"
3002 ];
3003
3004 const BUILT_IN_VARIABLES = [
3005 "arguments",
3006 "this",
3007 "super",
3008 "console",
3009 "window",
3010 "document",
3011 "localStorage",
3012 "module",
3013 "global" // Node.js
3014 ];
3015
3016 const BUILT_INS = [].concat(
3017 BUILT_IN_GLOBALS,
3018 BUILT_IN_VARIABLES,
3019 TYPES,
3020 ERROR_TYPES
3021 );
3022
3023 /*
3024 Language: CoffeeScript
3025 Author: Dmytrii Nagirniak <dnagir@gmail.com>
3026 Contributors: Oleg Efimov <efimovov@gmail.com>, Cédric Néhémie <cedric.nehemie@gmail.com>
3027 Description: CoffeeScript is a programming language that transcompiles to JavaScript. For info about language see http://coffeescript.org/
3028 Category: common, scripting
3029 Website: https://coffeescript.org
3030 */
3031
3032 /** @type LanguageFn */
3033 function coffeescript(hljs) {
3034 const COFFEE_BUILT_INS = [
3035 'npm',
3036 'print'
3037 ];
3038 const COFFEE_LITERALS = [
3039 'yes',
3040 'no',
3041 'on',
3042 'off'
3043 ];
3044 const COFFEE_KEYWORDS = [
3045 'then',
3046 'unless',
3047 'until',
3048 'loop',
3049 'by',
3050 'when',
3051 'and',
3052 'or',
3053 'is',
3054 'isnt',
3055 'not'
3056 ];
3057 const NOT_VALID_KEYWORDS = [
3058 "var",
3059 "const",
3060 "let",
3061 "function",
3062 "static"
3063 ];
3064 const excluding = (list) =>
3065 (kw) => !list.includes(kw);
3066 const KEYWORDS$1 = {
3067 keyword: KEYWORDS.concat(COFFEE_KEYWORDS).filter(excluding(NOT_VALID_KEYWORDS)).join(" "),
3068 literal: LITERALS.concat(COFFEE_LITERALS).join(" "),
3069 built_in: BUILT_INS.concat(COFFEE_BUILT_INS).join(" ")
3070 };
3071 const JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
3072 const SUBST = {
3073 className: 'subst',
3074 begin: /#\{/,
3075 end: /\}/,
3076 keywords: KEYWORDS$1
3077 };
3078 const EXPRESSIONS = [
3079 hljs.BINARY_NUMBER_MODE,
3080 hljs.inherit(hljs.C_NUMBER_MODE, {
3081 starts: {
3082 end: '(\\s*/)?',
3083 relevance: 0
3084 }
3085 }), // a number tries to eat the following slash to prevent treating it as a regexp
3086 {
3087 className: 'string',
3088 variants: [
3089 {
3090 begin: /'''/,
3091 end: /'''/,
3092 contains: [hljs.BACKSLASH_ESCAPE]
3093 },
3094 {
3095 begin: /'/,
3096 end: /'/,
3097 contains: [hljs.BACKSLASH_ESCAPE]
3098 },
3099 {
3100 begin: /"""/,
3101 end: /"""/,
3102 contains: [
3103 hljs.BACKSLASH_ESCAPE,
3104 SUBST
3105 ]
3106 },
3107 {
3108 begin: /"/,
3109 end: /"/,
3110 contains: [
3111 hljs.BACKSLASH_ESCAPE,
3112 SUBST
3113 ]
3114 }
3115 ]
3116 },
3117 {
3118 className: 'regexp',
3119 variants: [
3120 {
3121 begin: '///',
3122 end: '///',
3123 contains: [
3124 SUBST,
3125 hljs.HASH_COMMENT_MODE
3126 ]
3127 },
3128 {
3129 begin: '//[gim]{0,3}(?=\\W)',
3130 relevance: 0
3131 },
3132 {
3133 // regex can't start with space to parse x / 2 / 3 as two divisions
3134 // regex can't start with *, and it supports an "illegal" in the main mode
3135 begin: /\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/
3136 }
3137 ]
3138 },
3139 {
3140 begin: '@' + JS_IDENT_RE // relevance booster
3141 },
3142 {
3143 subLanguage: 'javascript',
3144 excludeBegin: true,
3145 excludeEnd: true,
3146 variants: [
3147 {
3148 begin: '```',
3149 end: '```'
3150 },
3151 {
3152 begin: '`',
3153 end: '`'
3154 }
3155 ]
3156 }
3157 ];
3158 SUBST.contains = EXPRESSIONS;
3159
3160 const TITLE = hljs.inherit(hljs.TITLE_MODE, {
3161 begin: JS_IDENT_RE
3162 });
3163 const POSSIBLE_PARAMS_RE = '(\\(.*\\)\\s*)?\\B[-=]>';
3164 const PARAMS = {
3165 className: 'params',
3166 begin: '\\([^\\(]',
3167 returnBegin: true,
3168 /* We need another contained nameless mode to not have every nested
3169 pair of parens to be called "params" */
3170 contains: [{
3171 begin: /\(/,
3172 end: /\)/,
3173 keywords: KEYWORDS$1,
3174 contains: ['self'].concat(EXPRESSIONS)
3175 }]
3176 };
3177
3178 return {
3179 name: 'CoffeeScript',
3180 aliases: [
3181 'coffee',
3182 'cson',
3183 'iced'
3184 ],
3185 keywords: KEYWORDS$1,
3186 illegal: /\/\*/,
3187 contains: EXPRESSIONS.concat([
3188 hljs.COMMENT('###', '###'),
3189 hljs.HASH_COMMENT_MODE,
3190 {
3191 className: 'function',
3192 begin: '^\\s*' + JS_IDENT_RE + '\\s*=\\s*' + POSSIBLE_PARAMS_RE,
3193 end: '[-=]>',
3194 returnBegin: true,
3195 contains: [
3196 TITLE,
3197 PARAMS
3198 ]
3199 },
3200 {
3201 // anonymous function start
3202 begin: /[:\(,=]\s*/,
3203 relevance: 0,
3204 contains: [{
3205 className: 'function',
3206 begin: POSSIBLE_PARAMS_RE,
3207 end: '[-=]>',
3208 returnBegin: true,
3209 contains: [PARAMS]
3210 }]
3211 },
3212 {
3213 className: 'class',
3214 beginKeywords: 'class',
3215 end: '$',
3216 illegal: /[:="\[\]]/,
3217 contains: [
3218 {
3219 beginKeywords: 'extends',
3220 endsWithParent: true,
3221 illegal: /[:="\[\]]/,
3222 contains: [TITLE]
3223 },
3224 TITLE
3225 ]
3226 },
3227 {
3228 begin: JS_IDENT_RE + ':',
3229 end: ':',
3230 returnBegin: true,
3231 returnEnd: true,
3232 relevance: 0
3233 }
3234 ])
3235 };
3236 }
3237
3238 return coffeescript;
3239
3240 return module.exports.definer || module.exports;
3241
3242}());
3243
3244hljs.registerLanguage('cpp', function () {
3245 'use strict';
3246
3247 /**
3248 * @param {string} value
3249 * @returns {RegExp}
3250 * */
3251
3252 /**
3253 * @param {RegExp | string } re
3254 * @returns {string}
3255 */
3256 function source(re) {
3257 if (!re) return null;
3258 if (typeof re === "string") return re;
3259
3260 return re.source;
3261 }
3262
3263 /**
3264 * @param {RegExp | string } re
3265 * @returns {string}
3266 */
3267 function optional(re) {
3268 return concat('(', re, ')?');
3269 }
3270
3271 /**
3272 * @param {...(RegExp | string) } args
3273 * @returns {string}
3274 */
3275 function concat(...args) {
3276 const joined = args.map((x) => source(x)).join("");
3277 return joined;
3278 }
3279
3280 /*
3281 Language: C-like foundation grammar for C/C++ grammars
3282 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
3283 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>
3284 */
3285
3286 /** @type LanguageFn */
3287 function cLike(hljs) {
3288 // added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
3289 // not include such support nor can we be sure all the grammars depending
3290 // on it would desire this behavior
3291 const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', {
3292 contains: [
3293 {
3294 begin: /\\\n/
3295 }
3296 ]
3297 });
3298 const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
3299 const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
3300 const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
3301 const FUNCTION_TYPE_RE = '(' +
3302 DECLTYPE_AUTO_RE + '|' +
3303 optional(NAMESPACE_RE) +
3304 '[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) +
3305 ')';
3306 const CPP_PRIMITIVE_TYPES = {
3307 className: 'keyword',
3308 begin: '\\b[a-z\\d_]*_t\\b'
3309 };
3310
3311 // https://en.cppreference.com/w/cpp/language/escape
3312 // \\ \x \xFF \u2837 \u00323747 \374
3313 const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
3314 const STRINGS = {
3315 className: 'string',
3316 variants: [
3317 {
3318 begin: '(u8?|U|L)?"',
3319 end: '"',
3320 illegal: '\\n',
3321 contains: [ hljs.BACKSLASH_ESCAPE ]
3322 },
3323 {
3324 begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + "|.)",
3325 end: '\'',
3326 illegal: '.'
3327 },
3328 hljs.END_SAME_AS_BEGIN({
3329 begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
3330 end: /\)([^()\\ ]{0,16})"/
3331 })
3332 ]
3333 };
3334
3335 const NUMBERS = {
3336 className: 'number',
3337 variants: [
3338 {
3339 begin: '\\b(0b[01\']+)'
3340 },
3341 {
3342 begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)'
3343 },
3344 {
3345 begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)'
3346 }
3347 ],
3348 relevance: 0
3349 };
3350
3351 const PREPROCESSOR = {
3352 className: 'meta',
3353 begin: /#\s*[a-z]+\b/,
3354 end: /$/,
3355 keywords: {
3356 'meta-keyword':
3357 'if else elif endif define undef warning error line ' +
3358 'pragma _Pragma ifdef ifndef include'
3359 },
3360 contains: [
3361 {
3362 begin: /\\\n/,
3363 relevance: 0
3364 },
3365 hljs.inherit(STRINGS, {
3366 className: 'meta-string'
3367 }),
3368 {
3369 className: 'meta-string',
3370 begin: /<.*?>/,
3371 end: /$/,
3372 illegal: '\\n'
3373 },
3374 C_LINE_COMMENT_MODE,
3375 hljs.C_BLOCK_COMMENT_MODE
3376 ]
3377 };
3378
3379 const TITLE_MODE = {
3380 className: 'title',
3381 begin: optional(NAMESPACE_RE) + hljs.IDENT_RE,
3382 relevance: 0
3383 };
3384
3385 const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
3386
3387 const CPP_KEYWORDS = {
3388 keyword: 'int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof ' +
3389 'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace ' +
3390 'unsigned long volatile static protected bool template mutable if public friend ' +
3391 'do goto auto void enum else break extern using asm case typeid wchar_t ' +
3392 'short reinterpret_cast|10 default double register explicit signed typename try this ' +
3393 'switch continue inline delete alignas alignof constexpr consteval constinit decltype ' +
3394 'concept co_await co_return co_yield requires ' +
3395 'noexcept static_assert thread_local restrict final override ' +
3396 'atomic_bool atomic_char atomic_schar ' +
3397 'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
3398 'atomic_ullong new throw return ' +
3399 'and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq',
3400 built_in: 'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' +
3401 'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set ' +
3402 'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos ' +
3403 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
3404 'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
3405 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
3406 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
3407 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
3408 'vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary',
3409 literal: 'true false nullptr NULL'
3410 };
3411
3412 const EXPRESSION_CONTAINS = [
3413 PREPROCESSOR,
3414 CPP_PRIMITIVE_TYPES,
3415 C_LINE_COMMENT_MODE,
3416 hljs.C_BLOCK_COMMENT_MODE,
3417 NUMBERS,
3418 STRINGS
3419 ];
3420
3421 const EXPRESSION_CONTEXT = {
3422 // This mode covers expression context where we can't expect a function
3423 // definition and shouldn't highlight anything that looks like one:
3424 // `return some()`, `else if()`, `(x*sum(1, 2))`
3425 variants: [
3426 {
3427 begin: /=/,
3428 end: /;/
3429 },
3430 {
3431 begin: /\(/,
3432 end: /\)/
3433 },
3434 {
3435 beginKeywords: 'new throw return else',
3436 end: /;/
3437 }
3438 ],
3439 keywords: CPP_KEYWORDS,
3440 contains: EXPRESSION_CONTAINS.concat([
3441 {
3442 begin: /\(/,
3443 end: /\)/,
3444 keywords: CPP_KEYWORDS,
3445 contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
3446 relevance: 0
3447 }
3448 ]),
3449 relevance: 0
3450 };
3451
3452 const FUNCTION_DECLARATION = {
3453 className: 'function',
3454 begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
3455 returnBegin: true,
3456 end: /[{;=]/,
3457 excludeEnd: true,
3458 keywords: CPP_KEYWORDS,
3459 illegal: /[^\w\s\*&:<>]/,
3460 contains: [
3461 { // to prevent it from being confused as the function title
3462 begin: DECLTYPE_AUTO_RE,
3463 keywords: CPP_KEYWORDS,
3464 relevance: 0
3465 },
3466 {
3467 begin: FUNCTION_TITLE,
3468 returnBegin: true,
3469 contains: [ TITLE_MODE ],
3470 relevance: 0
3471 },
3472 {
3473 className: 'params',
3474 begin: /\(/,
3475 end: /\)/,
3476 keywords: CPP_KEYWORDS,
3477 relevance: 0,
3478 contains: [
3479 C_LINE_COMMENT_MODE,
3480 hljs.C_BLOCK_COMMENT_MODE,
3481 STRINGS,
3482 NUMBERS,
3483 CPP_PRIMITIVE_TYPES,
3484 // Count matching parentheses.
3485 {
3486 begin: /\(/,
3487 end: /\)/,
3488 keywords: CPP_KEYWORDS,
3489 relevance: 0,
3490 contains: [
3491 'self',
3492 C_LINE_COMMENT_MODE,
3493 hljs.C_BLOCK_COMMENT_MODE,
3494 STRINGS,
3495 NUMBERS,
3496 CPP_PRIMITIVE_TYPES
3497 ]
3498 }
3499 ]
3500 },
3501 CPP_PRIMITIVE_TYPES,
3502 C_LINE_COMMENT_MODE,
3503 hljs.C_BLOCK_COMMENT_MODE,
3504 PREPROCESSOR
3505 ]
3506 };
3507
3508 return {
3509 aliases: [
3510 'c',
3511 'cc',
3512 'h',
3513 'c++',
3514 'h++',
3515 'hpp',
3516 'hh',
3517 'hxx',
3518 'cxx'
3519 ],
3520 keywords: CPP_KEYWORDS,
3521 // the base c-like language will NEVER be auto-detected, rather the
3522 // derivitives: c, c++, arduino turn auto-detect back on for themselves
3523 disableAutodetect: true,
3524 illegal: '</',
3525 contains: [].concat(
3526 EXPRESSION_CONTEXT,
3527 FUNCTION_DECLARATION,
3528 EXPRESSION_CONTAINS,
3529 [
3530 PREPROCESSOR,
3531 { // containers: ie, `vector <int> rooms (9);`
3532 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*<',
3533 end: '>',
3534 keywords: CPP_KEYWORDS,
3535 contains: [
3536 'self',
3537 CPP_PRIMITIVE_TYPES
3538 ]
3539 },
3540 {
3541 begin: hljs.IDENT_RE + '::',
3542 keywords: CPP_KEYWORDS
3543 },
3544 {
3545 className: 'class',
3546 beginKeywords: 'enum class struct union',
3547 end: /[{;:<>=]/,
3548 contains: [
3549 {
3550 beginKeywords: "final class struct"
3551 },
3552 hljs.TITLE_MODE
3553 ]
3554 }
3555 ]),
3556 exports: {
3557 preprocessor: PREPROCESSOR,
3558 strings: STRINGS,
3559 keywords: CPP_KEYWORDS
3560 }
3561 };
3562 }
3563
3564 /*
3565 Language: C++
3566 Category: common, system
3567 Website: https://isocpp.org
3568 */
3569
3570 /** @type LanguageFn */
3571 function cpp(hljs) {
3572 const lang = cLike(hljs);
3573 // return auto-detection back on
3574 lang.disableAutodetect = false;
3575 lang.name = 'C++';
3576 lang.aliases = ['cc', 'c++', 'h++', 'hpp', 'hh', 'hxx', 'cxx'];
3577 return lang;
3578 }
3579
3580 return cpp;
3581
3582 return module.exports.definer || module.exports;
3583
3584}());
3585
3586hljs.registerLanguage('csharp', function () {
3587 'use strict';
3588
3589 /*
3590 Language: C#
3591 Author: Jason Diamond <jason@diamond.name>
3592 Contributor: Nicolas LLOBERA <nllobera@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, David Pine <david.pine@microsoft.com>
3593 Website: https://docs.microsoft.com/en-us/dotnet/csharp/
3594 Category: common
3595 */
3596
3597 /** @type LanguageFn */
3598 function csharp(hljs) {
3599 var BUILT_IN_KEYWORDS = [
3600 'bool',
3601 'byte',
3602 'char',
3603 'decimal',
3604 'delegate',
3605 'double',
3606 'dynamic',
3607 'enum',
3608 'float',
3609 'int',
3610 'long',
3611 'nint',
3612 'nuint',
3613 'object',
3614 'sbyte',
3615 'short',
3616 'string',
3617 'ulong',
3618 'unit',
3619 'ushort'
3620 ];
3621 var FUNCTION_MODIFIERS = [
3622 'public',
3623 'private',
3624 'protected',
3625 'static',
3626 'internal',
3627 'protected',
3628 'abstract',
3629 'async',
3630 'extern',
3631 'override',
3632 'unsafe',
3633 'virtual',
3634 'new',
3635 'sealed',
3636 'partial'
3637 ];
3638 var LITERAL_KEYWORDS = [
3639 'default',
3640 'false',
3641 'null',
3642 'true'
3643 ];
3644 var NORMAL_KEYWORDS = [
3645 'abstract',
3646 'as',
3647 'base',
3648 'break',
3649 'case',
3650 'class',
3651 'const',
3652 'continue',
3653 'do',
3654 'else',
3655 'event',
3656 'explicit',
3657 'extern',
3658 'finally',
3659 'fixed',
3660 'for',
3661 'foreach',
3662 'goto',
3663 'if',
3664 'implicit',
3665 'in',
3666 'interface',
3667 'internal',
3668 'is',
3669 'lock',
3670 'namespace',
3671 'new',
3672 'operator',
3673 'out',
3674 'override',
3675 'params',
3676 'private',
3677 'protected',
3678 'public',
3679 'readonly',
3680 'record',
3681 'ref',
3682 'return',
3683 'sealed',
3684 'sizeof',
3685 'stackalloc',
3686 'static',
3687 'struct',
3688 'switch',
3689 'this',
3690 'throw',
3691 'try',
3692 'typeof',
3693 'unchecked',
3694 'unsafe',
3695 'using',
3696 'virtual',
3697 'void',
3698 'volatile',
3699 'while'
3700 ];
3701 var CONTEXTUAL_KEYWORDS = [
3702 'add',
3703 'alias',
3704 'and',
3705 'ascending',
3706 'async',
3707 'await',
3708 'by',
3709 'descending',
3710 'equals',
3711 'from',
3712 'get',
3713 'global',
3714 'group',
3715 'init',
3716 'into',
3717 'join',
3718 'let',
3719 'nameof',
3720 'not',
3721 'notnull',
3722 'on',
3723 'or',
3724 'orderby',
3725 'partial',
3726 'remove',
3727 'select',
3728 'set',
3729 'unmanaged',
3730 'value|0',
3731 'var',
3732 'when',
3733 'where',
3734 'with',
3735 'yield'
3736 ];
3737
3738 var KEYWORDS = {
3739 keyword: NORMAL_KEYWORDS.concat(CONTEXTUAL_KEYWORDS).join(' '),
3740 built_in: BUILT_IN_KEYWORDS.join(' '),
3741 literal: LITERAL_KEYWORDS.join(' ')
3742 };
3743 var TITLE_MODE = hljs.inherit(hljs.TITLE_MODE, {begin: '[a-zA-Z](\\.?\\w)*'});
3744 var NUMBERS = {
3745 className: 'number',
3746 variants: [
3747 { begin: '\\b(0b[01\']+)' },
3748 { begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)' },
3749 { begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' }
3750 ],
3751 relevance: 0
3752 };
3753 var VERBATIM_STRING = {
3754 className: 'string',
3755 begin: '@"', end: '"',
3756 contains: [{begin: '""'}]
3757 };
3758 var VERBATIM_STRING_NO_LF = hljs.inherit(VERBATIM_STRING, {illegal: /\n/});
3759 var SUBST = {
3760 className: 'subst',
3761 begin: /\{/, end: /\}/,
3762 keywords: KEYWORDS
3763 };
3764 var SUBST_NO_LF = hljs.inherit(SUBST, {illegal: /\n/});
3765 var INTERPOLATED_STRING = {
3766 className: 'string',
3767 begin: /\$"/, end: '"',
3768 illegal: /\n/,
3769 contains: [{begin: /\{\{/}, {begin: /\}\}/}, hljs.BACKSLASH_ESCAPE, SUBST_NO_LF]
3770 };
3771 var INTERPOLATED_VERBATIM_STRING = {
3772 className: 'string',
3773 begin: /\$@"/, end: '"',
3774 contains: [{begin: /\{\{/}, {begin: /\}\}/}, {begin: '""'}, SUBST]
3775 };
3776 var INTERPOLATED_VERBATIM_STRING_NO_LF = hljs.inherit(INTERPOLATED_VERBATIM_STRING, {
3777 illegal: /\n/,
3778 contains: [{begin: /\{\{/}, {begin: /\}\}/}, {begin: '""'}, SUBST_NO_LF]
3779 });
3780 SUBST.contains = [
3781 INTERPOLATED_VERBATIM_STRING,
3782 INTERPOLATED_STRING,
3783 VERBATIM_STRING,
3784 hljs.APOS_STRING_MODE,
3785 hljs.QUOTE_STRING_MODE,
3786 NUMBERS,
3787 hljs.C_BLOCK_COMMENT_MODE
3788 ];
3789 SUBST_NO_LF.contains = [
3790 INTERPOLATED_VERBATIM_STRING_NO_LF,
3791 INTERPOLATED_STRING,
3792 VERBATIM_STRING_NO_LF,
3793 hljs.APOS_STRING_MODE,
3794 hljs.QUOTE_STRING_MODE,
3795 NUMBERS,
3796 hljs.inherit(hljs.C_BLOCK_COMMENT_MODE, {illegal: /\n/})
3797 ];
3798 var STRING = {
3799 variants: [
3800 INTERPOLATED_VERBATIM_STRING,
3801 INTERPOLATED_STRING,
3802 VERBATIM_STRING,
3803 hljs.APOS_STRING_MODE,
3804 hljs.QUOTE_STRING_MODE
3805 ]
3806 };
3807
3808 var GENERIC_MODIFIER = {
3809 begin: "<",
3810 end: ">",
3811 contains: [
3812 { beginKeywords: "in out"},
3813 TITLE_MODE
3814 ]
3815 };
3816 var TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?';
3817 var AT_IDENTIFIER = {
3818 // prevents expressions like `@class` from incorrect flagging
3819 // `class` as a keyword
3820 begin: "@" + hljs.IDENT_RE,
3821 relevance: 0
3822 };
3823
3824 return {
3825 name: 'C#',
3826 aliases: ['cs', 'c#'],
3827 keywords: KEYWORDS,
3828 illegal: /::/,
3829 contains: [
3830 hljs.COMMENT(
3831 '///',
3832 '$',
3833 {
3834 returnBegin: true,
3835 contains: [
3836 {
3837 className: 'doctag',
3838 variants: [
3839 {
3840 begin: '///', relevance: 0
3841 },
3842 {
3843 begin: '<!--|-->'
3844 },
3845 {
3846 begin: '</?', end: '>'
3847 }
3848 ]
3849 }
3850 ]
3851 }
3852 ),
3853 hljs.C_LINE_COMMENT_MODE,
3854 hljs.C_BLOCK_COMMENT_MODE,
3855 {
3856 className: 'meta',
3857 begin: '#', end: '$',
3858 keywords: {
3859 'meta-keyword': 'if else elif endif define undef warning error line region endregion pragma checksum'
3860 }
3861 },
3862 STRING,
3863 NUMBERS,
3864 {
3865 beginKeywords: 'class interface',
3866 relevance: 0,
3867 end: /[{;=]/,
3868 illegal: /[^\s:,]/,
3869 contains: [
3870 { beginKeywords: "where class" },
3871 TITLE_MODE,
3872 GENERIC_MODIFIER,
3873 hljs.C_LINE_COMMENT_MODE,
3874 hljs.C_BLOCK_COMMENT_MODE
3875 ]
3876 },
3877 {
3878 beginKeywords: 'namespace',
3879 relevance: 0,
3880 end: /[{;=]/,
3881 illegal: /[^\s:]/,
3882 contains: [
3883 TITLE_MODE,
3884 hljs.C_LINE_COMMENT_MODE,
3885 hljs.C_BLOCK_COMMENT_MODE
3886 ]
3887 },
3888 {
3889 beginKeywords: 'record',
3890 relevance: 0,
3891 end: /[{;=]/,
3892 illegal: /[^\s:]/,
3893 contains: [
3894 TITLE_MODE,
3895 GENERIC_MODIFIER,
3896 hljs.C_LINE_COMMENT_MODE,
3897 hljs.C_BLOCK_COMMENT_MODE
3898 ]
3899 },
3900 {
3901 // [Attributes("")]
3902 className: 'meta',
3903 begin: '^\\s*\\[', excludeBegin: true, end: '\\]', excludeEnd: true,
3904 contains: [
3905 {className: 'meta-string', begin: /"/, end: /"/}
3906 ]
3907 },
3908 {
3909 // Expression keywords prevent 'keyword Name(...)' from being
3910 // recognized as a function definition
3911 beginKeywords: 'new return throw await else',
3912 relevance: 0
3913 },
3914 {
3915 className: 'function',
3916 begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', returnBegin: true,
3917 end: /\s*[{;=]/, excludeEnd: true,
3918 keywords: KEYWORDS,
3919 contains: [
3920 // prevents these from being highlighted `title`
3921 {
3922 beginKeywords: FUNCTION_MODIFIERS.join(" "),
3923 relevance: 0
3924 },
3925 {
3926 begin: hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', returnBegin: true,
3927 contains: [
3928 hljs.TITLE_MODE,
3929 GENERIC_MODIFIER
3930 ],
3931 relevance: 0
3932 },
3933 {
3934 className: 'params',
3935 begin: /\(/, end: /\)/,
3936 excludeBegin: true,
3937 excludeEnd: true,
3938 keywords: KEYWORDS,
3939 relevance: 0,
3940 contains: [
3941 STRING,
3942 NUMBERS,
3943 hljs.C_BLOCK_COMMENT_MODE
3944 ]
3945 },
3946 hljs.C_LINE_COMMENT_MODE,
3947 hljs.C_BLOCK_COMMENT_MODE
3948 ]
3949 },
3950 AT_IDENTIFIER
3951 ]
3952 };
3953 }
3954
3955 return csharp;
3956
3957 return module.exports.definer || module.exports;
3958
3959}());
3960
3961hljs.registerLanguage('css', function () {
3962 'use strict';
3963
3964 /*
3965 Language: CSS
3966 Category: common, css
3967 Website: https://developer.mozilla.org/en-US/docs/Web/CSS
3968 */
3969
3970 /** @type LanguageFn */
3971 function css(hljs) {
3972 var FUNCTION_LIKE = {
3973 begin: /[\w-]+\(/, returnBegin: true,
3974 contains: [
3975 {
3976 className: 'built_in',
3977 begin: /[\w-]+/
3978 },
3979 {
3980 begin: /\(/, end: /\)/,
3981 contains: [
3982 hljs.APOS_STRING_MODE,
3983 hljs.QUOTE_STRING_MODE,
3984 hljs.CSS_NUMBER_MODE,
3985 ]
3986 }
3987 ]
3988 };
3989 var ATTRIBUTE = {
3990 className: 'attribute',
3991 begin: /\S/, end: ':', excludeEnd: true,
3992 starts: {
3993 endsWithParent: true, excludeEnd: true,
3994 contains: [
3995 FUNCTION_LIKE,
3996 hljs.CSS_NUMBER_MODE,
3997 hljs.QUOTE_STRING_MODE,
3998 hljs.APOS_STRING_MODE,
3999 hljs.C_BLOCK_COMMENT_MODE,
4000 {
4001 className: 'number', begin: '#[0-9A-Fa-f]+'
4002 },
4003 {
4004 className: 'meta', begin: '!important'
4005 }
4006 ]
4007 }
4008 };
4009 var AT_IDENTIFIER = '@[a-z-]+'; // @font-face
4010 var AT_MODIFIERS = "and or not only";
4011 var AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
4012 var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
4013 var RULE = {
4014 begin: /([*]\s?)?(?:[A-Z_.\-\\]+|--[a-zA-Z0-9_-]+)\s*(\/\*\*\/)?:/, returnBegin: true, end: ';', endsWithParent: true,
4015 contains: [
4016 ATTRIBUTE
4017 ]
4018 };
4019
4020 return {
4021 name: 'CSS',
4022 case_insensitive: true,
4023 illegal: /[=|'\$]/,
4024 contains: [
4025 hljs.C_BLOCK_COMMENT_MODE,
4026 {
4027 className: 'selector-id', begin: /#[A-Za-z0-9_-]+/
4028 },
4029 {
4030 className: 'selector-class', begin: '\\.' + IDENT_RE
4031 },
4032 {
4033 className: 'selector-attr',
4034 begin: /\[/, end: /\]/,
4035 illegal: '$',
4036 contains: [
4037 hljs.APOS_STRING_MODE,
4038 hljs.QUOTE_STRING_MODE,
4039 ]
4040 },
4041 {
4042 className: 'selector-pseudo',
4043 begin: /:(:)?[a-zA-Z0-9_+()"'.-]+/
4044 },
4045 // matching these here allows us to treat them more like regular CSS
4046 // rules so everything between the {} gets regular rule highlighting,
4047 // which is what we want for page and font-face
4048 {
4049 begin: '@(page|font-face)',
4050 lexemes: AT_IDENTIFIER,
4051 keywords: '@page @font-face'
4052 },
4053 {
4054 begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing
4055 // because it doesn’t let it to be parsed as
4056 // a rule set but instead drops parser into
4057 // the default mode which is how it should be.
4058 illegal: /:/, // break on Less variables @var: ...
4059 returnBegin: true,
4060 contains: [
4061 {
4062 className: 'keyword',
4063 begin: AT_PROPERTY_RE
4064 },
4065 {
4066 begin: /\s/, endsWithParent: true, excludeEnd: true,
4067 relevance: 0,
4068 keywords: AT_MODIFIERS,
4069 contains: [
4070 {
4071 begin: /[a-z-]+:/,
4072 className:"attribute"
4073 },
4074 hljs.APOS_STRING_MODE,
4075 hljs.QUOTE_STRING_MODE,
4076 hljs.CSS_NUMBER_MODE
4077 ]
4078 }
4079 ]
4080 },
4081 {
4082 className: 'selector-tag', begin: IDENT_RE,
4083 relevance: 0
4084 },
4085 {
4086 begin: /\{/, end: /\}/,
4087 illegal: /\S/,
4088 contains: [
4089 hljs.C_BLOCK_COMMENT_MODE,
4090 { begin: /;/ }, // empty ; rule
4091 RULE,
4092 ]
4093 }
4094 ]
4095 };
4096 }
4097
4098 return css;
4099
4100 return module.exports.definer || module.exports;
4101
4102}());
4103
4104hljs.registerLanguage('diff', function () {
4105 'use strict';
4106
4107 /*
4108 Language: Diff
4109 Description: Unified and context diff
4110 Author: Vasily Polovnyov <vast@whiteants.net>
4111 Website: https://www.gnu.org/software/diffutils/
4112 Category: common
4113 */
4114
4115 /** @type LanguageFn */
4116 function diff(hljs) {
4117 return {
4118 name: 'Diff',
4119 aliases: ['patch'],
4120 contains: [
4121 {
4122 className: 'meta',
4123 relevance: 10,
4124 variants: [
4125 {
4126 begin: /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/
4127 },
4128 {
4129 begin: /^\*\*\* +\d+,\d+ +\*\*\*\*$/
4130 },
4131 {
4132 begin: /^--- +\d+,\d+ +----$/
4133 }
4134 ]
4135 },
4136 {
4137 className: 'comment',
4138 variants: [
4139 {
4140 begin: /Index: /,
4141 end: /$/
4142 },
4143 {
4144 begin: /^index/,
4145 end: /$/
4146 },
4147 {
4148 begin: /={3,}/,
4149 end: /$/
4150 },
4151 {
4152 begin: /^-{3}/,
4153 end: /$/
4154 },
4155 {
4156 begin: /^\*{3} /,
4157 end: /$/
4158 },
4159 {
4160 begin: /^\+{3}/,
4161 end: /$/
4162 },
4163 {
4164 begin: /^\*{15}$/
4165 },
4166 {
4167 begin: /^diff --git/,
4168 end: /$/
4169 }
4170 ]
4171 },
4172 {
4173 className: 'addition',
4174 begin: /^\+/,
4175 end: /$/
4176 },
4177 {
4178 className: 'deletion',
4179 begin: /^-/,
4180 end: /$/
4181 },
4182 {
4183 className: 'addition',
4184 begin: /^!/,
4185 end: /$/
4186 }
4187 ]
4188 };
4189 }
4190
4191 return diff;
4192
4193 return module.exports.definer || module.exports;
4194
4195}());
4196
4197hljs.registerLanguage('go', function () {
4198 'use strict';
4199
4200 /*
4201 Language: Go
4202 Author: Stephan Kountso aka StepLg <steplg@gmail.com>
4203 Contributors: Evgeny Stepanischev <imbolk@gmail.com>
4204 Description: Google go language (golang). For info about language
4205 Website: http://golang.org/
4206 Category: common, system
4207 */
4208
4209 function go(hljs) {
4210 const GO_KEYWORDS = {
4211 keyword:
4212 'break default func interface select case map struct chan else goto package switch ' +
4213 'const fallthrough if range type continue for import return var go defer ' +
4214 'bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 ' +
4215 'uint16 uint32 uint64 int uint uintptr rune',
4216 literal:
4217 'true false iota nil',
4218 built_in:
4219 'append cap close complex copy imag len make new panic print println real recover delete'
4220 };
4221 return {
4222 name: 'Go',
4223 aliases: ['golang'],
4224 keywords: GO_KEYWORDS,
4225 illegal: '</',
4226 contains: [
4227 hljs.C_LINE_COMMENT_MODE,
4228 hljs.C_BLOCK_COMMENT_MODE,
4229 {
4230 className: 'string',
4231 variants: [
4232 hljs.QUOTE_STRING_MODE,
4233 hljs.APOS_STRING_MODE,
4234 {
4235 begin: '`',
4236 end: '`'
4237 }
4238 ]
4239 },
4240 {
4241 className: 'number',
4242 variants: [
4243 {
4244 begin: hljs.C_NUMBER_RE + '[i]',
4245 relevance: 1
4246 },
4247 hljs.C_NUMBER_MODE
4248 ]
4249 },
4250 {
4251 begin: /:=/ // relevance booster
4252 },
4253 {
4254 className: 'function',
4255 beginKeywords: 'func',
4256 end: '\\s*(\\{|$)',
4257 excludeEnd: true,
4258 contains: [
4259 hljs.TITLE_MODE,
4260 {
4261 className: 'params',
4262 begin: /\(/,
4263 end: /\)/,
4264 keywords: GO_KEYWORDS,
4265 illegal: /["']/
4266 }
4267 ]
4268 }
4269 ]
4270 };
4271 }
4272
4273 return go;
4274
4275 return module.exports.definer || module.exports;
4276
4277}());
4278
4279hljs.registerLanguage('http', function () {
4280 'use strict';
4281
4282 /*
4283 Language: HTTP
4284 Description: HTTP request and response headers with automatic body highlighting
4285 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
4286 Category: common, protocols
4287 Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
4288 */
4289
4290 function http(hljs) {
4291 var VERSION = 'HTTP/[0-9\\.]+';
4292 return {
4293 name: 'HTTP',
4294 aliases: ['https'],
4295 illegal: '\\S',
4296 contains: [
4297 {
4298 begin: '^' + VERSION, end: '$',
4299 contains: [{className: 'number', begin: '\\b\\d{3}\\b'}]
4300 },
4301 {
4302 begin: '^[A-Z]+ (.*?) ' + VERSION + '$', returnBegin: true, end: '$',
4303 contains: [
4304 {
4305 className: 'string',
4306 begin: ' ', end: ' ',
4307 excludeBegin: true, excludeEnd: true
4308 },
4309 {
4310 begin: VERSION
4311 },
4312 {
4313 className: 'keyword',
4314 begin: '[A-Z]+'
4315 }
4316 ]
4317 },
4318 {
4319 className: 'attribute',
4320 begin: '^\\w', end: ': ', excludeEnd: true,
4321 illegal: '\\n|\\s|=',
4322 starts: {end: '$', relevance: 0}
4323 },
4324 {
4325 begin: '\\n\\n',
4326 starts: {subLanguage: [], endsWithParent: true}
4327 }
4328 ]
4329 };
4330 }
4331
4332 return http;
4333
4334 return module.exports.definer || module.exports;
4335
4336}());
4337
4338hljs.registerLanguage('ini', function () {
4339 'use strict';
4340
4341 /**
4342 * @param {string} value
4343 * @returns {RegExp}
4344 * */
4345
4346 /**
4347 * @param {RegExp | string } re
4348 * @returns {string}
4349 */
4350 function source(re) {
4351 if (!re) return null;
4352 if (typeof re === "string") return re;
4353
4354 return re.source;
4355 }
4356
4357 /**
4358 * @param {RegExp | string } re
4359 * @returns {string}
4360 */
4361 function lookahead(re) {
4362 return concat('(?=', re, ')');
4363 }
4364
4365 /**
4366 * @param {...(RegExp | string) } args
4367 * @returns {string}
4368 */
4369 function concat(...args) {
4370 const joined = args.map((x) => source(x)).join("");
4371 return joined;
4372 }
4373
4374 /**
4375 * Any of the passed expresssions may match
4376 *
4377 * Creates a huge this | this | that | that match
4378 * @param {(RegExp | string)[] } args
4379 * @returns {string}
4380 */
4381 function either(...args) {
4382 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
4383 return joined;
4384 }
4385
4386 /*
4387 Language: TOML, also INI
4388 Description: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.
4389 Contributors: Guillaume Gomez <guillaume1.gomez@gmail.com>
4390 Category: common, config
4391 Website: https://github.com/toml-lang/toml
4392 */
4393
4394 function ini(hljs) {
4395 const NUMBERS = {
4396 className: 'number',
4397 relevance: 0,
4398 variants: [
4399 {
4400 begin: /([+-]+)?[\d]+_[\d_]+/
4401 },
4402 {
4403 begin: hljs.NUMBER_RE
4404 }
4405 ]
4406 };
4407 const COMMENTS = hljs.COMMENT();
4408 COMMENTS.variants = [
4409 {
4410 begin: /;/,
4411 end: /$/
4412 },
4413 {
4414 begin: /#/,
4415 end: /$/
4416 }
4417 ];
4418 const VARIABLES = {
4419 className: 'variable',
4420 variants: [
4421 {
4422 begin: /\$[\w\d"][\w\d_]*/
4423 },
4424 {
4425 begin: /\$\{(.*?)\}/
4426 }
4427 ]
4428 };
4429 const LITERALS = {
4430 className: 'literal',
4431 begin: /\bon|off|true|false|yes|no\b/
4432 };
4433 const STRINGS = {
4434 className: "string",
4435 contains: [hljs.BACKSLASH_ESCAPE],
4436 variants: [
4437 {
4438 begin: "'''",
4439 end: "'''",
4440 relevance: 10
4441 },
4442 {
4443 begin: '"""',
4444 end: '"""',
4445 relevance: 10
4446 },
4447 {
4448 begin: '"',
4449 end: '"'
4450 },
4451 {
4452 begin: "'",
4453 end: "'"
4454 }
4455 ]
4456 };
4457 const ARRAY = {
4458 begin: /\[/,
4459 end: /\]/,
4460 contains: [
4461 COMMENTS,
4462 LITERALS,
4463 VARIABLES,
4464 STRINGS,
4465 NUMBERS,
4466 'self'
4467 ],
4468 relevance: 0
4469 };
4470
4471 const BARE_KEY = /[A-Za-z0-9_-]+/;
4472 const QUOTED_KEY_DOUBLE_QUOTE = /"(\\"|[^"])*"/;
4473 const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/;
4474 const ANY_KEY = either(
4475 BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE
4476 );
4477 const DOTTED_KEY = concat(
4478 ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*',
4479 lookahead(/\s*=\s*[^#\s]/)
4480 );
4481
4482 return {
4483 name: 'TOML, also INI',
4484 aliases: ['toml'],
4485 case_insensitive: true,
4486 illegal: /\S/,
4487 contains: [
4488 COMMENTS,
4489 {
4490 className: 'section',
4491 begin: /\[+/,
4492 end: /\]+/
4493 },
4494 {
4495 begin: DOTTED_KEY,
4496 className: 'attr',
4497 starts: {
4498 end: /$/,
4499 contains: [
4500 COMMENTS,
4501 ARRAY,
4502 LITERALS,
4503 VARIABLES,
4504 STRINGS,
4505 NUMBERS
4506 ]
4507 }
4508 }
4509 ]
4510 };
4511 }
4512
4513 return ini;
4514
4515 return module.exports.definer || module.exports;
4516
4517}());
4518
4519hljs.registerLanguage('java', function () {
4520 'use strict';
4521
4522 // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10
4523 var decimalDigits = '[0-9](_*[0-9])*';
4524 var frac = `\\.(${decimalDigits})`;
4525 var hexDigits = '[0-9a-fA-F](_*[0-9a-fA-F])*';
4526 var NUMERIC = {
4527 className: 'number',
4528 variants: [
4529 // DecimalFloatingPointLiteral
4530 // including ExponentPart
4531 { begin: `(\\b(${decimalDigits})((${frac})|\\.)?|(${frac}))` +
4532 `[eE][+-]?(${decimalDigits})[fFdD]?\\b` },
4533 // excluding ExponentPart
4534 { begin: `\\b(${decimalDigits})((${frac})[fFdD]?\\b|\\.([fFdD]\\b)?)` },
4535 { begin: `(${frac})[fFdD]?\\b` },
4536 { begin: `\\b(${decimalDigits})[fFdD]\\b` },
4537
4538 // HexadecimalFloatingPointLiteral
4539 { begin: `\\b0[xX]((${hexDigits})\\.?|(${hexDigits})?\\.(${hexDigits}))` +
4540 `[pP][+-]?(${decimalDigits})[fFdD]?\\b` },
4541
4542 // DecimalIntegerLiteral
4543 { begin: '\\b(0|[1-9](_*[0-9])*)[lL]?\\b' },
4544
4545 // HexIntegerLiteral
4546 { begin: `\\b0[xX](${hexDigits})[lL]?\\b` },
4547
4548 // OctalIntegerLiteral
4549 { begin: '\\b0(_*[0-7])*[lL]?\\b' },
4550
4551 // BinaryIntegerLiteral
4552 { begin: '\\b0[bB][01](_*[01])*[lL]?\\b' },
4553 ],
4554 relevance: 0
4555 };
4556
4557 /*
4558 Language: Java
4559 Author: Vsevolod Solovyov <vsevolod.solovyov@gmail.com>
4560 Category: common, enterprise
4561 Website: https://www.java.com/
4562 */
4563
4564 function java(hljs) {
4565 var JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*';
4566 var GENERIC_IDENT_RE = JAVA_IDENT_RE + '(<' + JAVA_IDENT_RE + '(\\s*,\\s*' + JAVA_IDENT_RE + ')*>)?';
4567 var KEYWORDS = 'false synchronized int abstract float private char boolean var static null if const ' +
4568 'for true while long strictfp finally protected import native final void ' +
4569 'enum else break transient catch instanceof byte super volatile case assert short ' +
4570 'package default double public try this switch continue throws protected public private ' +
4571 'module requires exports do';
4572
4573 var ANNOTATION = {
4574 className: 'meta',
4575 begin: '@' + JAVA_IDENT_RE,
4576 contains: [
4577 {
4578 begin: /\(/,
4579 end: /\)/,
4580 contains: ["self"] // allow nested () inside our annotation
4581 },
4582 ]
4583 };
4584 const NUMBER = NUMERIC;
4585
4586 return {
4587 name: 'Java',
4588 aliases: ['jsp'],
4589 keywords: KEYWORDS,
4590 illegal: /<\/|#/,
4591 contains: [
4592 hljs.COMMENT(
4593 '/\\*\\*',
4594 '\\*/',
4595 {
4596 relevance: 0,
4597 contains: [
4598 {
4599 // eat up @'s in emails to prevent them to be recognized as doctags
4600 begin: /\w+@/, relevance: 0
4601 },
4602 {
4603 className: 'doctag',
4604 begin: '@[A-Za-z]+'
4605 }
4606 ]
4607 }
4608 ),
4609 // relevance boost
4610 {
4611 begin: /import java\.[a-z]+\./,
4612 keywords: "import",
4613 relevance: 2
4614 },
4615 hljs.C_LINE_COMMENT_MODE,
4616 hljs.C_BLOCK_COMMENT_MODE,
4617 hljs.APOS_STRING_MODE,
4618 hljs.QUOTE_STRING_MODE,
4619 {
4620 className: 'class',
4621 beginKeywords: 'class interface enum', end: /[{;=]/, excludeEnd: true,
4622 keywords: 'class interface enum',
4623 illegal: /[:"\[\]]/,
4624 contains: [
4625 { beginKeywords: 'extends implements' },
4626 hljs.UNDERSCORE_TITLE_MODE
4627 ]
4628 },
4629 {
4630 // Expression keywords prevent 'keyword Name(...)' from being
4631 // recognized as a function definition
4632 beginKeywords: 'new throw return else',
4633 relevance: 0
4634 },
4635 {
4636 className: 'class',
4637 begin: 'record\\s+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(',
4638 returnBegin: true,
4639 excludeEnd: true,
4640 end: /[{;=]/,
4641 keywords: KEYWORDS,
4642 contains: [
4643 { beginKeywords: "record" },
4644 {
4645 begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(',
4646 returnBegin: true,
4647 relevance: 0,
4648 contains: [hljs.UNDERSCORE_TITLE_MODE]
4649 },
4650 {
4651 className: 'params',
4652 begin: /\(/, end: /\)/,
4653 keywords: KEYWORDS,
4654 relevance: 0,
4655 contains: [
4656 hljs.C_BLOCK_COMMENT_MODE
4657 ]
4658 },
4659 hljs.C_LINE_COMMENT_MODE,
4660 hljs.C_BLOCK_COMMENT_MODE
4661 ]
4662 },
4663 {
4664 className: 'function',
4665 begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
4666 excludeEnd: true,
4667 keywords: KEYWORDS,
4668 contains: [
4669 {
4670 begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true,
4671 relevance: 0,
4672 contains: [hljs.UNDERSCORE_TITLE_MODE]
4673 },
4674 {
4675 className: 'params',
4676 begin: /\(/, end: /\)/,
4677 keywords: KEYWORDS,
4678 relevance: 0,
4679 contains: [
4680 ANNOTATION,
4681 hljs.APOS_STRING_MODE,
4682 hljs.QUOTE_STRING_MODE,
4683 NUMBER,
4684 hljs.C_BLOCK_COMMENT_MODE
4685 ]
4686 },
4687 hljs.C_LINE_COMMENT_MODE,
4688 hljs.C_BLOCK_COMMENT_MODE
4689 ]
4690 },
4691 NUMBER,
4692 ANNOTATION
4693 ]
4694 };
4695 }
4696
4697 return java;
4698
4699 return module.exports.definer || module.exports;
4700
4701}());
4702
4703hljs.registerLanguage('javascript', function () {
4704 'use strict';
4705
4706 const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
4707 const KEYWORDS = [
4708 "as", // for exports
4709 "in",
4710 "of",
4711 "if",
4712 "for",
4713 "while",
4714 "finally",
4715 "var",
4716 "new",
4717 "function",
4718 "do",
4719 "return",
4720 "void",
4721 "else",
4722 "break",
4723 "catch",
4724 "instanceof",
4725 "with",
4726 "throw",
4727 "case",
4728 "default",
4729 "try",
4730 "switch",
4731 "continue",
4732 "typeof",
4733 "delete",
4734 "let",
4735 "yield",
4736 "const",
4737 "class",
4738 // JS handles these with a special rule
4739 // "get",
4740 // "set",
4741 "debugger",
4742 "async",
4743 "await",
4744 "static",
4745 "import",
4746 "from",
4747 "export",
4748 "extends"
4749 ];
4750 const LITERALS = [
4751 "true",
4752 "false",
4753 "null",
4754 "undefined",
4755 "NaN",
4756 "Infinity"
4757 ];
4758
4759 const TYPES = [
4760 "Intl",
4761 "DataView",
4762 "Number",
4763 "Math",
4764 "Date",
4765 "String",
4766 "RegExp",
4767 "Object",
4768 "Function",
4769 "Boolean",
4770 "Error",
4771 "Symbol",
4772 "Set",
4773 "Map",
4774 "WeakSet",
4775 "WeakMap",
4776 "Proxy",
4777 "Reflect",
4778 "JSON",
4779 "Promise",
4780 "Float64Array",
4781 "Int16Array",
4782 "Int32Array",
4783 "Int8Array",
4784 "Uint16Array",
4785 "Uint32Array",
4786 "Float32Array",
4787 "Array",
4788 "Uint8Array",
4789 "Uint8ClampedArray",
4790 "ArrayBuffer"
4791 ];
4792
4793 const ERROR_TYPES = [
4794 "EvalError",
4795 "InternalError",
4796 "RangeError",
4797 "ReferenceError",
4798 "SyntaxError",
4799 "TypeError",
4800 "URIError"
4801 ];
4802
4803 const BUILT_IN_GLOBALS = [
4804 "setInterval",
4805 "setTimeout",
4806 "clearInterval",
4807 "clearTimeout",
4808
4809 "require",
4810 "exports",
4811
4812 "eval",
4813 "isFinite",
4814 "isNaN",
4815 "parseFloat",
4816 "parseInt",
4817 "decodeURI",
4818 "decodeURIComponent",
4819 "encodeURI",
4820 "encodeURIComponent",
4821 "escape",
4822 "unescape"
4823 ];
4824
4825 const BUILT_IN_VARIABLES = [
4826 "arguments",
4827 "this",
4828 "super",
4829 "console",
4830 "window",
4831 "document",
4832 "localStorage",
4833 "module",
4834 "global" // Node.js
4835 ];
4836
4837 const BUILT_INS = [].concat(
4838 BUILT_IN_GLOBALS,
4839 BUILT_IN_VARIABLES,
4840 TYPES,
4841 ERROR_TYPES
4842 );
4843
4844 /**
4845 * @param {string} value
4846 * @returns {RegExp}
4847 * */
4848
4849 /**
4850 * @param {RegExp | string } re
4851 * @returns {string}
4852 */
4853 function source(re) {
4854 if (!re) return null;
4855 if (typeof re === "string") return re;
4856
4857 return re.source;
4858 }
4859
4860 /**
4861 * @param {RegExp | string } re
4862 * @returns {string}
4863 */
4864 function lookahead(re) {
4865 return concat('(?=', re, ')');
4866 }
4867
4868 /**
4869 * @param {...(RegExp | string) } args
4870 * @returns {string}
4871 */
4872 function concat(...args) {
4873 const joined = args.map((x) => source(x)).join("");
4874 return joined;
4875 }
4876
4877 /*
4878 Language: JavaScript
4879 Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
4880 Category: common, scripting
4881 Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
4882 */
4883
4884 /** @type LanguageFn */
4885 function javascript(hljs) {
4886 /**
4887 * Takes a string like "<Booger" and checks to see
4888 * if we can find a matching "</Booger" later in the
4889 * content.
4890 * @param {RegExpMatchArray} match
4891 * @param {{after:number}} param1
4892 */
4893 const hasClosingTag = (match, { after }) => {
4894 const tag = "</" + match[0].slice(1);
4895 const pos = match.input.indexOf(tag, after);
4896 return pos !== -1;
4897 };
4898
4899 const IDENT_RE$1 = IDENT_RE;
4900 const FRAGMENT = {
4901 begin: '<>',
4902 end: '</>'
4903 };
4904 const XML_TAG = {
4905 begin: /<[A-Za-z0-9\\._:-]+/,
4906 end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
4907 /**
4908 * @param {RegExpMatchArray} match
4909 * @param {CallbackResponse} response
4910 */
4911 isTrulyOpeningTag: (match, response) => {
4912 const afterMatchIndex = match[0].length + match.index;
4913 const nextChar = match.input[afterMatchIndex];
4914 // nested type?
4915 // HTML should not include another raw `<` inside a tag
4916 // But a type might: `<Array<Array<number>>`, etc.
4917 if (nextChar === "<") {
4918 response.ignoreMatch();
4919 return;
4920 }
4921 // <something>
4922 // This is now either a tag or a type.
4923 if (nextChar === ">") {
4924 // if we cannot find a matching closing tag, then we
4925 // will ignore it
4926 if (!hasClosingTag(match, { after: afterMatchIndex })) {
4927 response.ignoreMatch();
4928 }
4929 }
4930 }
4931 };
4932 const KEYWORDS$1 = {
4933 $pattern: IDENT_RE,
4934 keyword: KEYWORDS.join(" "),
4935 literal: LITERALS.join(" "),
4936 built_in: BUILT_INS.join(" ")
4937 };
4938
4939 // https://tc39.es/ecma262/#sec-literals-numeric-literals
4940 const decimalDigits = '[0-9](_?[0-9])*';
4941 const frac = `\\.(${decimalDigits})`;
4942 // DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
4943 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
4944 const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
4945 const NUMBER = {
4946 className: 'number',
4947 variants: [
4948 // DecimalLiteral
4949 { begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))` +
4950 `[eE][+-]?(${decimalDigits})\\b` },
4951 { begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
4952
4953 // DecimalBigIntegerLiteral
4954 { begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
4955
4956 // NonDecimalIntegerLiteral
4957 { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
4958 { begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
4959 { begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
4960
4961 // LegacyOctalIntegerLiteral (does not include underscore separators)
4962 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
4963 { begin: "\\b0[0-7]+n?\\b" },
4964 ],
4965 relevance: 0
4966 };
4967
4968 const SUBST = {
4969 className: 'subst',
4970 begin: '\\$\\{',
4971 end: '\\}',
4972 keywords: KEYWORDS$1,
4973 contains: [] // defined later
4974 };
4975 const HTML_TEMPLATE = {
4976 begin: 'html`',
4977 end: '',
4978 starts: {
4979 end: '`',
4980 returnEnd: false,
4981 contains: [
4982 hljs.BACKSLASH_ESCAPE,
4983 SUBST
4984 ],
4985 subLanguage: 'xml'
4986 }
4987 };
4988 const CSS_TEMPLATE = {
4989 begin: 'css`',
4990 end: '',
4991 starts: {
4992 end: '`',
4993 returnEnd: false,
4994 contains: [
4995 hljs.BACKSLASH_ESCAPE,
4996 SUBST
4997 ],
4998 subLanguage: 'css'
4999 }
5000 };
5001 const TEMPLATE_STRING = {
5002 className: 'string',
5003 begin: '`',
5004 end: '`',
5005 contains: [
5006 hljs.BACKSLASH_ESCAPE,
5007 SUBST
5008 ]
5009 };
5010 const JSDOC_COMMENT = hljs.COMMENT(
5011 '/\\*\\*',
5012 '\\*/',
5013 {
5014 relevance: 0,
5015 contains: [
5016 {
5017 className: 'doctag',
5018 begin: '@[A-Za-z]+',
5019 contains: [
5020 {
5021 className: 'type',
5022 begin: '\\{',
5023 end: '\\}',
5024 relevance: 0
5025 },
5026 {
5027 className: 'variable',
5028 begin: IDENT_RE$1 + '(?=\\s*(-)|$)',
5029 endsParent: true,
5030 relevance: 0
5031 },
5032 // eat spaces (not newlines) so we can find
5033 // types or variables
5034 {
5035 begin: /(?=[^\n])\s/,
5036 relevance: 0
5037 }
5038 ]
5039 }
5040 ]
5041 }
5042 );
5043 const COMMENT = {
5044 className: "comment",
5045 variants: [
5046 JSDOC_COMMENT,
5047 hljs.C_BLOCK_COMMENT_MODE,
5048 hljs.C_LINE_COMMENT_MODE
5049 ]
5050 };
5051 const SUBST_INTERNALS = [
5052 hljs.APOS_STRING_MODE,
5053 hljs.QUOTE_STRING_MODE,
5054 HTML_TEMPLATE,
5055 CSS_TEMPLATE,
5056 TEMPLATE_STRING,
5057 NUMBER,
5058 hljs.REGEXP_MODE
5059 ];
5060 SUBST.contains = SUBST_INTERNALS
5061 .concat({
5062 // we need to pair up {} inside our subst to prevent
5063 // it from ending too early by matching another }
5064 begin: /\{/,
5065 end: /\}/,
5066 keywords: KEYWORDS$1,
5067 contains: [
5068 "self"
5069 ].concat(SUBST_INTERNALS)
5070 });
5071 const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
5072 const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
5073 // eat recursive parens in sub expressions
5074 {
5075 begin: /\(/,
5076 end: /\)/,
5077 keywords: KEYWORDS$1,
5078 contains: ["self"].concat(SUBST_AND_COMMENTS)
5079 }
5080 ]);
5081 const PARAMS = {
5082 className: 'params',
5083 begin: /\(/,
5084 end: /\)/,
5085 excludeBegin: true,
5086 excludeEnd: true,
5087 keywords: KEYWORDS$1,
5088 contains: PARAMS_CONTAINS
5089 };
5090
5091 return {
5092 name: 'Javascript',
5093 aliases: ['js', 'jsx', 'mjs', 'cjs'],
5094 keywords: KEYWORDS$1,
5095 // this will be extended by TypeScript
5096 exports: { PARAMS_CONTAINS },
5097 illegal: /#(?![$_A-z])/,
5098 contains: [
5099 hljs.SHEBANG({
5100 label: "shebang",
5101 binary: "node",
5102 relevance: 5
5103 }),
5104 {
5105 label: "use_strict",
5106 className: 'meta',
5107 relevance: 10,
5108 begin: /^\s*['"]use (strict|asm)['"]/
5109 },
5110 hljs.APOS_STRING_MODE,
5111 hljs.QUOTE_STRING_MODE,
5112 HTML_TEMPLATE,
5113 CSS_TEMPLATE,
5114 TEMPLATE_STRING,
5115 COMMENT,
5116 NUMBER,
5117 { // object attr container
5118 begin: concat(/[{,\n]\s*/,
5119 // we need to look ahead to make sure that we actually have an
5120 // attribute coming up so we don't steal a comma from a potential
5121 // "value" container
5122 //
5123 // NOTE: this might not work how you think. We don't actually always
5124 // enter this mode and stay. Instead it might merely match `,
5125 // <comments up next>` and then immediately end after the , because it
5126 // fails to find any actual attrs. But this still does the job because
5127 // it prevents the value contain rule from grabbing this instead and
5128 // prevening this rule from firing when we actually DO have keys.
5129 lookahead(concat(
5130 // we also need to allow for multiple possible comments inbetween
5131 // the first key:value pairing
5132 /(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,
5133 IDENT_RE$1 + '\\s*:'))),
5134 relevance: 0,
5135 contains: [
5136 {
5137 className: 'attr',
5138 begin: IDENT_RE$1 + lookahead('\\s*:'),
5139 relevance: 0
5140 }
5141 ]
5142 },
5143 { // "value" container
5144 begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
5145 keywords: 'return throw case',
5146 contains: [
5147 COMMENT,
5148 hljs.REGEXP_MODE,
5149 {
5150 className: 'function',
5151 // we have to count the parens to make sure we actually have the
5152 // correct bounding ( ) before the =>. There could be any number of
5153 // sub-expressions inside also surrounded by parens.
5154 begin: '(\\(' +
5155 '[^()]*(\\(' +
5156 '[^()]*(\\(' +
5157 '[^()]*' +
5158 '\\)[^()]*)*' +
5159 '\\)[^()]*)*' +
5160 '\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>',
5161 returnBegin: true,
5162 end: '\\s*=>',
5163 contains: [
5164 {
5165 className: 'params',
5166 variants: [
5167 {
5168 begin: hljs.UNDERSCORE_IDENT_RE,
5169 relevance: 0
5170 },
5171 {
5172 className: null,
5173 begin: /\(\s*\)/,
5174 skip: true
5175 },
5176 {
5177 begin: /\(/,
5178 end: /\)/,
5179 excludeBegin: true,
5180 excludeEnd: true,
5181 keywords: KEYWORDS$1,
5182 contains: PARAMS_CONTAINS
5183 }
5184 ]
5185 }
5186 ]
5187 },
5188 { // could be a comma delimited list of params to a function call
5189 begin: /,/, relevance: 0
5190 },
5191 {
5192 className: '',
5193 begin: /\s/,
5194 end: /\s*/,
5195 skip: true
5196 },
5197 { // JSX
5198 variants: [
5199 { begin: FRAGMENT.begin, end: FRAGMENT.end },
5200 {
5201 begin: XML_TAG.begin,
5202 // we carefully check the opening tag to see if it truly
5203 // is a tag and not a false positive
5204 'on:begin': XML_TAG.isTrulyOpeningTag,
5205 end: XML_TAG.end
5206 }
5207 ],
5208 subLanguage: 'xml',
5209 contains: [
5210 {
5211 begin: XML_TAG.begin,
5212 end: XML_TAG.end,
5213 skip: true,
5214 contains: ['self']
5215 }
5216 ]
5217 }
5218 ],
5219 relevance: 0
5220 },
5221 {
5222 className: 'function',
5223 beginKeywords: 'function',
5224 end: /[{;]/,
5225 excludeEnd: true,
5226 keywords: KEYWORDS$1,
5227 contains: [
5228 'self',
5229 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5230 PARAMS
5231 ],
5232 illegal: /%/
5233 },
5234 {
5235 // prevent this from getting swallowed up by function
5236 // since they appear "function like"
5237 beginKeywords: "while if switch catch for"
5238 },
5239 {
5240 className: 'function',
5241 // we have to count the parens to make sure we actually have the correct
5242 // bounding ( ). There could be any number of sub-expressions inside
5243 // also surrounded by parens.
5244 begin: hljs.UNDERSCORE_IDENT_RE +
5245 '\\(' + // first parens
5246 '[^()]*(\\(' +
5247 '[^()]*(\\(' +
5248 '[^()]*' +
5249 '\\)[^()]*)*' +
5250 '\\)[^()]*)*' +
5251 '\\)\\s*\\{', // end parens
5252 returnBegin:true,
5253 contains: [
5254 PARAMS,
5255 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5256 ]
5257 },
5258 // hack: prevents detection of keywords in some circumstances
5259 // .keyword()
5260 // $keyword = x
5261 {
5262 variants: [
5263 { begin: '\\.' + IDENT_RE$1 },
5264 { begin: '\\$' + IDENT_RE$1 }
5265 ],
5266 relevance: 0
5267 },
5268 { // ES6 class
5269 className: 'class',
5270 beginKeywords: 'class',
5271 end: /[{;=]/,
5272 excludeEnd: true,
5273 illegal: /[:"[\]]/,
5274 contains: [
5275 { beginKeywords: 'extends' },
5276 hljs.UNDERSCORE_TITLE_MODE
5277 ]
5278 },
5279 {
5280 begin: /\b(?=constructor)/,
5281 end: /[{;]/,
5282 excludeEnd: true,
5283 contains: [
5284 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5285 'self',
5286 PARAMS
5287 ]
5288 },
5289 {
5290 begin: '(get|set)\\s+(?=' + IDENT_RE$1 + '\\()',
5291 end: /\{/,
5292 keywords: "get set",
5293 contains: [
5294 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
5295 { begin: /\(\)/ }, // eat to avoid empty params
5296 PARAMS
5297 ]
5298 },
5299 {
5300 begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
5301 }
5302 ]
5303 };
5304 }
5305
5306 return javascript;
5307
5308 return module.exports.definer || module.exports;
5309
5310}());
5311
5312hljs.registerLanguage('json', function () {
5313 'use strict';
5314
5315 /*
5316 Language: JSON
5317 Description: JSON (JavaScript Object Notation) is a lightweight data-interchange format.
5318 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
5319 Website: http://www.json.org
5320 Category: common, protocols
5321 */
5322
5323 function json(hljs) {
5324 const LITERALS = {
5325 literal: 'true false null'
5326 };
5327 const ALLOWED_COMMENTS = [
5328 hljs.C_LINE_COMMENT_MODE,
5329 hljs.C_BLOCK_COMMENT_MODE
5330 ];
5331 const TYPES = [
5332 hljs.QUOTE_STRING_MODE,
5333 hljs.C_NUMBER_MODE
5334 ];
5335 const VALUE_CONTAINER = {
5336 end: ',',
5337 endsWithParent: true,
5338 excludeEnd: true,
5339 contains: TYPES,
5340 keywords: LITERALS
5341 };
5342 const OBJECT = {
5343 begin: /\{/,
5344 end: /\}/,
5345 contains: [
5346 {
5347 className: 'attr',
5348 begin: /"/,
5349 end: /"/,
5350 contains: [hljs.BACKSLASH_ESCAPE],
5351 illegal: '\\n'
5352 },
5353 hljs.inherit(VALUE_CONTAINER, {
5354 begin: /:/
5355 })
5356 ].concat(ALLOWED_COMMENTS),
5357 illegal: '\\S'
5358 };
5359 const ARRAY = {
5360 begin: '\\[',
5361 end: '\\]',
5362 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
5363 illegal: '\\S'
5364 };
5365 TYPES.push(OBJECT, ARRAY);
5366 ALLOWED_COMMENTS.forEach(function(rule) {
5367 TYPES.push(rule);
5368 });
5369 return {
5370 name: 'JSON',
5371 contains: TYPES,
5372 keywords: LITERALS,
5373 illegal: '\\S'
5374 };
5375 }
5376
5377 return json;
5378
5379 return module.exports.definer || module.exports;
5380
5381}());
5382
5383hljs.registerLanguage('kotlin', function () {
5384 'use strict';
5385
5386 // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10
5387 var decimalDigits = '[0-9](_*[0-9])*';
5388 var frac = `\\.(${decimalDigits})`;
5389 var hexDigits = '[0-9a-fA-F](_*[0-9a-fA-F])*';
5390 var NUMERIC = {
5391 className: 'number',
5392 variants: [
5393 // DecimalFloatingPointLiteral
5394 // including ExponentPart
5395 { begin: `(\\b(${decimalDigits})((${frac})|\\.)?|(${frac}))` +
5396 `[eE][+-]?(${decimalDigits})[fFdD]?\\b` },
5397 // excluding ExponentPart
5398 { begin: `\\b(${decimalDigits})((${frac})[fFdD]?\\b|\\.([fFdD]\\b)?)` },
5399 { begin: `(${frac})[fFdD]?\\b` },
5400 { begin: `\\b(${decimalDigits})[fFdD]\\b` },
5401
5402 // HexadecimalFloatingPointLiteral
5403 { begin: `\\b0[xX]((${hexDigits})\\.?|(${hexDigits})?\\.(${hexDigits}))` +
5404 `[pP][+-]?(${decimalDigits})[fFdD]?\\b` },
5405
5406 // DecimalIntegerLiteral
5407 { begin: '\\b(0|[1-9](_*[0-9])*)[lL]?\\b' },
5408
5409 // HexIntegerLiteral
5410 { begin: `\\b0[xX](${hexDigits})[lL]?\\b` },
5411
5412 // OctalIntegerLiteral
5413 { begin: '\\b0(_*[0-7])*[lL]?\\b' },
5414
5415 // BinaryIntegerLiteral
5416 { begin: '\\b0[bB][01](_*[01])*[lL]?\\b' },
5417 ],
5418 relevance: 0
5419 };
5420
5421 /*
5422 Language: Kotlin
5423 Description: Kotlin is an OSS statically typed programming language that targets the JVM, Android, JavaScript and Native.
5424 Author: Sergey Mashkov <cy6erGn0m@gmail.com>
5425 Website: https://kotlinlang.org
5426 Category: common
5427 */
5428
5429 function kotlin(hljs) {
5430 const KEYWORDS = {
5431 keyword:
5432 'abstract as val var vararg get set class object open private protected public noinline ' +
5433 'crossinline dynamic final enum if else do while for when throw try catch finally ' +
5434 'import package is in fun override companion reified inline lateinit init ' +
5435 'interface annotation data sealed internal infix operator out by constructor super ' +
5436 'tailrec where const inner suspend typealias external expect actual',
5437 built_in:
5438 'Byte Short Char Int Long Boolean Float Double Void Unit Nothing',
5439 literal:
5440 'true false null'
5441 };
5442 const KEYWORDS_WITH_LABEL = {
5443 className: 'keyword',
5444 begin: /\b(break|continue|return|this)\b/,
5445 starts: {
5446 contains: [
5447 {
5448 className: 'symbol',
5449 begin: /@\w+/
5450 }
5451 ]
5452 }
5453 };
5454 const LABEL = {
5455 className: 'symbol',
5456 begin: hljs.UNDERSCORE_IDENT_RE + '@'
5457 };
5458
5459 // for string templates
5460 const SUBST = {
5461 className: 'subst',
5462 begin: /\$\{/,
5463 end: /\}/,
5464 contains: [ hljs.C_NUMBER_MODE ]
5465 };
5466 const VARIABLE = {
5467 className: 'variable',
5468 begin: '\\$' + hljs.UNDERSCORE_IDENT_RE
5469 };
5470 const STRING = {
5471 className: 'string',
5472 variants: [
5473 {
5474 begin: '"""',
5475 end: '"""(?=[^"])',
5476 contains: [
5477 VARIABLE,
5478 SUBST
5479 ]
5480 },
5481 // Can't use built-in modes easily, as we want to use STRING in the meta
5482 // context as 'meta-string' and there's no syntax to remove explicitly set
5483 // classNames in built-in modes.
5484 {
5485 begin: '\'',
5486 end: '\'',
5487 illegal: /\n/,
5488 contains: [ hljs.BACKSLASH_ESCAPE ]
5489 },
5490 {
5491 begin: '"',
5492 end: '"',
5493 illegal: /\n/,
5494 contains: [
5495 hljs.BACKSLASH_ESCAPE,
5496 VARIABLE,
5497 SUBST
5498 ]
5499 }
5500 ]
5501 };
5502 SUBST.contains.push(STRING);
5503
5504 const ANNOTATION_USE_SITE = {
5505 className: 'meta',
5506 begin: '@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*' + hljs.UNDERSCORE_IDENT_RE + ')?'
5507 };
5508 const ANNOTATION = {
5509 className: 'meta',
5510 begin: '@' + hljs.UNDERSCORE_IDENT_RE,
5511 contains: [
5512 {
5513 begin: /\(/,
5514 end: /\)/,
5515 contains: [
5516 hljs.inherit(STRING, {
5517 className: 'meta-string'
5518 })
5519 ]
5520 }
5521 ]
5522 };
5523
5524 // https://kotlinlang.org/docs/reference/whatsnew11.html#underscores-in-numeric-literals
5525 // According to the doc above, the number mode of kotlin is the same as java 8,
5526 // so the code below is copied from java.js
5527 const KOTLIN_NUMBER_MODE = NUMERIC;
5528 const KOTLIN_NESTED_COMMENT = hljs.COMMENT(
5529 '/\\*', '\\*/',
5530 {
5531 contains: [ hljs.C_BLOCK_COMMENT_MODE ]
5532 }
5533 );
5534 const KOTLIN_PAREN_TYPE = {
5535 variants: [
5536 {
5537 className: 'type',
5538 begin: hljs.UNDERSCORE_IDENT_RE
5539 },
5540 {
5541 begin: /\(/,
5542 end: /\)/,
5543 contains: [] // defined later
5544 }
5545 ]
5546 };
5547 const KOTLIN_PAREN_TYPE2 = KOTLIN_PAREN_TYPE;
5548 KOTLIN_PAREN_TYPE2.variants[1].contains = [ KOTLIN_PAREN_TYPE ];
5549 KOTLIN_PAREN_TYPE.variants[1].contains = [ KOTLIN_PAREN_TYPE2 ];
5550
5551 return {
5552 name: 'Kotlin',
5553 aliases: [ 'kt' ],
5554 keywords: KEYWORDS,
5555 contains: [
5556 hljs.COMMENT(
5557 '/\\*\\*',
5558 '\\*/',
5559 {
5560 relevance: 0,
5561 contains: [
5562 {
5563 className: 'doctag',
5564 begin: '@[A-Za-z]+'
5565 }
5566 ]
5567 }
5568 ),
5569 hljs.C_LINE_COMMENT_MODE,
5570 KOTLIN_NESTED_COMMENT,
5571 KEYWORDS_WITH_LABEL,
5572 LABEL,
5573 ANNOTATION_USE_SITE,
5574 ANNOTATION,
5575 {
5576 className: 'function',
5577 beginKeywords: 'fun',
5578 end: '[(]|$',
5579 returnBegin: true,
5580 excludeEnd: true,
5581 keywords: KEYWORDS,
5582 relevance: 5,
5583 contains: [
5584 {
5585 begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(',
5586 returnBegin: true,
5587 relevance: 0,
5588 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
5589 },
5590 {
5591 className: 'type',
5592 begin: /</,
5593 end: />/,
5594 keywords: 'reified',
5595 relevance: 0
5596 },
5597 {
5598 className: 'params',
5599 begin: /\(/,
5600 end: /\)/,
5601 endsParent: true,
5602 keywords: KEYWORDS,
5603 relevance: 0,
5604 contains: [
5605 {
5606 begin: /:/,
5607 end: /[=,\/]/,
5608 endsWithParent: true,
5609 contains: [
5610 KOTLIN_PAREN_TYPE,
5611 hljs.C_LINE_COMMENT_MODE,
5612 KOTLIN_NESTED_COMMENT
5613 ],
5614 relevance: 0
5615 },
5616 hljs.C_LINE_COMMENT_MODE,
5617 KOTLIN_NESTED_COMMENT,
5618 ANNOTATION_USE_SITE,
5619 ANNOTATION,
5620 STRING,
5621 hljs.C_NUMBER_MODE
5622 ]
5623 },
5624 KOTLIN_NESTED_COMMENT
5625 ]
5626 },
5627 {
5628 className: 'class',
5629 beginKeywords: 'class interface trait', // remove 'trait' when removed from KEYWORDS
5630 end: /[:\{(]|$/,
5631 excludeEnd: true,
5632 illegal: 'extends implements',
5633 contains: [
5634 {
5635 beginKeywords: 'public protected internal private constructor'
5636 },
5637 hljs.UNDERSCORE_TITLE_MODE,
5638 {
5639 className: 'type',
5640 begin: /</,
5641 end: />/,
5642 excludeBegin: true,
5643 excludeEnd: true,
5644 relevance: 0
5645 },
5646 {
5647 className: 'type',
5648 begin: /[,:]\s*/,
5649 end: /[<\(,]|$/,
5650 excludeBegin: true,
5651 returnEnd: true
5652 },
5653 ANNOTATION_USE_SITE,
5654 ANNOTATION
5655 ]
5656 },
5657 STRING,
5658 {
5659 className: 'meta',
5660 begin: "^#!/usr/bin/env",
5661 end: '$',
5662 illegal: '\n'
5663 },
5664 KOTLIN_NUMBER_MODE
5665 ]
5666 };
5667 }
5668
5669 return kotlin;
5670
5671 return module.exports.definer || module.exports;
5672
5673}());
5674
5675hljs.registerLanguage('less', function () {
5676 'use strict';
5677
5678 /*
5679 Language: Less
5680 Description: It's CSS, with just a little more.
5681 Author: Max Mikhailov <seven.phases.max@gmail.com>
5682 Website: http://lesscss.org
5683 Category: common, css
5684 */
5685
5686 function less(hljs) {
5687 var IDENT_RE = '[\\w-]+'; // yes, Less identifiers may begin with a digit
5688 var INTERP_IDENT_RE = '(' + IDENT_RE + '|@\\{' + IDENT_RE + '\\})';
5689
5690 /* Generic Modes */
5691
5692 var RULES = [], VALUE = []; // forward def. for recursive modes
5693
5694 var STRING_MODE = function(c) { return {
5695 // Less strings are not multiline (also include '~' for more consistent coloring of "escaped" strings)
5696 className: 'string', begin: '~?' + c + '.*?' + c
5697 };};
5698
5699 var IDENT_MODE = function(name, begin, relevance) { return {
5700 className: name, begin: begin, relevance: relevance
5701 };};
5702
5703 var PARENS_MODE = {
5704 // used only to properly balance nested parens inside mixin call, def. arg list
5705 begin: '\\(', end: '\\)', contains: VALUE, relevance: 0
5706 };
5707
5708 // generic Less highlighter (used almost everywhere except selectors):
5709 VALUE.push(
5710 hljs.C_LINE_COMMENT_MODE,
5711 hljs.C_BLOCK_COMMENT_MODE,
5712 STRING_MODE("'"),
5713 STRING_MODE('"'),
5714 hljs.CSS_NUMBER_MODE, // fixme: it does not include dot for numbers like .5em :(
5715 {
5716 begin: '(url|data-uri)\\(',
5717 starts: {className: 'string', end: '[\\)\\n]', excludeEnd: true}
5718 },
5719 IDENT_MODE('number', '#[0-9A-Fa-f]+\\b'),
5720 PARENS_MODE,
5721 IDENT_MODE('variable', '@@?' + IDENT_RE, 10),
5722 IDENT_MODE('variable', '@\\{' + IDENT_RE + '\\}'),
5723 IDENT_MODE('built_in', '~?`[^`]*?`'), // inline javascript (or whatever host language) *multiline* string
5724 { // @media features (it’s here to not duplicate things in AT_RULE_MODE with extra PARENS_MODE overriding):
5725 className: 'attribute', begin: IDENT_RE + '\\s*:', end: ':', returnBegin: true, excludeEnd: true
5726 },
5727 {
5728 className: 'meta',
5729 begin: '!important'
5730 }
5731 );
5732
5733 var VALUE_WITH_RULESETS = VALUE.concat({
5734 begin: /\{/, end: /\}/, contains: RULES
5735 });
5736
5737 var MIXIN_GUARD_MODE = {
5738 beginKeywords: 'when', endsWithParent: true,
5739 contains: [{beginKeywords: 'and not'}].concat(VALUE) // using this form to override VALUE’s 'function' match
5740 };
5741
5742 /* Rule-Level Modes */
5743
5744 var RULE_MODE = {
5745 begin: INTERP_IDENT_RE + '\\s*:', returnBegin: true, end: '[;}]',
5746 relevance: 0,
5747 contains: [
5748 {
5749 className: 'attribute',
5750 begin: INTERP_IDENT_RE, end: ':', excludeEnd: true,
5751 starts: {
5752 endsWithParent: true, illegal: '[<=$]',
5753 relevance: 0,
5754 contains: VALUE
5755 }
5756 }
5757 ]
5758 };
5759
5760 var AT_RULE_MODE = {
5761 className: 'keyword',
5762 begin: '@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b',
5763 starts: {end: '[;{}]', returnEnd: true, contains: VALUE, relevance: 0}
5764 };
5765
5766 // variable definitions and calls
5767 var VAR_RULE_MODE = {
5768 className: 'variable',
5769 variants: [
5770 // using more strict pattern for higher relevance to increase chances of Less detection.
5771 // this is *the only* Less specific statement used in most of the sources, so...
5772 // (we’ll still often loose to the css-parser unless there's '//' comment,
5773 // simply because 1 variable just can't beat 99 properties :)
5774 {begin: '@' + IDENT_RE + '\\s*:', relevance: 15},
5775 {begin: '@' + IDENT_RE}
5776 ],
5777 starts: {end: '[;}]', returnEnd: true, contains: VALUE_WITH_RULESETS}
5778 };
5779
5780 var SELECTOR_MODE = {
5781 // first parse unambiguous selectors (i.e. those not starting with tag)
5782 // then fall into the scary lookahead-discriminator variant.
5783 // this mode also handles mixin definitions and calls
5784 variants: [{
5785 begin: '[\\.#:&\\[>]', end: '[;{}]' // mixin calls end with ';'
5786 }, {
5787 begin: INTERP_IDENT_RE, end: /\{/
5788 }],
5789 returnBegin: true,
5790 returnEnd: true,
5791 illegal: '[<=\'$"]',
5792 relevance: 0,
5793 contains: [
5794 hljs.C_LINE_COMMENT_MODE,
5795 hljs.C_BLOCK_COMMENT_MODE,
5796 MIXIN_GUARD_MODE,
5797 IDENT_MODE('keyword', 'all\\b'),
5798 IDENT_MODE('variable', '@\\{' + IDENT_RE + '\\}'), // otherwise it’s identified as tag
5799 IDENT_MODE('selector-tag', INTERP_IDENT_RE + '%?', 0), // '%' for more consistent coloring of @keyframes "tags"
5800 IDENT_MODE('selector-id', '#' + INTERP_IDENT_RE),
5801 IDENT_MODE('selector-class', '\\.' + INTERP_IDENT_RE, 0),
5802 IDENT_MODE('selector-tag', '&', 0),
5803 {className: 'selector-attr', begin: '\\[', end: '\\]'},
5804 {className: 'selector-pseudo', begin: /:(:)?[a-zA-Z0-9_\-+()"'.]+/},
5805 {begin: '\\(', end: '\\)', contains: VALUE_WITH_RULESETS}, // argument list of parametric mixins
5806 {begin: '!important'} // eat !important after mixin call or it will be colored as tag
5807 ]
5808 };
5809
5810 RULES.push(
5811 hljs.C_LINE_COMMENT_MODE,
5812 hljs.C_BLOCK_COMMENT_MODE,
5813 AT_RULE_MODE,
5814 VAR_RULE_MODE,
5815 RULE_MODE,
5816 SELECTOR_MODE
5817 );
5818
5819 return {
5820 name: 'Less',
5821 case_insensitive: true,
5822 illegal: '[=>\'/<($"]',
5823 contains: RULES
5824 };
5825 }
5826
5827 return less;
5828
5829 return module.exports.definer || module.exports;
5830
5831}());
5832
5833hljs.registerLanguage('lua', function () {
5834 'use strict';
5835
5836 /*
5837 Language: Lua
5838 Description: Lua is a powerful, efficient, lightweight, embeddable scripting language.
5839 Author: Andrew Fedorov <dmmdrs@mail.ru>
5840 Category: common, scripting
5841 Website: https://www.lua.org
5842 */
5843
5844 function lua(hljs) {
5845 const OPENING_LONG_BRACKET = '\\[=*\\[';
5846 const CLOSING_LONG_BRACKET = '\\]=*\\]';
5847 const LONG_BRACKETS = {
5848 begin: OPENING_LONG_BRACKET,
5849 end: CLOSING_LONG_BRACKET,
5850 contains: ['self']
5851 };
5852 const COMMENTS = [
5853 hljs.COMMENT('--(?!' + OPENING_LONG_BRACKET + ')', '$'),
5854 hljs.COMMENT(
5855 '--' + OPENING_LONG_BRACKET,
5856 CLOSING_LONG_BRACKET,
5857 {
5858 contains: [LONG_BRACKETS],
5859 relevance: 10
5860 }
5861 )
5862 ];
5863 return {
5864 name: 'Lua',
5865 keywords: {
5866 $pattern: hljs.UNDERSCORE_IDENT_RE,
5867 literal: "true false nil",
5868 keyword: "and break do else elseif end for goto if in local not or repeat return then until while",
5869 built_in:
5870 // Metatags and globals:
5871 '_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len ' +
5872 '__gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert ' +
5873 // Standard methods and properties:
5874 'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring ' +
5875 'module next pairs pcall print rawequal rawget rawset require select setfenv ' +
5876 'setmetatable tonumber tostring type unpack xpcall arg self ' +
5877 // Library methods and properties (one line per library):
5878 'coroutine resume yield status wrap create running debug getupvalue ' +
5879 'debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv ' +
5880 'io lines write close flush open output type read stderr stdin input stdout popen tmpfile ' +
5881 '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 ' +
5882 'os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall ' +
5883 'string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower ' +
5884 'table setn insert getn foreachi maxn foreach concat sort remove'
5885 },
5886 contains: COMMENTS.concat([
5887 {
5888 className: 'function',
5889 beginKeywords: 'function',
5890 end: '\\)',
5891 contains: [
5892 hljs.inherit(hljs.TITLE_MODE, {
5893 begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*'
5894 }),
5895 {
5896 className: 'params',
5897 begin: '\\(',
5898 endsWithParent: true,
5899 contains: COMMENTS
5900 }
5901 ].concat(COMMENTS)
5902 },
5903 hljs.C_NUMBER_MODE,
5904 hljs.APOS_STRING_MODE,
5905 hljs.QUOTE_STRING_MODE,
5906 {
5907 className: 'string',
5908 begin: OPENING_LONG_BRACKET,
5909 end: CLOSING_LONG_BRACKET,
5910 contains: [LONG_BRACKETS],
5911 relevance: 5
5912 }
5913 ])
5914 };
5915 }
5916
5917 return lua;
5918
5919 return module.exports.definer || module.exports;
5920
5921}());
5922
5923hljs.registerLanguage('makefile', function () {
5924 'use strict';
5925
5926 /*
5927 Language: Makefile
5928 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
5929 Contributors: Joël Porquet <joel@porquet.org>
5930 Website: https://www.gnu.org/software/make/manual/html_node/Introduction.html
5931 Category: common
5932 */
5933
5934 function makefile(hljs) {
5935 /* Variables: simple (eg $(var)) and special (eg $@) */
5936 const VARIABLE = {
5937 className: 'variable',
5938 variants: [
5939 {
5940 begin: '\\$\\(' + hljs.UNDERSCORE_IDENT_RE + '\\)',
5941 contains: [ hljs.BACKSLASH_ESCAPE ]
5942 },
5943 {
5944 begin: /\$[@%<?\^\+\*]/
5945 }
5946 ]
5947 };
5948 /* Quoted string with variables inside */
5949 const QUOTE_STRING = {
5950 className: 'string',
5951 begin: /"/,
5952 end: /"/,
5953 contains: [
5954 hljs.BACKSLASH_ESCAPE,
5955 VARIABLE
5956 ]
5957 };
5958 /* Function: $(func arg,...) */
5959 const FUNC = {
5960 className: 'variable',
5961 begin: /\$\([\w-]+\s/,
5962 end: /\)/,
5963 keywords: {
5964 built_in:
5965 'subst patsubst strip findstring filter filter-out sort ' +
5966 'word wordlist firstword lastword dir notdir suffix basename ' +
5967 'addsuffix addprefix join wildcard realpath abspath error warning ' +
5968 'shell origin flavor foreach if or and call eval file value'
5969 },
5970 contains: [ VARIABLE ]
5971 };
5972 /* Variable assignment */
5973 const ASSIGNMENT = {
5974 begin: '^' + hljs.UNDERSCORE_IDENT_RE + '\\s*(?=[:+?]?=)'
5975 };
5976 /* Meta targets (.PHONY) */
5977 const META = {
5978 className: 'meta',
5979 begin: /^\.PHONY:/,
5980 end: /$/,
5981 keywords: {
5982 $pattern: /[\.\w]+/,
5983 'meta-keyword': '.PHONY'
5984 }
5985 };
5986 /* Targets */
5987 const TARGET = {
5988 className: 'section',
5989 begin: /^[^\s]+:/,
5990 end: /$/,
5991 contains: [ VARIABLE ]
5992 };
5993 return {
5994 name: 'Makefile',
5995 aliases: [
5996 'mk',
5997 'mak'
5998 ],
5999 keywords: {
6000 $pattern: /[\w-]+/,
6001 keyword: 'define endef undefine ifdef ifndef ifeq ifneq else endif ' +
6002 'include -include sinclude override export unexport private vpath'
6003 },
6004 contains: [
6005 hljs.HASH_COMMENT_MODE,
6006 VARIABLE,
6007 QUOTE_STRING,
6008 FUNC,
6009 ASSIGNMENT,
6010 META,
6011 TARGET
6012 ]
6013 };
6014 }
6015
6016 return makefile;
6017
6018 return module.exports.definer || module.exports;
6019
6020}());
6021
6022hljs.registerLanguage('xml', function () {
6023 'use strict';
6024
6025 /**
6026 * @param {string} value
6027 * @returns {RegExp}
6028 * */
6029
6030 /**
6031 * @param {RegExp | string } re
6032 * @returns {string}
6033 */
6034 function source(re) {
6035 if (!re) return null;
6036 if (typeof re === "string") return re;
6037
6038 return re.source;
6039 }
6040
6041 /**
6042 * @param {RegExp | string } re
6043 * @returns {string}
6044 */
6045 function lookahead(re) {
6046 return concat('(?=', re, ')');
6047 }
6048
6049 /**
6050 * @param {RegExp | string } re
6051 * @returns {string}
6052 */
6053 function optional(re) {
6054 return concat('(', re, ')?');
6055 }
6056
6057 /**
6058 * @param {...(RegExp | string) } args
6059 * @returns {string}
6060 */
6061 function concat(...args) {
6062 const joined = args.map((x) => source(x)).join("");
6063 return joined;
6064 }
6065
6066 /**
6067 * Any of the passed expresssions may match
6068 *
6069 * Creates a huge this | this | that | that match
6070 * @param {(RegExp | string)[] } args
6071 * @returns {string}
6072 */
6073 function either(...args) {
6074 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
6075 return joined;
6076 }
6077
6078 /*
6079 Language: HTML, XML
6080 Website: https://www.w3.org/XML/
6081 Category: common
6082 */
6083
6084 /** @type LanguageFn */
6085 function xml(hljs) {
6086 // Element names can contain letters, digits, hyphens, underscores, and periods
6087 const TAG_NAME_RE = concat(/[A-Z_]/, optional(/[A-Z0-9_.-]+:/), /[A-Z0-9_.-]*/);
6088 const XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
6089 const XML_ENTITIES = {
6090 className: 'symbol',
6091 begin: '&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;'
6092 };
6093 const XML_META_KEYWORDS = {
6094 begin: '\\s',
6095 contains: [
6096 {
6097 className: 'meta-keyword',
6098 begin: '#?[a-z_][a-z1-9_-]+',
6099 illegal: '\\n'
6100 }
6101 ]
6102 };
6103 const XML_META_PAR_KEYWORDS = hljs.inherit(XML_META_KEYWORDS, {
6104 begin: '\\(',
6105 end: '\\)'
6106 });
6107 const APOS_META_STRING_MODE = hljs.inherit(hljs.APOS_STRING_MODE, {
6108 className: 'meta-string'
6109 });
6110 const QUOTE_META_STRING_MODE = hljs.inherit(hljs.QUOTE_STRING_MODE, {
6111 className: 'meta-string'
6112 });
6113 const TAG_INTERNALS = {
6114 endsWithParent: true,
6115 illegal: /</,
6116 relevance: 0,
6117 contains: [
6118 {
6119 className: 'attr',
6120 begin: XML_IDENT_RE,
6121 relevance: 0
6122 },
6123 {
6124 begin: /=\s*/,
6125 relevance: 0,
6126 contains: [
6127 {
6128 className: 'string',
6129 endsParent: true,
6130 variants: [
6131 {
6132 begin: /"/,
6133 end: /"/,
6134 contains: [ XML_ENTITIES ]
6135 },
6136 {
6137 begin: /'/,
6138 end: /'/,
6139 contains: [ XML_ENTITIES ]
6140 },
6141 {
6142 begin: /[^\s"'=<>`]+/
6143 }
6144 ]
6145 }
6146 ]
6147 }
6148 ]
6149 };
6150 return {
6151 name: 'HTML, XML',
6152 aliases: [
6153 'html',
6154 'xhtml',
6155 'rss',
6156 'atom',
6157 'xjb',
6158 'xsd',
6159 'xsl',
6160 'plist',
6161 'wsf',
6162 'svg'
6163 ],
6164 case_insensitive: true,
6165 contains: [
6166 {
6167 className: 'meta',
6168 begin: '<![a-z]',
6169 end: '>',
6170 relevance: 10,
6171 contains: [
6172 XML_META_KEYWORDS,
6173 QUOTE_META_STRING_MODE,
6174 APOS_META_STRING_MODE,
6175 XML_META_PAR_KEYWORDS,
6176 {
6177 begin: '\\[',
6178 end: '\\]',
6179 contains: [
6180 {
6181 className: 'meta',
6182 begin: '<![a-z]',
6183 end: '>',
6184 contains: [
6185 XML_META_KEYWORDS,
6186 XML_META_PAR_KEYWORDS,
6187 QUOTE_META_STRING_MODE,
6188 APOS_META_STRING_MODE
6189 ]
6190 }
6191 ]
6192 }
6193 ]
6194 },
6195 hljs.COMMENT(
6196 '<!--',
6197 '-->',
6198 {
6199 relevance: 10
6200 }
6201 ),
6202 {
6203 begin: '<!\\[CDATA\\[',
6204 end: '\\]\\]>',
6205 relevance: 10
6206 },
6207 XML_ENTITIES,
6208 {
6209 className: 'meta',
6210 begin: /<\?xml/,
6211 end: /\?>/,
6212 relevance: 10
6213 },
6214 {
6215 className: 'tag',
6216 /*
6217 The lookahead pattern (?=...) ensures that 'begin' only matches
6218 '<style' as a single word, followed by a whitespace or an
6219 ending braket. The '$' is needed for the lexeme to be recognized
6220 by hljs.subMode() that tests lexemes outside the stream.
6221 */
6222 begin: '<style(?=\\s|>)',
6223 end: '>',
6224 keywords: {
6225 name: 'style'
6226 },
6227 contains: [ TAG_INTERNALS ],
6228 starts: {
6229 end: '</style>',
6230 returnEnd: true,
6231 subLanguage: [
6232 'css',
6233 'xml'
6234 ]
6235 }
6236 },
6237 {
6238 className: 'tag',
6239 // See the comment in the <style tag about the lookahead pattern
6240 begin: '<script(?=\\s|>)',
6241 end: '>',
6242 keywords: {
6243 name: 'script'
6244 },
6245 contains: [ TAG_INTERNALS ],
6246 starts: {
6247 end: /<\/script>/,
6248 returnEnd: true,
6249 subLanguage: [
6250 'javascript',
6251 'handlebars',
6252 'xml'
6253 ]
6254 }
6255 },
6256 // we need this for now for jSX
6257 {
6258 className: 'tag',
6259 begin: /<>|<\/>/
6260 },
6261 // open tag
6262 {
6263 className: 'tag',
6264 begin: concat(
6265 /</,
6266 lookahead(concat(
6267 TAG_NAME_RE,
6268 // <tag/>
6269 // <tag>
6270 // <tag ...
6271 either(/\/>/, />/, /\s/)
6272 ))
6273 ),
6274 end: /\/?>/,
6275 contains: [
6276 {
6277 className: 'name',
6278 begin: TAG_NAME_RE,
6279 relevance: 0,
6280 starts: TAG_INTERNALS
6281 }
6282 ]
6283 },
6284 // close tag
6285 {
6286 className: 'tag',
6287 begin: concat(
6288 /<\//,
6289 lookahead(concat(
6290 TAG_NAME_RE, />/
6291 ))
6292 ),
6293 contains: [
6294 {
6295 className: 'name',
6296 begin: TAG_NAME_RE,
6297 relevance: 0
6298 },
6299 {
6300 begin: />/,
6301 relevance: 0
6302 }
6303 ]
6304 }
6305 ]
6306 };
6307 }
6308
6309 return xml;
6310
6311 return module.exports.definer || module.exports;
6312
6313}());
6314
6315hljs.registerLanguage('markdown', function () {
6316 'use strict';
6317
6318 /**
6319 * @param {string} value
6320 * @returns {RegExp}
6321 * */
6322
6323 /**
6324 * @param {RegExp | string } re
6325 * @returns {string}
6326 */
6327 function source(re) {
6328 if (!re) return null;
6329 if (typeof re === "string") return re;
6330
6331 return re.source;
6332 }
6333
6334 /**
6335 * @param {...(RegExp | string) } args
6336 * @returns {string}
6337 */
6338 function concat(...args) {
6339 const joined = args.map((x) => source(x)).join("");
6340 return joined;
6341 }
6342
6343 /*
6344 Language: Markdown
6345 Requires: xml.js
6346 Author: John Crepezzi <john.crepezzi@gmail.com>
6347 Website: https://daringfireball.net/projects/markdown/
6348 Category: common, markup
6349 */
6350
6351 function markdown(hljs) {
6352 const INLINE_HTML = {
6353 begin: /<\/?[A-Za-z_]/,
6354 end: '>',
6355 subLanguage: 'xml',
6356 relevance: 0
6357 };
6358 const HORIZONTAL_RULE = {
6359 begin: '^[-\\*]{3,}',
6360 end: '$'
6361 };
6362 const CODE = {
6363 className: 'code',
6364 variants: [
6365 // TODO: fix to allow these to work with sublanguage also
6366 {
6367 begin: '(`{3,})[^`](.|\\n)*?\\1`*[ ]*'
6368 },
6369 {
6370 begin: '(~{3,})[^~](.|\\n)*?\\1~*[ ]*'
6371 },
6372 // needed to allow markdown as a sublanguage to work
6373 {
6374 begin: '```',
6375 end: '```+[ ]*$'
6376 },
6377 {
6378 begin: '~~~',
6379 end: '~~~+[ ]*$'
6380 },
6381 {
6382 begin: '`.+?`'
6383 },
6384 {
6385 begin: '(?=^( {4}|\\t))',
6386 // use contains to gobble up multiple lines to allow the block to be whatever size
6387 // but only have a single open/close tag vs one per line
6388 contains: [
6389 {
6390 begin: '^( {4}|\\t)',
6391 end: '(\\n)$'
6392 }
6393 ],
6394 relevance: 0
6395 }
6396 ]
6397 };
6398 const LIST = {
6399 className: 'bullet',
6400 begin: '^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)',
6401 end: '\\s+',
6402 excludeEnd: true
6403 };
6404 const LINK_REFERENCE = {
6405 begin: /^\[[^\n]+\]:/,
6406 returnBegin: true,
6407 contains: [
6408 {
6409 className: 'symbol',
6410 begin: /\[/,
6411 end: /\]/,
6412 excludeBegin: true,
6413 excludeEnd: true
6414 },
6415 {
6416 className: 'link',
6417 begin: /:\s*/,
6418 end: /$/,
6419 excludeBegin: true
6420 }
6421 ]
6422 };
6423 const URL_SCHEME = /[A-Za-z][A-Za-z0-9+.-]*/;
6424 const LINK = {
6425 variants: [
6426 // too much like nested array access in so many languages
6427 // to have any real relevance
6428 {
6429 begin: /\[.+?\]\[.*?\]/,
6430 relevance: 0
6431 },
6432 // popular internet URLs
6433 {
6434 begin: /\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
6435 relevance: 2
6436 },
6437 {
6438 begin: concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/),
6439 relevance: 2
6440 },
6441 // relative urls
6442 {
6443 begin: /\[.+?\]\([./?&#].*?\)/,
6444 relevance: 1
6445 },
6446 // whatever else, lower relevance (might not be a link at all)
6447 {
6448 begin: /\[.+?\]\(.*?\)/,
6449 relevance: 0
6450 }
6451 ],
6452 returnBegin: true,
6453 contains: [
6454 {
6455 className: 'string',
6456 relevance: 0,
6457 begin: '\\[',
6458 end: '\\]',
6459 excludeBegin: true,
6460 returnEnd: true
6461 },
6462 {
6463 className: 'link',
6464 relevance: 0,
6465 begin: '\\]\\(',
6466 end: '\\)',
6467 excludeBegin: true,
6468 excludeEnd: true
6469 },
6470 {
6471 className: 'symbol',
6472 relevance: 0,
6473 begin: '\\]\\[',
6474 end: '\\]',
6475 excludeBegin: true,
6476 excludeEnd: true
6477 }
6478 ]
6479 };
6480 const BOLD = {
6481 className: 'strong',
6482 contains: [],
6483 variants: [
6484 {
6485 begin: /_{2}/,
6486 end: /_{2}/
6487 },
6488 {
6489 begin: /\*{2}/,
6490 end: /\*{2}/
6491 }
6492 ]
6493 };
6494 const ITALIC = {
6495 className: 'emphasis',
6496 contains: [],
6497 variants: [
6498 {
6499 begin: /\*(?!\*)/,
6500 end: /\*/
6501 },
6502 {
6503 begin: /_(?!_)/,
6504 end: /_/,
6505 relevance: 0
6506 }
6507 ]
6508 };
6509 BOLD.contains.push(ITALIC);
6510 ITALIC.contains.push(BOLD);
6511
6512 let CONTAINABLE = [
6513 INLINE_HTML,
6514 LINK
6515 ];
6516
6517 BOLD.contains = BOLD.contains.concat(CONTAINABLE);
6518 ITALIC.contains = ITALIC.contains.concat(CONTAINABLE);
6519
6520 CONTAINABLE = CONTAINABLE.concat(BOLD, ITALIC);
6521
6522 const HEADER = {
6523 className: 'section',
6524 variants: [
6525 {
6526 begin: '^#{1,6}',
6527 end: '$',
6528 contains: CONTAINABLE
6529 },
6530 {
6531 begin: '(?=^.+?\\n[=-]{2,}$)',
6532 contains: [
6533 {
6534 begin: '^[=-]*$'
6535 },
6536 {
6537 begin: '^',
6538 end: "\\n",
6539 contains: CONTAINABLE
6540 }
6541 ]
6542 }
6543 ]
6544 };
6545
6546 const BLOCKQUOTE = {
6547 className: 'quote',
6548 begin: '^>\\s+',
6549 contains: CONTAINABLE,
6550 end: '$'
6551 };
6552
6553 return {
6554 name: 'Markdown',
6555 aliases: [
6556 'md',
6557 'mkdown',
6558 'mkd'
6559 ],
6560 contains: [
6561 HEADER,
6562 INLINE_HTML,
6563 LIST,
6564 BOLD,
6565 ITALIC,
6566 BLOCKQUOTE,
6567 CODE,
6568 HORIZONTAL_RULE,
6569 LINK,
6570 LINK_REFERENCE
6571 ]
6572 };
6573 }
6574
6575 return markdown;
6576
6577 return module.exports.definer || module.exports;
6578
6579}());
6580
6581hljs.registerLanguage('nginx', function () {
6582 'use strict';
6583
6584 /*
6585 Language: Nginx config
6586 Author: Peter Leonov <gojpeg@yandex.ru>
6587 Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
6588 Category: common, config
6589 Website: https://www.nginx.com
6590 */
6591
6592 function nginx(hljs) {
6593 const VAR = {
6594 className: 'variable',
6595 variants: [
6596 {
6597 begin: /\$\d+/
6598 },
6599 {
6600 begin: /\$\{/,
6601 end: /\}/
6602 },
6603 {
6604 begin: /[$@]/ + hljs.UNDERSCORE_IDENT_RE
6605 }
6606 ]
6607 };
6608 const DEFAULT = {
6609 endsWithParent: true,
6610 keywords: {
6611 $pattern: '[a-z/_]+',
6612 literal:
6613 'on off yes no true false none blocked debug info notice warn error crit ' +
6614 'select break last permanent redirect kqueue rtsig epoll poll /dev/poll'
6615 },
6616 relevance: 0,
6617 illegal: '=>',
6618 contains: [
6619 hljs.HASH_COMMENT_MODE,
6620 {
6621 className: 'string',
6622 contains: [
6623 hljs.BACKSLASH_ESCAPE,
6624 VAR
6625 ],
6626 variants: [
6627 {
6628 begin: /"/,
6629 end: /"/
6630 },
6631 {
6632 begin: /'/,
6633 end: /'/
6634 }
6635 ]
6636 },
6637 // this swallows entire URLs to avoid detecting numbers within
6638 {
6639 begin: '([a-z]+):/',
6640 end: '\\s',
6641 endsWithParent: true,
6642 excludeEnd: true,
6643 contains: [ VAR ]
6644 },
6645 {
6646 className: 'regexp',
6647 contains: [
6648 hljs.BACKSLASH_ESCAPE,
6649 VAR
6650 ],
6651 variants: [
6652 {
6653 begin: "\\s\\^",
6654 end: "\\s|\\{|;",
6655 returnEnd: true
6656 },
6657 // regexp locations (~, ~*)
6658 {
6659 begin: "~\\*?\\s+",
6660 end: "\\s|\\{|;",
6661 returnEnd: true
6662 },
6663 // *.example.com
6664 {
6665 begin: "\\*(\\.[a-z\\-]+)+"
6666 },
6667 // sub.example.*
6668 {
6669 begin: "([a-z\\-]+\\.)+\\*"
6670 }
6671 ]
6672 },
6673 // IP
6674 {
6675 className: 'number',
6676 begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
6677 },
6678 // units
6679 {
6680 className: 'number',
6681 begin: '\\b\\d+[kKmMgGdshdwy]*\\b',
6682 relevance: 0
6683 },
6684 VAR
6685 ]
6686 };
6687
6688 return {
6689 name: 'Nginx config',
6690 aliases: [ 'nginxconf' ],
6691 contains: [
6692 hljs.HASH_COMMENT_MODE,
6693 {
6694 begin: hljs.UNDERSCORE_IDENT_RE + '\\s+\\{',
6695 returnBegin: true,
6696 end: /\{/,
6697 contains: [
6698 {
6699 className: 'section',
6700 begin: hljs.UNDERSCORE_IDENT_RE
6701 }
6702 ],
6703 relevance: 0
6704 },
6705 {
6706 begin: hljs.UNDERSCORE_IDENT_RE + '\\s',
6707 end: ';|\\{',
6708 returnBegin: true,
6709 contains: [
6710 {
6711 className: 'attribute',
6712 begin: hljs.UNDERSCORE_IDENT_RE,
6713 starts: DEFAULT
6714 }
6715 ],
6716 relevance: 0
6717 }
6718 ],
6719 illegal: '[^\\s\\}]'
6720 };
6721 }
6722
6723 return nginx;
6724
6725 return module.exports.definer || module.exports;
6726
6727}());
6728
6729hljs.registerLanguage('objectivec', function () {
6730 'use strict';
6731
6732 /*
6733 Language: Objective-C
6734 Author: Valerii Hiora <valerii.hiora@gmail.com>
6735 Contributors: Angel G. Olloqui <angelgarcia.mail@gmail.com>, Matt Diephouse <matt@diephouse.com>, Andrew Farmer <ahfarmer@gmail.com>, Minh Nguyễn <mxn@1ec5.org>
6736 Website: https://developer.apple.com/documentation/objectivec
6737 Category: common
6738 */
6739
6740 function objectivec(hljs) {
6741 const API_CLASS = {
6742 className: 'built_in',
6743 begin: '\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+'
6744 };
6745 const IDENTIFIER_RE = /[a-zA-Z@][a-zA-Z0-9_]*/;
6746 const OBJC_KEYWORDS = {
6747 $pattern: IDENTIFIER_RE,
6748 keyword:
6749 'int float while char export sizeof typedef const struct for union ' +
6750 'unsigned long volatile static bool mutable if do return goto void ' +
6751 'enum else break extern asm case short default double register explicit ' +
6752 'signed typename this switch continue wchar_t inline readonly assign ' +
6753 'readwrite self @synchronized id typeof ' +
6754 'nonatomic super unichar IBOutlet IBAction strong weak copy ' +
6755 'in out inout bycopy byref oneway __strong __weak __block __autoreleasing ' +
6756 '@private @protected @public @try @property @end @throw @catch @finally ' +
6757 '@autoreleasepool @synthesize @dynamic @selector @optional @required ' +
6758 '@encode @package @import @defs @compatibility_alias ' +
6759 '__bridge __bridge_transfer __bridge_retained __bridge_retain ' +
6760 '__covariant __contravariant __kindof ' +
6761 '_Nonnull _Nullable _Null_unspecified ' +
6762 '__FUNCTION__ __PRETTY_FUNCTION__ __attribute__ ' +
6763 'getter setter retain unsafe_unretained ' +
6764 'nonnull nullable null_unspecified null_resettable class instancetype ' +
6765 'NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER ' +
6766 'NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED ' +
6767 'NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE ' +
6768 'NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END ' +
6769 'NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW ' +
6770 'NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN',
6771 literal:
6772 'false true FALSE TRUE nil YES NO NULL',
6773 built_in:
6774 'BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once'
6775 };
6776 const CLASS_KEYWORDS = {
6777 $pattern: IDENTIFIER_RE,
6778 keyword: '@interface @class @protocol @implementation'
6779 };
6780 return {
6781 name: 'Objective-C',
6782 aliases: [
6783 'mm',
6784 'objc',
6785 'obj-c',
6786 'obj-c++',
6787 'objective-c++'
6788 ],
6789 keywords: OBJC_KEYWORDS,
6790 illegal: '</',
6791 contains: [
6792 API_CLASS,
6793 hljs.C_LINE_COMMENT_MODE,
6794 hljs.C_BLOCK_COMMENT_MODE,
6795 hljs.C_NUMBER_MODE,
6796 hljs.QUOTE_STRING_MODE,
6797 hljs.APOS_STRING_MODE,
6798 {
6799 className: 'string',
6800 variants: [
6801 {
6802 begin: '@"',
6803 end: '"',
6804 illegal: '\\n',
6805 contains: [ hljs.BACKSLASH_ESCAPE ]
6806 }
6807 ]
6808 },
6809 {
6810 className: 'meta',
6811 begin: /#\s*[a-z]+\b/,
6812 end: /$/,
6813 keywords: {
6814 'meta-keyword':
6815 'if else elif endif define undef warning error line ' +
6816 'pragma ifdef ifndef include'
6817 },
6818 contains: [
6819 {
6820 begin: /\\\n/,
6821 relevance: 0
6822 },
6823 hljs.inherit(hljs.QUOTE_STRING_MODE, {
6824 className: 'meta-string'
6825 }),
6826 {
6827 className: 'meta-string',
6828 begin: /<.*?>/,
6829 end: /$/,
6830 illegal: '\\n'
6831 },
6832 hljs.C_LINE_COMMENT_MODE,
6833 hljs.C_BLOCK_COMMENT_MODE
6834 ]
6835 },
6836 {
6837 className: 'class',
6838 begin: '(' + CLASS_KEYWORDS.keyword.split(' ').join('|') + ')\\b',
6839 end: /(\{|$)/,
6840 excludeEnd: true,
6841 keywords: CLASS_KEYWORDS,
6842 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
6843 },
6844 {
6845 begin: '\\.' + hljs.UNDERSCORE_IDENT_RE,
6846 relevance: 0
6847 }
6848 ]
6849 };
6850 }
6851
6852 return objectivec;
6853
6854 return module.exports.definer || module.exports;
6855
6856}());
6857
6858hljs.registerLanguage('perl', function () {
6859 'use strict';
6860
6861 /**
6862 * @param {string} value
6863 * @returns {RegExp}
6864 * */
6865
6866 /**
6867 * @param {RegExp | string } re
6868 * @returns {string}
6869 */
6870 function source(re) {
6871 if (!re) return null;
6872 if (typeof re === "string") return re;
6873
6874 return re.source;
6875 }
6876
6877 /**
6878 * @param {...(RegExp | string) } args
6879 * @returns {string}
6880 */
6881 function concat(...args) {
6882 const joined = args.map((x) => source(x)).join("");
6883 return joined;
6884 }
6885
6886 /*
6887 Language: Perl
6888 Author: Peter Leonov <gojpeg@yandex.ru>
6889 Website: https://www.perl.org
6890 Category: common
6891 */
6892
6893 /** @type LanguageFn */
6894 function perl(hljs) {
6895 // https://perldoc.perl.org/perlre#Modifiers
6896 const REGEX_MODIFIERS = /[dualxmsipn]{0,12}/; // aa and xx are valid, making max length 12
6897 const PERL_KEYWORDS = {
6898 $pattern: /[\w.]+/,
6899 keyword: 'getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ' +
6900 'ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime ' +
6901 'readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq ' +
6902 'fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent ' +
6903 'shutdown dump chomp connect getsockname die socketpair close flock exists index shmget ' +
6904 'sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr ' +
6905 'unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 ' +
6906 'getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline ' +
6907 'endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand ' +
6908 'mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink ' +
6909 'getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr ' +
6910 'untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link ' +
6911 'getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller ' +
6912 'lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and ' +
6913 'sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 ' +
6914 'chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach ' +
6915 'tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir ' +
6916 'ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe ' +
6917 'atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when'
6918 };
6919 const SUBST = {
6920 className: 'subst',
6921 begin: '[$@]\\{',
6922 end: '\\}',
6923 keywords: PERL_KEYWORDS
6924 };
6925 const METHOD = {
6926 begin: /->\{/,
6927 end: /\}/
6928 // contains defined later
6929 };
6930 const VAR = {
6931 variants: [
6932 {
6933 begin: /\$\d/
6934 },
6935 {
6936 begin: concat(
6937 /[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,
6938 // negative look-ahead tries to avoid matching patterns that are not
6939 // Perl at all like $ident$, @ident@, etc.
6940 `(?![A-Za-z])(?![@$%])`
6941 )
6942 },
6943 {
6944 begin: /[$%@][^\s\w{]/,
6945 relevance: 0
6946 }
6947 ]
6948 };
6949 const STRING_CONTAINS = [
6950 hljs.BACKSLASH_ESCAPE,
6951 SUBST,
6952 VAR
6953 ];
6954 const PERL_DEFAULT_CONTAINS = [
6955 VAR,
6956 hljs.HASH_COMMENT_MODE,
6957 hljs.COMMENT(
6958 /^=\w/,
6959 /=cut/,
6960 {
6961 endsWithParent: true
6962 }
6963 ),
6964 METHOD,
6965 {
6966 className: 'string',
6967 contains: STRING_CONTAINS,
6968 variants: [
6969 {
6970 begin: 'q[qwxr]?\\s*\\(',
6971 end: '\\)',
6972 relevance: 5
6973 },
6974 {
6975 begin: 'q[qwxr]?\\s*\\[',
6976 end: '\\]',
6977 relevance: 5
6978 },
6979 {
6980 begin: 'q[qwxr]?\\s*\\{',
6981 end: '\\}',
6982 relevance: 5
6983 },
6984 {
6985 begin: 'q[qwxr]?\\s*\\|',
6986 end: '\\|',
6987 relevance: 5
6988 },
6989 {
6990 begin: 'q[qwxr]?\\s*<',
6991 end: '>',
6992 relevance: 5
6993 },
6994 {
6995 begin: 'qw\\s+q',
6996 end: 'q',
6997 relevance: 5
6998 },
6999 {
7000 begin: '\'',
7001 end: '\'',
7002 contains: [ hljs.BACKSLASH_ESCAPE ]
7003 },
7004 {
7005 begin: '"',
7006 end: '"'
7007 },
7008 {
7009 begin: '`',
7010 end: '`',
7011 contains: [ hljs.BACKSLASH_ESCAPE ]
7012 },
7013 {
7014 begin: /\{\w+\}/,
7015 contains: [],
7016 relevance: 0
7017 },
7018 {
7019 begin: '-?\\w+\\s*=>',
7020 contains: [],
7021 relevance: 0
7022 }
7023 ]
7024 },
7025 {
7026 className: 'number',
7027 begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
7028 relevance: 0
7029 },
7030 { // regexp container
7031 begin: '(\\/\\/|' + hljs.RE_STARTERS_RE + '|\\b(split|return|print|reverse|grep)\\b)\\s*',
7032 keywords: 'split return print reverse grep',
7033 relevance: 0,
7034 contains: [
7035 hljs.HASH_COMMENT_MODE,
7036 {
7037 className: 'regexp',
7038 begin: concat(
7039 /(s|tr|y)/,
7040 /\//,
7041 /(\\.|[^\\\/])*/,
7042 /\//,
7043 /(\\.|[^\\\/])*/,
7044 /\//,
7045 REGEX_MODIFIERS,
7046 ),
7047 relevance: 10
7048 },
7049 {
7050 className: 'regexp',
7051 begin: /(m|qr)?\//,
7052 end: concat(
7053 /\//,
7054 REGEX_MODIFIERS
7055 ),
7056 contains: [ hljs.BACKSLASH_ESCAPE ],
7057 relevance: 0 // allows empty "//" which is a common comment delimiter in other languages
7058 }
7059 ]
7060 },
7061 {
7062 className: 'function',
7063 beginKeywords: 'sub',
7064 end: '(\\s*\\(.*?\\))?[;{]',
7065 excludeEnd: true,
7066 relevance: 5,
7067 contains: [ hljs.TITLE_MODE ]
7068 },
7069 {
7070 begin: '-\\w\\b',
7071 relevance: 0
7072 },
7073 {
7074 begin: "^__DATA__$",
7075 end: "^__END__$",
7076 subLanguage: 'mojolicious',
7077 contains: [
7078 {
7079 begin: "^@@.*",
7080 end: "$",
7081 className: "comment"
7082 }
7083 ]
7084 }
7085 ];
7086 SUBST.contains = PERL_DEFAULT_CONTAINS;
7087 METHOD.contains = PERL_DEFAULT_CONTAINS;
7088
7089 return {
7090 name: 'Perl',
7091 aliases: [
7092 'pl',
7093 'pm'
7094 ],
7095 keywords: PERL_KEYWORDS,
7096 contains: PERL_DEFAULT_CONTAINS
7097 };
7098 }
7099
7100 return perl;
7101
7102 return module.exports.definer || module.exports;
7103
7104}());
7105
7106hljs.registerLanguage('php', function () {
7107 'use strict';
7108
7109 /*
7110 Language: PHP
7111 Author: Victor Karamzin <Victor.Karamzin@enterra-inc.com>
7112 Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Ivan Sagalaev <maniac@softwaremaniacs.org>
7113 Website: https://www.php.net
7114 Category: common
7115 */
7116
7117 /**
7118 * @param {HLJSApi} hljs
7119 * @returns {LanguageDetail}
7120 * */
7121 function php(hljs) {
7122 const VARIABLE = {
7123 className: 'variable',
7124 begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' +
7125 // negative look-ahead tries to avoid matching patterns that are not
7126 // Perl at all like $ident$, @ident@, etc.
7127 `(?![A-Za-z0-9])(?![$])`
7128 };
7129 const PREPROCESSOR = {
7130 className: 'meta',
7131 variants: [
7132 { begin: /<\?php/, relevance: 10 }, // boost for obvious PHP
7133 { begin: /<\?[=]?/ },
7134 { begin: /\?>/ } // end php tag
7135 ]
7136 };
7137 const SUBST = {
7138 className: 'subst',
7139 variants: [
7140 { begin: /\$\w+/ },
7141 { begin: /\{\$/, end: /\}/ }
7142 ]
7143 };
7144 const SINGLE_QUOTED = hljs.inherit(hljs.APOS_STRING_MODE, {
7145 illegal: null,
7146 });
7147 const DOUBLE_QUOTED = hljs.inherit(hljs.QUOTE_STRING_MODE, {
7148 illegal: null,
7149 contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
7150 });
7151 const HEREDOC = hljs.END_SAME_AS_BEGIN({
7152 begin: /<<<[ \t]*(\w+)\n/,
7153 end: /[ \t]*(\w+)\b/,
7154 contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
7155 });
7156 const STRING = {
7157 className: 'string',
7158 contains: [hljs.BACKSLASH_ESCAPE, PREPROCESSOR],
7159 variants: [
7160 hljs.inherit(SINGLE_QUOTED, {
7161 begin: "b'", end: "'",
7162 }),
7163 hljs.inherit(DOUBLE_QUOTED, {
7164 begin: 'b"', end: '"',
7165 }),
7166 DOUBLE_QUOTED,
7167 SINGLE_QUOTED,
7168 HEREDOC
7169 ]
7170 };
7171 const NUMBER = {variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]};
7172 const KEYWORDS = {
7173 keyword:
7174 // Magic constants:
7175 // <https://www.php.net/manual/en/language.constants.predefined.php>
7176 '__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ ' +
7177 // Function that look like language construct or language construct that look like function:
7178 // List of keywords that may not require parenthesis
7179 'die echo exit include include_once print require require_once ' +
7180 // These are not language construct (function) but operate on the currently-executing function and can access the current symbol table
7181 // 'compact extract func_get_arg func_get_args func_num_args get_called_class get_parent_class ' +
7182 // Other keywords:
7183 // <https://www.php.net/manual/en/reserved.php>
7184 // <https://www.php.net/manual/en/language.types.type-juggling.php>
7185 'array abstract and as binary bool boolean break callable case catch class clone const continue declare ' +
7186 'default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends ' +
7187 'final finally float for foreach from global goto if implements instanceof insteadof int integer interface ' +
7188 'isset iterable list match|0 new object or private protected public real return string switch throw trait ' +
7189 'try unset use var void while xor yield',
7190 literal: 'false null true',
7191 built_in:
7192 // Standard PHP library:
7193 // <https://www.php.net/manual/en/book.spl.php>
7194 'Error|0 ' + // error is too common a name esp since PHP is case in-sensitive
7195 '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 ' +
7196 // Reserved interfaces:
7197 // <https://www.php.net/manual/en/reserved.interfaces.php>
7198 'ArrayAccess Closure Generator Iterator IteratorAggregate Serializable Throwable Traversable WeakReference ' +
7199 // Reserved classes:
7200 // <https://www.php.net/manual/en/reserved.classes.php>
7201 'Directory __PHP_Incomplete_Class parent php_user_filter self static stdClass'
7202 };
7203 return {
7204 aliases: ['php', 'php3', 'php4', 'php5', 'php6', 'php7', 'php8'],
7205 case_insensitive: true,
7206 keywords: KEYWORDS,
7207 contains: [
7208 hljs.HASH_COMMENT_MODE,
7209 hljs.COMMENT('//', '$', {contains: [PREPROCESSOR]}),
7210 hljs.COMMENT(
7211 '/\\*',
7212 '\\*/',
7213 {
7214 contains: [
7215 {
7216 className: 'doctag',
7217 begin: '@[A-Za-z]+'
7218 }
7219 ]
7220 }
7221 ),
7222 hljs.COMMENT(
7223 '__halt_compiler.+?;',
7224 false,
7225 {
7226 endsWithParent: true,
7227 keywords: '__halt_compiler'
7228 }
7229 ),
7230 PREPROCESSOR,
7231 {
7232 className: 'keyword', begin: /\$this\b/
7233 },
7234 VARIABLE,
7235 {
7236 // swallow composed identifiers to avoid parsing them as keywords
7237 begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
7238 },
7239 {
7240 className: 'function',
7241 relevance: 0,
7242 beginKeywords: 'fn function', end: /[;{]/, excludeEnd: true,
7243 illegal: '[$%\\[]',
7244 contains: [
7245 hljs.UNDERSCORE_TITLE_MODE,
7246 {
7247 begin: '=>' // No markup, just a relevance booster
7248 },
7249 {
7250 className: 'params',
7251 begin: '\\(', end: '\\)',
7252 excludeBegin: true,
7253 excludeEnd: true,
7254 keywords: KEYWORDS,
7255 contains: [
7256 'self',
7257 VARIABLE,
7258 hljs.C_BLOCK_COMMENT_MODE,
7259 STRING,
7260 NUMBER
7261 ]
7262 }
7263 ]
7264 },
7265 {
7266 className: 'class',
7267 beginKeywords: 'class interface',
7268 relevance: 0,
7269 end: /\{/,
7270 excludeEnd: true,
7271 illegal: /[:($"]/,
7272 contains: [
7273 {beginKeywords: 'extends implements'},
7274 hljs.UNDERSCORE_TITLE_MODE
7275 ]
7276 },
7277 {
7278 beginKeywords: 'namespace',
7279 relevance: 0,
7280 end: ';',
7281 illegal: /[.']/,
7282 contains: [hljs.UNDERSCORE_TITLE_MODE]
7283 },
7284 {
7285 beginKeywords: 'use',
7286 relevance: 0,
7287 end: ';',
7288 contains: [hljs.UNDERSCORE_TITLE_MODE]
7289 },
7290 STRING,
7291 NUMBER
7292 ]
7293 };
7294 }
7295
7296 return php;
7297
7298 return module.exports.definer || module.exports;
7299
7300}());
7301
7302hljs.registerLanguage('php-template', function () {
7303 'use strict';
7304
7305 /*
7306 Language: PHP Template
7307 Requires: xml.js, php.js
7308 Author: Josh Goebel <hello@joshgoebel.com>
7309 Website: https://www.php.net
7310 Category: common
7311 */
7312
7313 function phpTemplate(hljs) {
7314 return {
7315 name: "PHP template",
7316 subLanguage: 'xml',
7317 contains: [
7318 {
7319 begin: /<\?(php|=)?/,
7320 end: /\?>/,
7321 subLanguage: 'php',
7322 contains: [
7323 // We don't want the php closing tag ?> to close the PHP block when
7324 // inside any of the following blocks:
7325 {
7326 begin: '/\\*',
7327 end: '\\*/',
7328 skip: true
7329 },
7330 {
7331 begin: 'b"',
7332 end: '"',
7333 skip: true
7334 },
7335 {
7336 begin: 'b\'',
7337 end: '\'',
7338 skip: true
7339 },
7340 hljs.inherit(hljs.APOS_STRING_MODE, {
7341 illegal: null,
7342 className: null,
7343 contains: null,
7344 skip: true
7345 }),
7346 hljs.inherit(hljs.QUOTE_STRING_MODE, {
7347 illegal: null,
7348 className: null,
7349 contains: null,
7350 skip: true
7351 })
7352 ]
7353 }
7354 ]
7355 };
7356 }
7357
7358 return phpTemplate;
7359
7360 return module.exports.definer || module.exports;
7361
7362}());
7363
7364hljs.registerLanguage('plaintext', function () {
7365 'use strict';
7366
7367 /*
7368 Language: Plain text
7369 Author: Egor Rogov (e.rogov@postgrespro.ru)
7370 Description: Plain text without any highlighting.
7371 Category: common
7372 */
7373
7374 function plaintext(hljs) {
7375 return {
7376 name: 'Plain text',
7377 aliases: [
7378 'text',
7379 'txt'
7380 ],
7381 disableAutodetect: true
7382 };
7383 }
7384
7385 return plaintext;
7386
7387 return module.exports.definer || module.exports;
7388
7389}());
7390
7391hljs.registerLanguage('properties', function () {
7392 'use strict';
7393
7394 /*
7395 Language: .properties
7396 Contributors: Valentin Aitken <valentin@nalisbg.com>, Egor Rogov <e.rogov@postgrespro.ru>
7397 Website: https://en.wikipedia.org/wiki/.properties
7398 Category: common, config
7399 */
7400
7401 function properties(hljs) {
7402
7403 // whitespaces: space, tab, formfeed
7404 var WS0 = '[ \\t\\f]*';
7405 var WS1 = '[ \\t\\f]+';
7406 // delimiter
7407 var EQUAL_DELIM = WS0+'[:=]'+WS0;
7408 var WS_DELIM = WS1;
7409 var DELIM = '(' + EQUAL_DELIM + '|' + WS_DELIM + ')';
7410 var KEY_ALPHANUM = '([^\\\\\\W:= \\t\\f\\n]|\\\\.)+';
7411 var KEY_OTHER = '([^\\\\:= \\t\\f\\n]|\\\\.)+';
7412
7413 var DELIM_AND_VALUE = {
7414 // skip DELIM
7415 end: DELIM,
7416 relevance: 0,
7417 starts: {
7418 // value: everything until end of line (again, taking into account backslashes)
7419 className: 'string',
7420 end: /$/,
7421 relevance: 0,
7422 contains: [
7423 { begin: '\\\\\\n' }
7424 ]
7425 }
7426 };
7427
7428 return {
7429 name: '.properties',
7430 case_insensitive: true,
7431 illegal: /\S/,
7432 contains: [
7433 hljs.COMMENT('^\\s*[!#]', '$'),
7434 // key: everything until whitespace or = or : (taking into account backslashes)
7435 // case of a "normal" key
7436 {
7437 returnBegin: true,
7438 variants: [
7439 { begin: KEY_ALPHANUM + EQUAL_DELIM, relevance: 1 },
7440 { begin: KEY_ALPHANUM + WS_DELIM, relevance: 0 }
7441 ],
7442 contains: [
7443 {
7444 className: 'attr',
7445 begin: KEY_ALPHANUM,
7446 endsParent: true,
7447 relevance: 0
7448 }
7449 ],
7450 starts: DELIM_AND_VALUE
7451 },
7452 // case of key containing non-alphanumeric chars => relevance = 0
7453 {
7454 begin: KEY_OTHER + DELIM,
7455 returnBegin: true,
7456 relevance: 0,
7457 contains: [
7458 {
7459 className: 'meta',
7460 begin: KEY_OTHER,
7461 endsParent: true,
7462 relevance: 0
7463 }
7464 ],
7465 starts: DELIM_AND_VALUE
7466 },
7467 // case of an empty key
7468 {
7469 className: 'attr',
7470 relevance: 0,
7471 begin: KEY_OTHER + WS0 + '$'
7472 }
7473 ]
7474 };
7475 }
7476
7477 return properties;
7478
7479 return module.exports.definer || module.exports;
7480
7481}());
7482
7483hljs.registerLanguage('python', function () {
7484 'use strict';
7485
7486 /*
7487 Language: Python
7488 Description: Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
7489 Website: https://www.python.org
7490 Category: common
7491 */
7492
7493 function python(hljs) {
7494 const RESERVED_WORDS = [
7495 'and',
7496 'as',
7497 'assert',
7498 'async',
7499 'await',
7500 'break',
7501 'class',
7502 'continue',
7503 'def',
7504 'del',
7505 'elif',
7506 'else',
7507 'except',
7508 'finally',
7509 'for',
7510 '',
7511 'from',
7512 'global',
7513 'if',
7514 'import',
7515 'in',
7516 'is',
7517 'lambda',
7518 'nonlocal|10',
7519 'not',
7520 'or',
7521 'pass',
7522 'raise',
7523 'return',
7524 'try',
7525 'while',
7526 'with',
7527 'yield',
7528 ];
7529
7530 const BUILT_INS = [
7531 '__import__',
7532 'abs',
7533 'all',
7534 'any',
7535 'ascii',
7536 'bin',
7537 'bool',
7538 'breakpoint',
7539 'bytearray',
7540 'bytes',
7541 'callable',
7542 'chr',
7543 'classmethod',
7544 'compile',
7545 'complex',
7546 'delattr',
7547 'dict',
7548 'dir',
7549 'divmod',
7550 'enumerate',
7551 'eval',
7552 'exec',
7553 'filter',
7554 'float',
7555 'format',
7556 'frozenset',
7557 'getattr',
7558 'globals',
7559 'hasattr',
7560 'hash',
7561 'help',
7562 'hex',
7563 'id',
7564 'input',
7565 'int',
7566 'isinstance',
7567 'issubclass',
7568 'iter',
7569 'len',
7570 'list',
7571 'locals',
7572 'map',
7573 'max',
7574 'memoryview',
7575 'min',
7576 'next',
7577 'object',
7578 'oct',
7579 'open',
7580 'ord',
7581 'pow',
7582 'print',
7583 'property',
7584 'range',
7585 'repr',
7586 'reversed',
7587 'round',
7588 'set',
7589 'setattr',
7590 'slice',
7591 'sorted',
7592 'staticmethod',
7593 'str',
7594 'sum',
7595 'super',
7596 'tuple',
7597 'type',
7598 'vars',
7599 'zip',
7600 ];
7601
7602 const LITERALS = [
7603 '__debug__',
7604 'Ellipsis',
7605 'False',
7606 'None',
7607 'NotImplemented',
7608 'True',
7609 ];
7610
7611 const KEYWORDS = {
7612 keyword: RESERVED_WORDS.join(' '),
7613 built_in: BUILT_INS.join(' '),
7614 literal: LITERALS.join(' ')
7615 };
7616
7617 const PROMPT = {
7618 className: 'meta', begin: /^(>>>|\.\.\.) /
7619 };
7620
7621 const SUBST = {
7622 className: 'subst',
7623 begin: /\{/, end: /\}/,
7624 keywords: KEYWORDS,
7625 illegal: /#/
7626 };
7627
7628 const LITERAL_BRACKET = {
7629 begin: /\{\{/,
7630 relevance: 0
7631 };
7632
7633 const STRING = {
7634 className: 'string',
7635 contains: [hljs.BACKSLASH_ESCAPE],
7636 variants: [
7637 {
7638 begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/, end: /'''/,
7639 contains: [hljs.BACKSLASH_ESCAPE, PROMPT],
7640 relevance: 10
7641 },
7642 {
7643 begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/, end: /"""/,
7644 contains: [hljs.BACKSLASH_ESCAPE, PROMPT],
7645 relevance: 10
7646 },
7647 {
7648 begin: /([fF][rR]|[rR][fF]|[fF])'''/, end: /'''/,
7649 contains: [hljs.BACKSLASH_ESCAPE, PROMPT, LITERAL_BRACKET, SUBST]
7650 },
7651 {
7652 begin: /([fF][rR]|[rR][fF]|[fF])"""/, end: /"""/,
7653 contains: [hljs.BACKSLASH_ESCAPE, PROMPT, LITERAL_BRACKET, SUBST]
7654 },
7655 {
7656 begin: /([uU]|[rR])'/, end: /'/,
7657 relevance: 10
7658 },
7659 {
7660 begin: /([uU]|[rR])"/, end: /"/,
7661 relevance: 10
7662 },
7663 {
7664 begin: /([bB]|[bB][rR]|[rR][bB])'/, end: /'/
7665 },
7666 {
7667 begin: /([bB]|[bB][rR]|[rR][bB])"/, end: /"/
7668 },
7669 {
7670 begin: /([fF][rR]|[rR][fF]|[fF])'/, end: /'/,
7671 contains: [hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET, SUBST]
7672 },
7673 {
7674 begin: /([fF][rR]|[rR][fF]|[fF])"/, end: /"/,
7675 contains: [hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET, SUBST]
7676 },
7677 hljs.APOS_STRING_MODE,
7678 hljs.QUOTE_STRING_MODE
7679 ]
7680 };
7681
7682 // https://docs.python.org/3.9/reference/lexical_analysis.html#numeric-literals
7683 const digitpart = '[0-9](_?[0-9])*';
7684 const pointfloat = `(\\b(${digitpart}))?\\.(${digitpart})|\\b(${digitpart})\\.`;
7685 const NUMBER = {
7686 className: 'number', relevance: 0,
7687 variants: [
7688 // exponentfloat, pointfloat
7689 // https://docs.python.org/3.9/reference/lexical_analysis.html#floating-point-literals
7690 // optionally imaginary
7691 // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
7692 // Note: no leading \b because floats can start with a decimal point
7693 // and we don't want to mishandle e.g. `fn(.5)`,
7694 // no trailing \b for pointfloat because it can end with a decimal point
7695 // and we don't want to mishandle e.g. `0..hex()`; this should be safe
7696 // because both MUST contain a decimal point and so cannot be confused with
7697 // the interior part of an identifier
7698 { begin: `(\\b(${digitpart})|(${pointfloat}))[eE][+-]?(${digitpart})[jJ]?\\b` },
7699 { begin: `(${pointfloat})[jJ]?` },
7700
7701 // decinteger, bininteger, octinteger, hexinteger
7702 // https://docs.python.org/3.9/reference/lexical_analysis.html#integer-literals
7703 // optionally "long" in Python 2
7704 // https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals
7705 // decinteger is optionally imaginary
7706 // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
7707 { begin: '\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?\\b' },
7708 { begin: '\\b0[bB](_?[01])+[lL]?\\b' },
7709 { begin: '\\b0[oO](_?[0-7])+[lL]?\\b' },
7710 { begin: '\\b0[xX](_?[0-9a-fA-F])+[lL]?\\b' },
7711
7712 // imagnumber (digitpart-based)
7713 // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
7714 { begin: `\\b(${digitpart})[jJ]\\b` },
7715 ]
7716 };
7717
7718 const PARAMS = {
7719 className: 'params',
7720 variants: [
7721 // Exclude params at functions without params
7722 {begin: /\(\s*\)/, skip: true, className: null },
7723 {
7724 begin: /\(/, end: /\)/, excludeBegin: true, excludeEnd: true,
7725 keywords: KEYWORDS,
7726 contains: ['self', PROMPT, NUMBER, STRING, hljs.HASH_COMMENT_MODE],
7727 },
7728 ],
7729 };
7730 SUBST.contains = [STRING, NUMBER, PROMPT];
7731
7732 return {
7733 name: 'Python',
7734 aliases: ['py', 'gyp', 'ipython'],
7735 keywords: KEYWORDS,
7736 illegal: /(<\/|->|\?)|=>/,
7737 contains: [
7738 PROMPT,
7739 NUMBER,
7740 // eat "if" prior to string so that it won't accidentally be
7741 // labeled as an f-string as in:
7742 { begin: /\bself\b/, }, // very common convention
7743 { beginKeywords: "if", relevance: 0 },
7744 STRING,
7745 hljs.HASH_COMMENT_MODE,
7746 {
7747 variants: [
7748 {className: 'function', beginKeywords: 'def'},
7749 {className: 'class', beginKeywords: 'class'}
7750 ],
7751 end: /:/,
7752 illegal: /[${=;\n,]/,
7753 contains: [
7754 hljs.UNDERSCORE_TITLE_MODE,
7755 PARAMS,
7756 {
7757 begin: /->/, endsWithParent: true,
7758 keywords: 'None'
7759 }
7760 ]
7761 },
7762 {
7763 className: 'meta',
7764 begin: /^[\t ]*@/, end: /(?=#)|$/,
7765 contains: [NUMBER, PARAMS, STRING]
7766 },
7767 {
7768 begin: /\b(print|exec)\(/ // don’t highlight keywords-turned-functions in Python 3
7769 }
7770 ]
7771 };
7772 }
7773
7774 return python;
7775
7776 return module.exports.definer || module.exports;
7777
7778}());
7779
7780hljs.registerLanguage('python-repl', function () {
7781 'use strict';
7782
7783 /*
7784 Language: Python REPL
7785 Requires: python.js
7786 Author: Josh Goebel <hello@joshgoebel.com>
7787 Category: common
7788 */
7789
7790 function pythonRepl(hljs) {
7791 return {
7792 aliases: [ 'pycon' ],
7793 contains: [
7794 {
7795 className: 'meta',
7796 starts: {
7797 // a space separates the REPL prefix from the actual code
7798 // this is purely for cleaner HTML output
7799 end: / |$/,
7800 starts: {
7801 end: '$',
7802 subLanguage: 'python'
7803 }
7804 },
7805 variants: [
7806 {
7807 begin: /^>>>(?=[ ]|$)/
7808 },
7809 {
7810 begin: /^\.\.\.(?=[ ]|$)/
7811 }
7812 ]
7813 }
7814 ]
7815 };
7816 }
7817
7818 return pythonRepl;
7819
7820 return module.exports.definer || module.exports;
7821
7822}());
7823
7824hljs.registerLanguage('ruby', function () {
7825 'use strict';
7826
7827 /**
7828 * @param {string} value
7829 * @returns {RegExp}
7830 * */
7831
7832 /**
7833 * @param {RegExp | string } re
7834 * @returns {string}
7835 */
7836 function source(re) {
7837 if (!re) return null;
7838 if (typeof re === "string") return re;
7839
7840 return re.source;
7841 }
7842
7843 /**
7844 * @param {RegExp | string } re
7845 * @returns {string}
7846 */
7847 function lookahead(re) {
7848 return concat('(?=', re, ')');
7849 }
7850
7851 /**
7852 * @param {...(RegExp | string) } args
7853 * @returns {string}
7854 */
7855 function concat(...args) {
7856 const joined = args.map((x) => source(x)).join("");
7857 return joined;
7858 }
7859
7860 /*
7861 Language: Ruby
7862 Description: Ruby is a dynamic, open source programming language with a focus on simplicity and productivity.
7863 Website: https://www.ruby-lang.org/
7864 Author: Anton Kovalyov <anton@kovalyov.net>
7865 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>
7866 Category: common
7867 */
7868
7869 function ruby(hljs) {
7870 var RUBY_METHOD_RE = '([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)';
7871 var RUBY_KEYWORDS = {
7872 keyword:
7873 'and then defined module in return redo if BEGIN retry end for self when ' +
7874 'next until do begin unless END rescue else break undef not super class case ' +
7875 'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor ' +
7876 '__FILE__',
7877 built_in: 'proc lambda',
7878 literal:
7879 'true false nil'
7880 };
7881 var YARDOCTAG = {
7882 className: 'doctag',
7883 begin: '@[A-Za-z]+'
7884 };
7885 var IRB_OBJECT = {
7886 begin: '#<', end: '>'
7887 };
7888 var COMMENT_MODES = [
7889 hljs.COMMENT(
7890 '#',
7891 '$',
7892 {
7893 contains: [YARDOCTAG]
7894 }
7895 ),
7896 hljs.COMMENT(
7897 '^=begin',
7898 '^=end',
7899 {
7900 contains: [YARDOCTAG],
7901 relevance: 10
7902 }
7903 ),
7904 hljs.COMMENT('^__END__', '\\n$')
7905 ];
7906 var SUBST = {
7907 className: 'subst',
7908 begin: /#\{/, end: /\}/,
7909 keywords: RUBY_KEYWORDS
7910 };
7911 var STRING = {
7912 className: 'string',
7913 contains: [hljs.BACKSLASH_ESCAPE, SUBST],
7914 variants: [
7915 {begin: /'/, end: /'/},
7916 {begin: /"/, end: /"/},
7917 {begin: /`/, end: /`/},
7918 {begin: /%[qQwWx]?\(/, end: /\)/},
7919 {begin: /%[qQwWx]?\[/, end: /\]/},
7920 {begin: /%[qQwWx]?\{/, end: /\}/},
7921 {begin: /%[qQwWx]?</, end: />/},
7922 {begin: /%[qQwWx]?\//, end: /\//},
7923 {begin: /%[qQwWx]?%/, end: /%/},
7924 {begin: /%[qQwWx]?-/, end: /-/},
7925 {begin: /%[qQwWx]?\|/, end: /\|/},
7926 {
7927 // \B in the beginning suppresses recognition of ?-sequences where ?
7928 // is the last character of a preceding identifier, as in: `func?4`
7929 begin: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/
7930 },
7931 { // heredocs
7932 begin: /<<[-~]?'?(\w+)\n(?:[^\n]*\n)*?\s*\1\b/,
7933 returnBegin: true,
7934 contains: [
7935 { begin: /<<[-~]?'?/ },
7936 hljs.END_SAME_AS_BEGIN({
7937 begin: /(\w+)/, end: /(\w+)/,
7938 contains: [hljs.BACKSLASH_ESCAPE, SUBST],
7939 })
7940 ]
7941 }
7942 ]
7943 };
7944
7945 // Ruby syntax is underdocumented, but this grammar seems to be accurate
7946 // as of version 2.7.2 (confirmed with (irb and `Ripper.sexp(...)`)
7947 // https://docs.ruby-lang.org/en/2.7.0/doc/syntax/literals_rdoc.html#label-Numbers
7948 var decimal = '[1-9](_?[0-9])*|0';
7949 var digits = '[0-9](_?[0-9])*';
7950 var NUMBER = {
7951 className: 'number', relevance: 0,
7952 variants: [
7953 // decimal integer/float, optionally exponential or rational, optionally imaginary
7954 { begin: `\\b(${decimal})(\\.(${digits}))?([eE][+-]?(${digits})|r)?i?\\b` },
7955
7956 // explicit decimal/binary/octal/hexadecimal integer,
7957 // optionally rational and/or imaginary
7958 { begin: "\\b0[dD][0-9](_?[0-9])*r?i?\\b" },
7959 { begin: "\\b0[bB][0-1](_?[0-1])*r?i?\\b" },
7960 { begin: "\\b0[oO][0-7](_?[0-7])*r?i?\\b" },
7961 { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b" },
7962
7963 // 0-prefixed implicit octal integer, optionally rational and/or imaginary
7964 { begin: "\\b0(_?[0-7])+r?i?\\b" },
7965 ]
7966 };
7967
7968 var PARAMS = {
7969 className: 'params',
7970 begin: '\\(', end: '\\)', endsParent: true,
7971 keywords: RUBY_KEYWORDS
7972 };
7973
7974 var RUBY_DEFAULT_CONTAINS = [
7975 STRING,
7976 {
7977 className: 'class',
7978 beginKeywords: 'class module', end: '$|;',
7979 illegal: /=/,
7980 contains: [
7981 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|!)?'}),
7982 {
7983 begin: '<\\s*',
7984 contains: [{
7985 begin: '(' + hljs.IDENT_RE + '::)?' + hljs.IDENT_RE
7986 }]
7987 }
7988 ].concat(COMMENT_MODES)
7989 },
7990 {
7991 className: 'function',
7992 // def method_name(
7993 // def method_name;
7994 // def method_name (end of line)
7995 begin: concat(/def\s*/, lookahead(RUBY_METHOD_RE + "\\s*(\\(|;|$)")),
7996 keywords: "def",
7997 end: '$|;',
7998 contains: [
7999 hljs.inherit(hljs.TITLE_MODE, {begin: RUBY_METHOD_RE}),
8000 PARAMS
8001 ].concat(COMMENT_MODES)
8002 },
8003 {
8004 // swallow namespace qualifiers before symbols
8005 begin: hljs.IDENT_RE + '::'
8006 },
8007 {
8008 className: 'symbol',
8009 begin: hljs.UNDERSCORE_IDENT_RE + '(!|\\?)?:',
8010 relevance: 0
8011 },
8012 {
8013 className: 'symbol',
8014 begin: ':(?!\\s)',
8015 contains: [STRING, {begin: RUBY_METHOD_RE}],
8016 relevance: 0
8017 },
8018 NUMBER,
8019 {
8020 // negative-look forward attemps to prevent false matches like:
8021 // @ident@ or $ident$ that might indicate this is not ruby at all
8022 className: "variable",
8023 begin: '(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])' + `(?![A-Za-z])(?![@$?'])`
8024 },
8025 {
8026 className: 'params',
8027 begin: /\|/,
8028 end: /\|/,
8029 relevance:0, // this could be a lot of things (in other languages) other than params
8030 keywords: RUBY_KEYWORDS
8031 },
8032 { // regexp container
8033 begin: '(' + hljs.RE_STARTERS_RE + '|unless)\\s*',
8034 keywords: 'unless',
8035 contains: [
8036 {
8037 className: 'regexp',
8038 contains: [hljs.BACKSLASH_ESCAPE, SUBST],
8039 illegal: /\n/,
8040 variants: [
8041 {begin: '/', end: '/[a-z]*'},
8042 {begin: /%r\{/, end: /\}[a-z]*/},
8043 {begin: '%r\\(', end: '\\)[a-z]*'},
8044 {begin: '%r!', end: '![a-z]*'},
8045 {begin: '%r\\[', end: '\\][a-z]*'}
8046 ]
8047 }
8048 ].concat(IRB_OBJECT, COMMENT_MODES),
8049 relevance: 0
8050 }
8051 ].concat(IRB_OBJECT, COMMENT_MODES);
8052
8053 SUBST.contains = RUBY_DEFAULT_CONTAINS;
8054 PARAMS.contains = RUBY_DEFAULT_CONTAINS;
8055
8056 // >>
8057 // ?>
8058 var SIMPLE_PROMPT = "[>?]>";
8059 // irb(main):001:0>
8060 var DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+>";
8061 var RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>";
8062
8063 var IRB_DEFAULT = [
8064 {
8065 begin: /^\s*=>/,
8066 starts: {
8067 end: '$', contains: RUBY_DEFAULT_CONTAINS
8068 }
8069 },
8070 {
8071 className: 'meta',
8072 begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')(?=[ ])',
8073 starts: {
8074 end: '$', contains: RUBY_DEFAULT_CONTAINS
8075 }
8076 }
8077 ];
8078
8079 COMMENT_MODES.unshift(IRB_OBJECT);
8080
8081 return {
8082 name: 'Ruby',
8083 aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'],
8084 keywords: RUBY_KEYWORDS,
8085 illegal: /\/\*/,
8086 contains: [
8087 hljs.SHEBANG({binary:"ruby"}),
8088 ]
8089 .concat(IRB_DEFAULT)
8090 .concat(COMMENT_MODES)
8091 .concat(RUBY_DEFAULT_CONTAINS)
8092 };
8093 }
8094
8095 return ruby;
8096
8097 return module.exports.definer || module.exports;
8098
8099}());
8100
8101hljs.registerLanguage('rust', function () {
8102 'use strict';
8103
8104 /*
8105 Language: Rust
8106 Author: Andrey Vlasovskikh <andrey.vlasovskikh@gmail.com>
8107 Contributors: Roman Shmatov <romanshmatov@gmail.com>, Kasper Andersen <kma_untrusted@protonmail.com>
8108 Website: https://www.rust-lang.org
8109 Category: common, system
8110 */
8111
8112 function rust(hljs) {
8113 const NUM_SUFFIX = '([ui](8|16|32|64|128|size)|f(32|64))\?';
8114 const KEYWORDS =
8115 'abstract as async await become box break const continue crate do dyn ' +
8116 'else enum extern false final fn for if impl in let loop macro match mod ' +
8117 'move mut override priv pub ref return self Self static struct super ' +
8118 'trait true try type typeof unsafe unsized use virtual where while yield';
8119 const BUILTINS =
8120 // functions
8121 'drop ' +
8122 // types
8123 'i8 i16 i32 i64 i128 isize ' +
8124 'u8 u16 u32 u64 u128 usize ' +
8125 'f32 f64 ' +
8126 'str char bool ' +
8127 'Box Option Result String Vec ' +
8128 // traits
8129 'Copy Send Sized Sync Drop Fn FnMut FnOnce ToOwned Clone Debug ' +
8130 'PartialEq PartialOrd Eq Ord AsRef AsMut Into From Default Iterator ' +
8131 'Extend IntoIterator DoubleEndedIterator ExactSizeIterator ' +
8132 'SliceConcatExt ToString ' +
8133 // macros
8134 'assert! assert_eq! bitflags! bytes! cfg! col! concat! concat_idents! ' +
8135 'debug_assert! debug_assert_eq! env! panic! file! format! format_args! ' +
8136 'include_bin! include_str! line! local_data_key! module_path! ' +
8137 'option_env! print! println! select! stringify! try! unimplemented! ' +
8138 'unreachable! vec! write! writeln! macro_rules! assert_ne! debug_assert_ne!';
8139 return {
8140 name: 'Rust',
8141 aliases: [ 'rs' ],
8142 keywords: {
8143 $pattern: hljs.IDENT_RE + '!?',
8144 keyword:
8145 KEYWORDS,
8146 literal:
8147 'true false Some None Ok Err',
8148 built_in:
8149 BUILTINS
8150 },
8151 illegal: '</',
8152 contains: [
8153 hljs.C_LINE_COMMENT_MODE,
8154 hljs.COMMENT('/\\*', '\\*/', {
8155 contains: [ 'self' ]
8156 }),
8157 hljs.inherit(hljs.QUOTE_STRING_MODE, {
8158 begin: /b?"/,
8159 illegal: null
8160 }),
8161 {
8162 className: 'string',
8163 variants: [
8164 {
8165 begin: /r(#*)"(.|\n)*?"\1(?!#)/
8166 },
8167 {
8168 begin: /b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/
8169 }
8170 ]
8171 },
8172 {
8173 className: 'symbol',
8174 begin: /'[a-zA-Z_][a-zA-Z0-9_]*/
8175 },
8176 {
8177 className: 'number',
8178 variants: [
8179 {
8180 begin: '\\b0b([01_]+)' + NUM_SUFFIX
8181 },
8182 {
8183 begin: '\\b0o([0-7_]+)' + NUM_SUFFIX
8184 },
8185 {
8186 begin: '\\b0x([A-Fa-f0-9_]+)' + NUM_SUFFIX
8187 },
8188 {
8189 begin: '\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)' +
8190 NUM_SUFFIX
8191 }
8192 ],
8193 relevance: 0
8194 },
8195 {
8196 className: 'function',
8197 beginKeywords: 'fn',
8198 end: '(\\(|<)',
8199 excludeEnd: true,
8200 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
8201 },
8202 {
8203 className: 'meta',
8204 begin: '#!?\\[',
8205 end: '\\]',
8206 contains: [
8207 {
8208 className: 'meta-string',
8209 begin: /"/,
8210 end: /"/
8211 }
8212 ]
8213 },
8214 {
8215 className: 'class',
8216 beginKeywords: 'type',
8217 end: ';',
8218 contains: [
8219 hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, {
8220 endsParent: true
8221 })
8222 ],
8223 illegal: '\\S'
8224 },
8225 {
8226 className: 'class',
8227 beginKeywords: 'trait enum struct union',
8228 end: /\{/,
8229 contains: [
8230 hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, {
8231 endsParent: true
8232 })
8233 ],
8234 illegal: '[\\w\\d]'
8235 },
8236 {
8237 begin: hljs.IDENT_RE + '::',
8238 keywords: {
8239 built_in: BUILTINS
8240 }
8241 },
8242 {
8243 begin: '->'
8244 }
8245 ]
8246 };
8247 }
8248
8249 return rust;
8250
8251 return module.exports.definer || module.exports;
8252
8253}());
8254
8255hljs.registerLanguage('scss', function () {
8256 'use strict';
8257
8258 /*
8259 Language: SCSS
8260 Description: Scss is an extension of the syntax of CSS.
8261 Author: Kurt Emch <kurt@kurtemch.com>
8262 Website: https://sass-lang.com
8263 Category: common, css
8264 */
8265 function scss(hljs) {
8266 var AT_IDENTIFIER = '@[a-z-]+'; // @font-face
8267 var AT_MODIFIERS = "and or not only";
8268 var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
8269 var VARIABLE = {
8270 className: 'variable',
8271 begin: '(\\$' + IDENT_RE + ')\\b'
8272 };
8273 var HEXCOLOR = {
8274 className: 'number', begin: '#[0-9A-Fa-f]+'
8275 };
8276 var DEF_INTERNALS = {
8277 className: 'attribute',
8278 begin: '[A-Z\\_\\.\\-]+', end: ':',
8279 excludeEnd: true,
8280 illegal: '[^\\s]',
8281 starts: {
8282 endsWithParent: true, excludeEnd: true,
8283 contains: [
8284 HEXCOLOR,
8285 hljs.CSS_NUMBER_MODE,
8286 hljs.QUOTE_STRING_MODE,
8287 hljs.APOS_STRING_MODE,
8288 hljs.C_BLOCK_COMMENT_MODE,
8289 {
8290 className: 'meta', begin: '!important'
8291 }
8292 ]
8293 }
8294 };
8295 return {
8296 name: 'SCSS',
8297 case_insensitive: true,
8298 illegal: '[=/|\']',
8299 contains: [
8300 hljs.C_LINE_COMMENT_MODE,
8301 hljs.C_BLOCK_COMMENT_MODE,
8302 {
8303 className: 'selector-id', begin: '#[A-Za-z0-9_-]+',
8304 relevance: 0
8305 },
8306 {
8307 className: 'selector-class', begin: '\\.[A-Za-z0-9_-]+',
8308 relevance: 0
8309 },
8310 {
8311 className: 'selector-attr', begin: '\\[', end: '\\]',
8312 illegal: '$'
8313 },
8314 {
8315 className: 'selector-tag', // begin: IDENT_RE, end: '[,|\\s]'
8316 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',
8317 relevance: 0
8318 },
8319 {
8320 className: 'selector-pseudo',
8321 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)'
8322 },
8323 {
8324 className: 'selector-pseudo',
8325 begin: '::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)'
8326 },
8327 VARIABLE,
8328 {
8329 className: 'attribute',
8330 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',
8331 illegal: '[^\\s]'
8332 },
8333 {
8334 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'
8335 },
8336 {
8337 begin: ':', end: ';',
8338 contains: [
8339 VARIABLE,
8340 HEXCOLOR,
8341 hljs.CSS_NUMBER_MODE,
8342 hljs.QUOTE_STRING_MODE,
8343 hljs.APOS_STRING_MODE,
8344 {
8345 className: 'meta', begin: '!important'
8346 }
8347 ]
8348 },
8349 // matching these here allows us to treat them more like regular CSS
8350 // rules so everything between the {} gets regular rule highlighting,
8351 // which is what we want for page and font-face
8352 {
8353 begin: '@(page|font-face)',
8354 lexemes: AT_IDENTIFIER,
8355 keywords: '@page @font-face'
8356 },
8357 {
8358 begin: '@', end: '[{;]',
8359 returnBegin: true,
8360 keywords: AT_MODIFIERS,
8361 contains: [
8362 {
8363 begin: AT_IDENTIFIER,
8364 className: "keyword"
8365 },
8366 VARIABLE,
8367 hljs.QUOTE_STRING_MODE,
8368 hljs.APOS_STRING_MODE,
8369 HEXCOLOR,
8370 hljs.CSS_NUMBER_MODE,
8371 // {
8372 // begin: '\\s[A-Za-z0-9_.-]+',
8373 // relevance: 0
8374 // }
8375 ]
8376 }
8377 ]
8378 };
8379 }
8380
8381 return scss;
8382
8383 return module.exports.definer || module.exports;
8384
8385}());
8386
8387hljs.registerLanguage('shell', function () {
8388 'use strict';
8389
8390 /*
8391 Language: Shell Session
8392 Requires: bash.js
8393 Author: TSUYUSATO Kitsune <make.just.on@gmail.com>
8394 Category: common
8395 Audit: 2020
8396 */
8397
8398 /** @type LanguageFn */
8399 function shell(hljs) {
8400 return {
8401 name: 'Shell Session',
8402 aliases: [ 'console' ],
8403 contains: [
8404 {
8405 className: 'meta',
8406 // We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result.
8407 // For instance, in the following example, it would match "echo /path/to/home >" as a prompt:
8408 // echo /path/to/home > t.exe
8409 begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#]/,
8410 starts: {
8411 end: /[^\\](?=\s*$)/,
8412 subLanguage: 'bash'
8413 }
8414 }
8415 ]
8416 };
8417 }
8418
8419 return shell;
8420
8421 return module.exports.definer || module.exports;
8422
8423}());
8424
8425hljs.registerLanguage('sql', function () {
8426 'use strict';
8427
8428 /*
8429 Language: SQL
8430 Contributors: Nikolay Lisienko <info@neor.ru>, Heiko August <post@auge8472.de>, Travis Odom <travis.a.odom@gmail.com>, Vadimtro <vadimtro@yahoo.com>, Benjamin Auder <benjamin.auder@gmail.com>
8431 Website: https://en.wikipedia.org/wiki/SQL
8432 Category: common
8433 */
8434
8435 function sql(hljs) {
8436 var COMMENT_MODE = hljs.COMMENT('--', '$');
8437 return {
8438 name: 'SQL',
8439 case_insensitive: true,
8440 illegal: /[<>{}*]/,
8441 contains: [
8442 {
8443 beginKeywords:
8444 'begin end start commit rollback savepoint lock alter create drop rename call ' +
8445 'delete do handler insert load replace select truncate update set show pragma grant ' +
8446 'merge describe use explain help declare prepare execute deallocate release ' +
8447 'unlock purge reset change stop analyze cache flush optimize repair kill ' +
8448 'install uninstall checksum restore check backup revoke comment values with',
8449 end: /;/, endsWithParent: true,
8450 keywords: {
8451 $pattern: /[\w\.]+/,
8452 keyword:
8453 'as abort abs absolute acc acce accep accept access accessed accessible account acos action activate add ' +
8454 'addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias ' +
8455 'all allocate allow alter always analyze ancillary and anti any anydata anydataset anyschema anytype apply ' +
8456 'archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan ' +
8457 'atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid ' +
8458 'authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile ' +
8459 'before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float ' +
8460 'binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound ' +
8461 'bucket buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel ' +
8462 'capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base ' +
8463 'char_length character_length characters characterset charindex charset charsetform charsetid check ' +
8464 'checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close ' +
8465 'cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation ' +
8466 'collect colu colum column column_value columns columns_updated comment commit compact compatibility ' +
8467 'compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn ' +
8468 'connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection ' +
8469 'consider consistent constant constraint constraints constructor container content contents context ' +
8470 'contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost ' +
8471 'count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation ' +
8472 'critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user ' +
8473 'cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add ' +
8474 'date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts ' +
8475 'day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate ' +
8476 'declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults ' +
8477 'deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank ' +
8478 'depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor ' +
8479 'deterministic diagnostics difference dimension direct_load directory disable disable_all ' +
8480 'disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div ' +
8481 'do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable ' +
8482 'editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt ' +
8483 'end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors ' +
8484 'escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding ' +
8485 'execu execut execute exempt exists exit exp expire explain explode export export_set extended extent external ' +
8486 'external_1 external_2 externally extract failed failed_login_attempts failover failure far fast ' +
8487 'feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final ' +
8488 'finish first first_value fixed flash_cache flashback floor flush following follows for forall force foreign ' +
8489 'form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ' +
8490 'ftp full function general generated get get_format get_lock getdate getutcdate global global_name ' +
8491 'globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups ' +
8492 'gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex ' +
8493 'hierarchy high high_priority hosts hour hours http id ident_current ident_incr ident_seed identified ' +
8494 'identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment ' +
8495 'index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile ' +
8496 'initial initialized initially initrans inmemory inner innodb input insert install instance instantiable ' +
8497 'instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat ' +
8498 'is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists ' +
8499 'keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lateral lax lcase ' +
8500 'lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit ' +
8501 'lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate ' +
8502 'locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call ' +
8503 'logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime ' +
8504 'managed management manual map mapping mask master master_pos_wait match matched materialized max ' +
8505 'maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans ' +
8506 'md5 measures median medium member memcompress memory merge microsecond mid migration min minextents ' +
8507 'minimum mining minus minute minutes minvalue missing mod mode model modification modify module monitoring month ' +
8508 'months mount move movement multiset mutex name name_const names nan national native natural nav nchar ' +
8509 'nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile ' +
8510 'nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile ' +
8511 'nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder ' +
8512 'nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck ' +
8513 'noswitch not nothing notice notnull notrim novalidate now nowait nth_value nullif nulls num numb numbe ' +
8514 'nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ' +
8515 'ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old ' +
8516 'on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date ' +
8517 'oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary ' +
8518 'out outer outfile outline output over overflow overriding package pad parallel parallel_enable ' +
8519 'parameters parent parse partial partition partitions pascal passing password password_grace_time ' +
8520 'password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex ' +
8521 'pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc ' +
8522 'performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin ' +
8523 'policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction ' +
8524 'prediction_cost prediction_details prediction_probability prediction_set prepare present preserve ' +
8525 'prior priority private private_sga privileges procedural procedure procedure_analyze processlist ' +
8526 'profiles project prompt protection public publishingservername purge quarter query quick quiesce quota ' +
8527 'quotename radians raise rand range rank raw read reads readsize rebuild record records ' +
8528 'recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh ' +
8529 'regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy ' +
8530 'reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename ' +
8531 'repair repeat replace replicate replication required reset resetlogs resize resource respect restore ' +
8532 'restricted result result_cache resumable resume retention return returning returns reuse reverse revoke ' +
8533 'right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows ' +
8534 'rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll ' +
8535 'sdo_georaster sdo_topo_geometry search sec_to_time second seconds section securefile security seed segment select ' +
8536 'self semi sequence sequential serializable server servererror session session_user sessions_per_user set ' +
8537 'sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor ' +
8538 'si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin ' +
8539 'size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex ' +
8540 'source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows ' +
8541 'sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone ' +
8542 'standby start starting startup statement static statistics stats_binomial_test stats_crosstab ' +
8543 'stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep ' +
8544 'stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev ' +
8545 'stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate ' +
8546 'subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum ' +
8547 'suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate ' +
8548 'sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tablesample tan tdo ' +
8549 'template temporary terminated tertiary_weights test than then thread through tier ties time time_format ' +
8550 'time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr ' +
8551 'timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking ' +
8552 'transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate ' +
8553 'try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress ' +
8554 'under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unnest unpivot ' +
8555 'unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert ' +
8556 'url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date ' +
8557 'utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var ' +
8558 'var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray ' +
8559 'verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear ' +
8560 'wellformed when whene whenev wheneve whenever where while whitespace window with within without work wrapped ' +
8561 'xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces ' +
8562 'xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek',
8563 literal:
8564 'true false null unknown',
8565 built_in:
8566 'array bigint binary bit blob bool boolean char character date dec decimal float int int8 integer interval number ' +
8567 'numeric real record serial serial8 smallint text time timestamp tinyint varchar varchar2 varying void'
8568 },
8569 contains: [
8570 {
8571 className: 'string',
8572 begin: '\'', end: '\'',
8573 contains: [{begin: '\'\''}]
8574 },
8575 {
8576 className: 'string',
8577 begin: '"', end: '"',
8578 contains: [{begin: '""'}]
8579 },
8580 {
8581 className: 'string',
8582 begin: '`', end: '`'
8583 },
8584 hljs.C_NUMBER_MODE,
8585 hljs.C_BLOCK_COMMENT_MODE,
8586 COMMENT_MODE,
8587 hljs.HASH_COMMENT_MODE
8588 ]
8589 },
8590 hljs.C_BLOCK_COMMENT_MODE,
8591 COMMENT_MODE,
8592 hljs.HASH_COMMENT_MODE
8593 ]
8594 };
8595 }
8596
8597 return sql;
8598
8599 return module.exports.definer || module.exports;
8600
8601}());
8602
8603hljs.registerLanguage('swift', function () {
8604 'use strict';
8605
8606 /*
8607 Language: Swift
8608 Description: Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
8609 Author: Chris Eidhof <chris@eidhof.nl>
8610 Contributors: Nate Cook <natecook@gmail.com>, Alexander Lichter <manniL@gmx.net>
8611 Website: https://swift.org
8612 Category: common, system
8613 */
8614
8615
8616 function swift(hljs) {
8617 var SWIFT_KEYWORDS = {
8618 // override the pattern since the default of of /\w+/ is not sufficient to
8619 // capture the keywords that start with the character "#"
8620 $pattern: /[\w#]+/,
8621 keyword: '#available #colorLiteral #column #else #elseif #endif #file ' +
8622 '#fileLiteral #function #if #imageLiteral #line #selector #sourceLocation ' +
8623 '_ __COLUMN__ __FILE__ __FUNCTION__ __LINE__ Any as as! as? associatedtype ' +
8624 'associativity break case catch class continue convenience default defer deinit didSet do ' +
8625 'dynamic dynamicType else enum extension fallthrough false fileprivate final for func ' +
8626 'get guard if import in indirect infix init inout internal is lazy left let ' +
8627 'mutating nil none nonmutating open operator optional override postfix precedence ' +
8628 'prefix private protocol Protocol public repeat required rethrows return ' +
8629 'right self Self set some static struct subscript super switch throw throws true ' +
8630 'try try! try? Type typealias unowned var weak where while willSet',
8631 literal: 'true false nil',
8632 built_in: 'abs advance alignof alignofValue anyGenerator assert assertionFailure ' +
8633 'bridgeFromObjectiveC bridgeFromObjectiveCUnconditional bridgeToObjectiveC ' +
8634 'bridgeToObjectiveCUnconditional c compactMap contains count countElements countLeadingZeros ' +
8635 'debugPrint debugPrintln distance dropFirst dropLast dump encodeBitsAsWords ' +
8636 'enumerate equal fatalError filter find getBridgedObjectiveCType getVaList ' +
8637 'indices insertionSort isBridgedToObjectiveC isBridgedVerbatimToObjectiveC ' +
8638 'isUniquelyReferenced isUniquelyReferencedNonObjC join lazy lexicographicalCompare ' +
8639 'map max maxElement min minElement numericCast overlaps partition posix ' +
8640 'precondition preconditionFailure print println quickSort readLine reduce reflect ' +
8641 'reinterpretCast reverse roundUpToAlignment sizeof sizeofValue sort split ' +
8642 'startsWith stride strideof strideofValue swap toString transcode ' +
8643 'underestimateCount unsafeAddressOf unsafeBitCast unsafeDowncast unsafeUnwrap ' +
8644 'unsafeReflect withExtendedLifetime withObjectAtPlusZero withUnsafePointer ' +
8645 'withUnsafePointerToObject withUnsafeMutablePointer withUnsafeMutablePointers ' +
8646 'withUnsafePointer withUnsafePointers withVaList zip'
8647 };
8648
8649 var TYPE = {
8650 className: 'type',
8651 begin: '\\b[A-Z][\\w\u00C0-\u02B8\']*',
8652 relevance: 0
8653 };
8654 // slightly more special to swift
8655 var OPTIONAL_USING_TYPE = {
8656 className: 'type',
8657 begin: '\\b[A-Z][\\w\u00C0-\u02B8\']*[!?]'
8658 };
8659 var BLOCK_COMMENT = hljs.COMMENT(
8660 '/\\*',
8661 '\\*/',
8662 {
8663 contains: ['self']
8664 }
8665 );
8666 var SUBST = {
8667 className: 'subst',
8668 begin: /\\\(/, end: '\\)',
8669 keywords: SWIFT_KEYWORDS,
8670 contains: [] // assigned later
8671 };
8672 var STRING = {
8673 className: 'string',
8674 contains: [hljs.BACKSLASH_ESCAPE, SUBST],
8675 variants: [
8676 {begin: /"""/, end: /"""/},
8677 {begin: /"/, end: /"/},
8678 ]
8679 };
8680
8681 // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#grammar_numeric-literal
8682 // TODO: Update for leading `-` after lookbehind is supported everywhere
8683 var decimalDigits = '([0-9]_*)+';
8684 var hexDigits = '([0-9a-fA-F]_*)+';
8685 var NUMBER = {
8686 className: 'number',
8687 relevance: 0,
8688 variants: [
8689 // decimal floating-point-literal (subsumes decimal-literal)
8690 { begin: `\\b(${decimalDigits})(\\.(${decimalDigits}))?` +
8691 `([eE][+-]?(${decimalDigits}))?\\b` },
8692
8693 // hexadecimal floating-point-literal (subsumes hexadecimal-literal)
8694 { begin: `\\b0x(${hexDigits})(\\.(${hexDigits}))?` +
8695 `([pP][+-]?(${decimalDigits}))?\\b` },
8696
8697 // octal-literal
8698 { begin: /\b0o([0-7]_*)+\b/ },
8699
8700 // binary-literal
8701 { begin: /\b0b([01]_*)+\b/ },
8702 ]
8703 };
8704 SUBST.contains = [NUMBER];
8705
8706 return {
8707 name: 'Swift',
8708 keywords: SWIFT_KEYWORDS,
8709 contains: [
8710 STRING,
8711 hljs.C_LINE_COMMENT_MODE,
8712 BLOCK_COMMENT,
8713 OPTIONAL_USING_TYPE,
8714 TYPE,
8715 NUMBER,
8716 {
8717 className: 'function',
8718 beginKeywords: 'func', end: /\{/, excludeEnd: true,
8719 contains: [
8720 hljs.inherit(hljs.TITLE_MODE, {
8721 begin: /[A-Za-z$_][0-9A-Za-z$_]*/
8722 }),
8723 {
8724 begin: /</, end: />/
8725 },
8726 {
8727 className: 'params',
8728 begin: /\(/, end: /\)/, endsParent: true,
8729 keywords: SWIFT_KEYWORDS,
8730 contains: [
8731 'self',
8732 NUMBER,
8733 STRING,
8734 hljs.C_BLOCK_COMMENT_MODE,
8735 {begin: ':'} // relevance booster
8736 ],
8737 illegal: /["']/
8738 }
8739 ],
8740 illegal: /\[|%/
8741 },
8742 {
8743 className: 'class',
8744 beginKeywords: 'struct protocol class extension enum',
8745 keywords: SWIFT_KEYWORDS,
8746 end: '\\{',
8747 excludeEnd: true,
8748 contains: [
8749 hljs.inherit(hljs.TITLE_MODE, {begin: /[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/})
8750 ]
8751 },
8752 {
8753 className: 'meta', // @attributes
8754 begin: '(@discardableResult|@warn_unused_result|@exported|@lazy|@noescape|' +
8755 '@NSCopying|@NSManaged|@objc|@objcMembers|@convention|@required|' +
8756 '@noreturn|@IBAction|@IBDesignable|@IBInspectable|@IBOutlet|' +
8757 '@infix|@prefix|@postfix|@autoclosure|@testable|@available|' +
8758 '@nonobjc|@NSApplicationMain|@UIApplicationMain|@dynamicMemberLookup|' +
8759 '@propertyWrapper|@main)\\b'
8760
8761 },
8762 {
8763 beginKeywords: 'import', end: /$/,
8764 contains: [hljs.C_LINE_COMMENT_MODE, BLOCK_COMMENT],
8765 relevance: 0
8766 }
8767 ]
8768 };
8769 }
8770
8771 return swift;
8772
8773 return module.exports.definer || module.exports;
8774
8775}());
8776
8777hljs.registerLanguage('typescript', function () {
8778 'use strict';
8779
8780 const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
8781 const KEYWORDS = [
8782 "as", // for exports
8783 "in",
8784 "of",
8785 "if",
8786 "for",
8787 "while",
8788 "finally",
8789 "var",
8790 "new",
8791 "function",
8792 "do",
8793 "return",
8794 "void",
8795 "else",
8796 "break",
8797 "catch",
8798 "instanceof",
8799 "with",
8800 "throw",
8801 "case",
8802 "default",
8803 "try",
8804 "switch",
8805 "continue",
8806 "typeof",
8807 "delete",
8808 "let",
8809 "yield",
8810 "const",
8811 "class",
8812 // JS handles these with a special rule
8813 // "get",
8814 // "set",
8815 "debugger",
8816 "async",
8817 "await",
8818 "static",
8819 "import",
8820 "from",
8821 "export",
8822 "extends"
8823 ];
8824 const LITERALS = [
8825 "true",
8826 "false",
8827 "null",
8828 "undefined",
8829 "NaN",
8830 "Infinity"
8831 ];
8832
8833 const TYPES = [
8834 "Intl",
8835 "DataView",
8836 "Number",
8837 "Math",
8838 "Date",
8839 "String",
8840 "RegExp",
8841 "Object",
8842 "Function",
8843 "Boolean",
8844 "Error",
8845 "Symbol",
8846 "Set",
8847 "Map",
8848 "WeakSet",
8849 "WeakMap",
8850 "Proxy",
8851 "Reflect",
8852 "JSON",
8853 "Promise",
8854 "Float64Array",
8855 "Int16Array",
8856 "Int32Array",
8857 "Int8Array",
8858 "Uint16Array",
8859 "Uint32Array",
8860 "Float32Array",
8861 "Array",
8862 "Uint8Array",
8863 "Uint8ClampedArray",
8864 "ArrayBuffer"
8865 ];
8866
8867 const ERROR_TYPES = [
8868 "EvalError",
8869 "InternalError",
8870 "RangeError",
8871 "ReferenceError",
8872 "SyntaxError",
8873 "TypeError",
8874 "URIError"
8875 ];
8876
8877 const BUILT_IN_GLOBALS = [
8878 "setInterval",
8879 "setTimeout",
8880 "clearInterval",
8881 "clearTimeout",
8882
8883 "require",
8884 "exports",
8885
8886 "eval",
8887 "isFinite",
8888 "isNaN",
8889 "parseFloat",
8890 "parseInt",
8891 "decodeURI",
8892 "decodeURIComponent",
8893 "encodeURI",
8894 "encodeURIComponent",
8895 "escape",
8896 "unescape"
8897 ];
8898
8899 const BUILT_IN_VARIABLES = [
8900 "arguments",
8901 "this",
8902 "super",
8903 "console",
8904 "window",
8905 "document",
8906 "localStorage",
8907 "module",
8908 "global" // Node.js
8909 ];
8910
8911 const BUILT_INS = [].concat(
8912 BUILT_IN_GLOBALS,
8913 BUILT_IN_VARIABLES,
8914 TYPES,
8915 ERROR_TYPES
8916 );
8917
8918 /**
8919 * @param {string} value
8920 * @returns {RegExp}
8921 * */
8922
8923 /**
8924 * @param {RegExp | string } re
8925 * @returns {string}
8926 */
8927 function source(re) {
8928 if (!re) return null;
8929 if (typeof re === "string") return re;
8930
8931 return re.source;
8932 }
8933
8934 /**
8935 * @param {RegExp | string } re
8936 * @returns {string}
8937 */
8938 function lookahead(re) {
8939 return concat('(?=', re, ')');
8940 }
8941
8942 /**
8943 * @param {...(RegExp | string) } args
8944 * @returns {string}
8945 */
8946 function concat(...args) {
8947 const joined = args.map((x) => source(x)).join("");
8948 return joined;
8949 }
8950
8951 /*
8952 Language: JavaScript
8953 Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
8954 Category: common, scripting
8955 Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
8956 */
8957
8958 /** @type LanguageFn */
8959 function javascript(hljs) {
8960 /**
8961 * Takes a string like "<Booger" and checks to see
8962 * if we can find a matching "</Booger" later in the
8963 * content.
8964 * @param {RegExpMatchArray} match
8965 * @param {{after:number}} param1
8966 */
8967 const hasClosingTag = (match, { after }) => {
8968 const tag = "</" + match[0].slice(1);
8969 const pos = match.input.indexOf(tag, after);
8970 return pos !== -1;
8971 };
8972
8973 const IDENT_RE$1 = IDENT_RE;
8974 const FRAGMENT = {
8975 begin: '<>',
8976 end: '</>'
8977 };
8978 const XML_TAG = {
8979 begin: /<[A-Za-z0-9\\._:-]+/,
8980 end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
8981 /**
8982 * @param {RegExpMatchArray} match
8983 * @param {CallbackResponse} response
8984 */
8985 isTrulyOpeningTag: (match, response) => {
8986 const afterMatchIndex = match[0].length + match.index;
8987 const nextChar = match.input[afterMatchIndex];
8988 // nested type?
8989 // HTML should not include another raw `<` inside a tag
8990 // But a type might: `<Array<Array<number>>`, etc.
8991 if (nextChar === "<") {
8992 response.ignoreMatch();
8993 return;
8994 }
8995 // <something>
8996 // This is now either a tag or a type.
8997 if (nextChar === ">") {
8998 // if we cannot find a matching closing tag, then we
8999 // will ignore it
9000 if (!hasClosingTag(match, { after: afterMatchIndex })) {
9001 response.ignoreMatch();
9002 }
9003 }
9004 }
9005 };
9006 const KEYWORDS$1 = {
9007 $pattern: IDENT_RE,
9008 keyword: KEYWORDS.join(" "),
9009 literal: LITERALS.join(" "),
9010 built_in: BUILT_INS.join(" ")
9011 };
9012
9013 // https://tc39.es/ecma262/#sec-literals-numeric-literals
9014 const decimalDigits = '[0-9](_?[0-9])*';
9015 const frac = `\\.(${decimalDigits})`;
9016 // DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
9017 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
9018 const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
9019 const NUMBER = {
9020 className: 'number',
9021 variants: [
9022 // DecimalLiteral
9023 { begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))` +
9024 `[eE][+-]?(${decimalDigits})\\b` },
9025 { begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
9026
9027 // DecimalBigIntegerLiteral
9028 { begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
9029
9030 // NonDecimalIntegerLiteral
9031 { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
9032 { begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
9033 { begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
9034
9035 // LegacyOctalIntegerLiteral (does not include underscore separators)
9036 // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
9037 { begin: "\\b0[0-7]+n?\\b" },
9038 ],
9039 relevance: 0
9040 };
9041
9042 const SUBST = {
9043 className: 'subst',
9044 begin: '\\$\\{',
9045 end: '\\}',
9046 keywords: KEYWORDS$1,
9047 contains: [] // defined later
9048 };
9049 const HTML_TEMPLATE = {
9050 begin: 'html`',
9051 end: '',
9052 starts: {
9053 end: '`',
9054 returnEnd: false,
9055 contains: [
9056 hljs.BACKSLASH_ESCAPE,
9057 SUBST
9058 ],
9059 subLanguage: 'xml'
9060 }
9061 };
9062 const CSS_TEMPLATE = {
9063 begin: 'css`',
9064 end: '',
9065 starts: {
9066 end: '`',
9067 returnEnd: false,
9068 contains: [
9069 hljs.BACKSLASH_ESCAPE,
9070 SUBST
9071 ],
9072 subLanguage: 'css'
9073 }
9074 };
9075 const TEMPLATE_STRING = {
9076 className: 'string',
9077 begin: '`',
9078 end: '`',
9079 contains: [
9080 hljs.BACKSLASH_ESCAPE,
9081 SUBST
9082 ]
9083 };
9084 const JSDOC_COMMENT = hljs.COMMENT(
9085 '/\\*\\*',
9086 '\\*/',
9087 {
9088 relevance: 0,
9089 contains: [
9090 {
9091 className: 'doctag',
9092 begin: '@[A-Za-z]+',
9093 contains: [
9094 {
9095 className: 'type',
9096 begin: '\\{',
9097 end: '\\}',
9098 relevance: 0
9099 },
9100 {
9101 className: 'variable',
9102 begin: IDENT_RE$1 + '(?=\\s*(-)|$)',
9103 endsParent: true,
9104 relevance: 0
9105 },
9106 // eat spaces (not newlines) so we can find
9107 // types or variables
9108 {
9109 begin: /(?=[^\n])\s/,
9110 relevance: 0
9111 }
9112 ]
9113 }
9114 ]
9115 }
9116 );
9117 const COMMENT = {
9118 className: "comment",
9119 variants: [
9120 JSDOC_COMMENT,
9121 hljs.C_BLOCK_COMMENT_MODE,
9122 hljs.C_LINE_COMMENT_MODE
9123 ]
9124 };
9125 const SUBST_INTERNALS = [
9126 hljs.APOS_STRING_MODE,
9127 hljs.QUOTE_STRING_MODE,
9128 HTML_TEMPLATE,
9129 CSS_TEMPLATE,
9130 TEMPLATE_STRING,
9131 NUMBER,
9132 hljs.REGEXP_MODE
9133 ];
9134 SUBST.contains = SUBST_INTERNALS
9135 .concat({
9136 // we need to pair up {} inside our subst to prevent
9137 // it from ending too early by matching another }
9138 begin: /\{/,
9139 end: /\}/,
9140 keywords: KEYWORDS$1,
9141 contains: [
9142 "self"
9143 ].concat(SUBST_INTERNALS)
9144 });
9145 const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
9146 const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
9147 // eat recursive parens in sub expressions
9148 {
9149 begin: /\(/,
9150 end: /\)/,
9151 keywords: KEYWORDS$1,
9152 contains: ["self"].concat(SUBST_AND_COMMENTS)
9153 }
9154 ]);
9155 const PARAMS = {
9156 className: 'params',
9157 begin: /\(/,
9158 end: /\)/,
9159 excludeBegin: true,
9160 excludeEnd: true,
9161 keywords: KEYWORDS$1,
9162 contains: PARAMS_CONTAINS
9163 };
9164
9165 return {
9166 name: 'Javascript',
9167 aliases: ['js', 'jsx', 'mjs', 'cjs'],
9168 keywords: KEYWORDS$1,
9169 // this will be extended by TypeScript
9170 exports: { PARAMS_CONTAINS },
9171 illegal: /#(?![$_A-z])/,
9172 contains: [
9173 hljs.SHEBANG({
9174 label: "shebang",
9175 binary: "node",
9176 relevance: 5
9177 }),
9178 {
9179 label: "use_strict",
9180 className: 'meta',
9181 relevance: 10,
9182 begin: /^\s*['"]use (strict|asm)['"]/
9183 },
9184 hljs.APOS_STRING_MODE,
9185 hljs.QUOTE_STRING_MODE,
9186 HTML_TEMPLATE,
9187 CSS_TEMPLATE,
9188 TEMPLATE_STRING,
9189 COMMENT,
9190 NUMBER,
9191 { // object attr container
9192 begin: concat(/[{,\n]\s*/,
9193 // we need to look ahead to make sure that we actually have an
9194 // attribute coming up so we don't steal a comma from a potential
9195 // "value" container
9196 //
9197 // NOTE: this might not work how you think. We don't actually always
9198 // enter this mode and stay. Instead it might merely match `,
9199 // <comments up next>` and then immediately end after the , because it
9200 // fails to find any actual attrs. But this still does the job because
9201 // it prevents the value contain rule from grabbing this instead and
9202 // prevening this rule from firing when we actually DO have keys.
9203 lookahead(concat(
9204 // we also need to allow for multiple possible comments inbetween
9205 // the first key:value pairing
9206 /(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,
9207 IDENT_RE$1 + '\\s*:'))),
9208 relevance: 0,
9209 contains: [
9210 {
9211 className: 'attr',
9212 begin: IDENT_RE$1 + lookahead('\\s*:'),
9213 relevance: 0
9214 }
9215 ]
9216 },
9217 { // "value" container
9218 begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
9219 keywords: 'return throw case',
9220 contains: [
9221 COMMENT,
9222 hljs.REGEXP_MODE,
9223 {
9224 className: 'function',
9225 // we have to count the parens to make sure we actually have the
9226 // correct bounding ( ) before the =>. There could be any number of
9227 // sub-expressions inside also surrounded by parens.
9228 begin: '(\\(' +
9229 '[^()]*(\\(' +
9230 '[^()]*(\\(' +
9231 '[^()]*' +
9232 '\\)[^()]*)*' +
9233 '\\)[^()]*)*' +
9234 '\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>',
9235 returnBegin: true,
9236 end: '\\s*=>',
9237 contains: [
9238 {
9239 className: 'params',
9240 variants: [
9241 {
9242 begin: hljs.UNDERSCORE_IDENT_RE,
9243 relevance: 0
9244 },
9245 {
9246 className: null,
9247 begin: /\(\s*\)/,
9248 skip: true
9249 },
9250 {
9251 begin: /\(/,
9252 end: /\)/,
9253 excludeBegin: true,
9254 excludeEnd: true,
9255 keywords: KEYWORDS$1,
9256 contains: PARAMS_CONTAINS
9257 }
9258 ]
9259 }
9260 ]
9261 },
9262 { // could be a comma delimited list of params to a function call
9263 begin: /,/, relevance: 0
9264 },
9265 {
9266 className: '',
9267 begin: /\s/,
9268 end: /\s*/,
9269 skip: true
9270 },
9271 { // JSX
9272 variants: [
9273 { begin: FRAGMENT.begin, end: FRAGMENT.end },
9274 {
9275 begin: XML_TAG.begin,
9276 // we carefully check the opening tag to see if it truly
9277 // is a tag and not a false positive
9278 'on:begin': XML_TAG.isTrulyOpeningTag,
9279 end: XML_TAG.end
9280 }
9281 ],
9282 subLanguage: 'xml',
9283 contains: [
9284 {
9285 begin: XML_TAG.begin,
9286 end: XML_TAG.end,
9287 skip: true,
9288 contains: ['self']
9289 }
9290 ]
9291 }
9292 ],
9293 relevance: 0
9294 },
9295 {
9296 className: 'function',
9297 beginKeywords: 'function',
9298 end: /[{;]/,
9299 excludeEnd: true,
9300 keywords: KEYWORDS$1,
9301 contains: [
9302 'self',
9303 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
9304 PARAMS
9305 ],
9306 illegal: /%/
9307 },
9308 {
9309 // prevent this from getting swallowed up by function
9310 // since they appear "function like"
9311 beginKeywords: "while if switch catch for"
9312 },
9313 {
9314 className: 'function',
9315 // we have to count the parens to make sure we actually have the correct
9316 // bounding ( ). There could be any number of sub-expressions inside
9317 // also surrounded by parens.
9318 begin: hljs.UNDERSCORE_IDENT_RE +
9319 '\\(' + // first parens
9320 '[^()]*(\\(' +
9321 '[^()]*(\\(' +
9322 '[^()]*' +
9323 '\\)[^()]*)*' +
9324 '\\)[^()]*)*' +
9325 '\\)\\s*\\{', // end parens
9326 returnBegin:true,
9327 contains: [
9328 PARAMS,
9329 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
9330 ]
9331 },
9332 // hack: prevents detection of keywords in some circumstances
9333 // .keyword()
9334 // $keyword = x
9335 {
9336 variants: [
9337 { begin: '\\.' + IDENT_RE$1 },
9338 { begin: '\\$' + IDENT_RE$1 }
9339 ],
9340 relevance: 0
9341 },
9342 { // ES6 class
9343 className: 'class',
9344 beginKeywords: 'class',
9345 end: /[{;=]/,
9346 excludeEnd: true,
9347 illegal: /[:"[\]]/,
9348 contains: [
9349 { beginKeywords: 'extends' },
9350 hljs.UNDERSCORE_TITLE_MODE
9351 ]
9352 },
9353 {
9354 begin: /\b(?=constructor)/,
9355 end: /[{;]/,
9356 excludeEnd: true,
9357 contains: [
9358 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
9359 'self',
9360 PARAMS
9361 ]
9362 },
9363 {
9364 begin: '(get|set)\\s+(?=' + IDENT_RE$1 + '\\()',
9365 end: /\{/,
9366 keywords: "get set",
9367 contains: [
9368 hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1 }),
9369 { begin: /\(\)/ }, // eat to avoid empty params
9370 PARAMS
9371 ]
9372 },
9373 {
9374 begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
9375 }
9376 ]
9377 };
9378 }
9379
9380 /*
9381 Language: TypeScript
9382 Author: Panu Horsmalahti <panu.horsmalahti@iki.fi>
9383 Contributors: Ike Ku <dempfi@yahoo.com>
9384 Description: TypeScript is a strict superset of JavaScript
9385 Website: https://www.typescriptlang.org
9386 Category: common, scripting
9387 */
9388
9389 /** @type LanguageFn */
9390 function typescript(hljs) {
9391 const IDENT_RE$1 = IDENT_RE;
9392 const NAMESPACE = {
9393 beginKeywords: 'namespace', end: /\{/, excludeEnd: true
9394 };
9395 const INTERFACE = {
9396 beginKeywords: 'interface', end: /\{/, excludeEnd: true,
9397 keywords: 'interface extends'
9398 };
9399 const USE_STRICT = {
9400 className: 'meta',
9401 relevance: 10,
9402 begin: /^\s*['"]use strict['"]/
9403 };
9404 const TYPES = [
9405 "any",
9406 "void",
9407 "number",
9408 "boolean",
9409 "string",
9410 "object",
9411 "never",
9412 "enum"
9413 ];
9414 const TS_SPECIFIC_KEYWORDS = [
9415 "type",
9416 "namespace",
9417 "typedef",
9418 "interface",
9419 "public",
9420 "private",
9421 "protected",
9422 "implements",
9423 "declare",
9424 "abstract",
9425 "readonly"
9426 ];
9427 const KEYWORDS$1 = {
9428 $pattern: IDENT_RE,
9429 keyword: KEYWORDS.concat(TS_SPECIFIC_KEYWORDS).join(" "),
9430 literal: LITERALS.join(" "),
9431 built_in: BUILT_INS.concat(TYPES).join(" ")
9432 };
9433 const DECORATOR = {
9434 className: 'meta',
9435 begin: '@' + IDENT_RE$1,
9436 };
9437
9438 const swapMode = (mode, label, replacement) => {
9439 const indx = mode.contains.findIndex(m => m.label === label);
9440 if (indx === -1) { throw new Error("can not find mode to replace"); }
9441 mode.contains.splice(indx, 1, replacement);
9442 };
9443
9444 const tsLanguage = javascript(hljs);
9445
9446 // this should update anywhere keywords is used since
9447 // it will be the same actual JS object
9448 Object.assign(tsLanguage.keywords, KEYWORDS$1);
9449
9450 tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR);
9451 tsLanguage.contains = tsLanguage.contains.concat([
9452 DECORATOR,
9453 NAMESPACE,
9454 INTERFACE,
9455 ]);
9456
9457 // TS gets a simpler shebang rule than JS
9458 swapMode(tsLanguage, "shebang", hljs.SHEBANG());
9459 // JS use strict rule purposely excludes `asm` which makes no sense
9460 swapMode(tsLanguage, "use_strict", USE_STRICT);
9461
9462 const functionDeclaration = tsLanguage.contains.find(m => m.className === "function");
9463 functionDeclaration.relevance = 0; // () => {} is more typical in TypeScript
9464
9465 Object.assign(tsLanguage, {
9466 name: 'TypeScript',
9467 aliases: ['ts']
9468 });
9469
9470 return tsLanguage;
9471 }
9472
9473 return typescript;
9474
9475 return module.exports.definer || module.exports;
9476
9477}());
9478
9479hljs.registerLanguage('yaml', function () {
9480 'use strict';
9481
9482 /*
9483 Language: YAML
9484 Description: Yet Another Markdown Language
9485 Author: Stefan Wienert <stwienert@gmail.com>
9486 Contributors: Carl Baxter <carl@cbax.tech>
9487 Requires: ruby.js
9488 Website: https://yaml.org
9489 Category: common, config
9490 */
9491 function yaml(hljs) {
9492 var LITERALS = 'true false yes no null';
9493
9494 // YAML spec allows non-reserved URI characters in tags.
9495 var URI_CHARACTERS = '[\\w#;/?:@&=+$,.~*\'()[\\]]+';
9496
9497 // Define keys as starting with a word character
9498 // ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
9499 // ...and ending with a colon followed immediately by a space, tab or newline.
9500 // The YAML spec allows for much more than this, but this covers most use-cases.
9501 var KEY = {
9502 className: 'attr',
9503 variants: [
9504 { begin: '\\w[\\w :\\/.-]*:(?=[ \t]|$)' },
9505 { begin: '"\\w[\\w :\\/.-]*":(?=[ \t]|$)' }, // double quoted keys
9506 { begin: '\'\\w[\\w :\\/.-]*\':(?=[ \t]|$)' } // single quoted keys
9507 ]
9508 };
9509
9510 var TEMPLATE_VARIABLES = {
9511 className: 'template-variable',
9512 variants: [
9513 { begin: /\{\{/, end: /\}\}/ }, // jinja templates Ansible
9514 { begin: /%\{/, end: /\}/ } // Ruby i18n
9515 ]
9516 };
9517 var STRING = {
9518 className: 'string',
9519 relevance: 0,
9520 variants: [
9521 { begin: /'/, end: /'/ },
9522 { begin: /"/, end: /"/ },
9523 { begin: /\S+/ }
9524 ],
9525 contains: [
9526 hljs.BACKSLASH_ESCAPE,
9527 TEMPLATE_VARIABLES
9528 ]
9529 };
9530
9531 // Strings inside of value containers (objects) can't contain braces,
9532 // brackets, or commas
9533 var CONTAINER_STRING = hljs.inherit(STRING, {
9534 variants: [
9535 { begin: /'/, end: /'/ },
9536 { begin: /"/, end: /"/ },
9537 { begin: /[^\s,{}[\]]+/ }
9538 ]
9539 });
9540
9541 var DATE_RE = '[0-9]{4}(-[0-9][0-9]){0,2}';
9542 var TIME_RE = '([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?';
9543 var FRACTION_RE = '(\\.[0-9]*)?';
9544 var ZONE_RE = '([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?';
9545 var TIMESTAMP = {
9546 className: 'number',
9547 begin: '\\b' + DATE_RE + TIME_RE + FRACTION_RE + ZONE_RE + '\\b'
9548 };
9549
9550 var VALUE_CONTAINER = {
9551 end: ',',
9552 endsWithParent: true,
9553 excludeEnd: true,
9554 contains: [],
9555 keywords: LITERALS,
9556 relevance: 0
9557 };
9558 var OBJECT = {
9559 begin: /\{/,
9560 end: /\}/,
9561 contains: [VALUE_CONTAINER],
9562 illegal: '\\n',
9563 relevance: 0
9564 };
9565 var ARRAY = {
9566 begin: '\\[',
9567 end: '\\]',
9568 contains: [VALUE_CONTAINER],
9569 illegal: '\\n',
9570 relevance: 0
9571 };
9572
9573 var MODES = [
9574 KEY,
9575 {
9576 className: 'meta',
9577 begin: '^---\\s*$',
9578 relevance: 10
9579 },
9580 { // multi line string
9581 // Blocks start with a | or > followed by a newline
9582 //
9583 // Indentation of subsequent lines must be the same to
9584 // be considered part of the block
9585 className: 'string',
9586 begin: '[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*'
9587 },
9588 { // Ruby/Rails erb
9589 begin: '<%[%=-]?',
9590 end: '[%-]?%>',
9591 subLanguage: 'ruby',
9592 excludeBegin: true,
9593 excludeEnd: true,
9594 relevance: 0
9595 },
9596 { // named tags
9597 className: 'type',
9598 begin: '!\\w+!' + URI_CHARACTERS
9599 },
9600 // https://yaml.org/spec/1.2/spec.html#id2784064
9601 { // verbatim tags
9602 className: 'type',
9603 begin: '!<' + URI_CHARACTERS + ">"
9604 },
9605 { // primary tags
9606 className: 'type',
9607 begin: '!' + URI_CHARACTERS
9608 },
9609 { // secondary tags
9610 className: 'type',
9611 begin: '!!' + URI_CHARACTERS
9612 },
9613 { // fragment id &ref
9614 className: 'meta',
9615 begin: '&' + hljs.UNDERSCORE_IDENT_RE + '$'
9616 },
9617 { // fragment reference *ref
9618 className: 'meta',
9619 begin: '\\*' + hljs.UNDERSCORE_IDENT_RE + '$'
9620 },
9621 { // array listing
9622 className: 'bullet',
9623 // TODO: remove |$ hack when we have proper look-ahead support
9624 begin: '-(?=[ ]|$)',
9625 relevance: 0
9626 },
9627 hljs.HASH_COMMENT_MODE,
9628 {
9629 beginKeywords: LITERALS,
9630 keywords: { literal: LITERALS }
9631 },
9632 TIMESTAMP,
9633 // numbers are any valid C-style number that
9634 // sit isolated from other words
9635 {
9636 className: 'number',
9637 begin: hljs.C_NUMBER_RE + '\\b',
9638 relevance: 0
9639 },
9640 OBJECT,
9641 ARRAY,
9642 STRING
9643 ];
9644
9645 var VALUE_MODES = [...MODES];
9646 VALUE_MODES.pop();
9647 VALUE_MODES.push(CONTAINER_STRING);
9648 VALUE_CONTAINER.contains = VALUE_MODES;
9649
9650 return {
9651 name: 'YAML',
9652 case_insensitive: true,
9653 aliases: ['yml', 'YAML'],
9654 contains: MODES
9655 };
9656 }
9657
9658 return yaml;
9659
9660 return module.exports.definer || module.exports;
9661
9662}());