1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | var Prism = (function () {
|
23 |
|
24 |
|
25 | var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
|
26 | var uniqueId = 0;
|
27 |
|
28 |
|
29 | var plainTextGrammar = {};
|
30 |
|
31 |
|
32 | var _ = {
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | util: {
|
43 | encode: function encode(tokens) {
|
44 | if (tokens instanceof Token) {
|
45 | return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
46 | } else if (Array.isArray(tokens)) {
|
47 | return tokens.map(encode);
|
48 | } else {
|
49 | return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
50 | }
|
51 | },
|
52 |
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | type: function (o) {
|
70 | return Object.prototype.toString.call(o).slice(8, -1);
|
71 | },
|
72 |
|
73 | |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | objId: function (obj) {
|
80 | if (!obj['__id']) {
|
81 | Object.defineProperty(obj, '__id', { value: ++uniqueId });
|
82 | }
|
83 | return obj['__id'];
|
84 | },
|
85 |
|
86 | |
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | clone: function deepClone(o, visited) {
|
97 | visited = visited || {};
|
98 |
|
99 | var clone; var id;
|
100 | switch (_.util.type(o)) {
|
101 | case 'Object':
|
102 | id = _.util.objId(o);
|
103 | if (visited[id]) {
|
104 | return visited[id];
|
105 | }
|
106 | clone = ({});
|
107 | visited[id] = clone;
|
108 |
|
109 | for (var key in o) {
|
110 | if (o.hasOwnProperty(key)) {
|
111 | clone[key] = deepClone(o[key], visited);
|
112 | }
|
113 | }
|
114 |
|
115 | return (clone);
|
116 |
|
117 | case 'Array':
|
118 | id = _.util.objId(o);
|
119 | if (visited[id]) {
|
120 | return visited[id];
|
121 | }
|
122 | clone = [];
|
123 | visited[id] = clone;
|
124 |
|
125 | (((o))).forEach(function (v, i) {
|
126 | clone[i] = deepClone(v, visited);
|
127 | });
|
128 |
|
129 | return (clone);
|
130 |
|
131 | default:
|
132 | return o;
|
133 | }
|
134 | },
|
135 |
|
136 | |
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | getLanguage: function (element) {
|
145 | while (element) {
|
146 | var m = lang.exec(element.className);
|
147 | if (m) {
|
148 | return m[1].toLowerCase();
|
149 | }
|
150 | element = element.parentElement;
|
151 | }
|
152 | return 'none';
|
153 | },
|
154 |
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | setLanguage: function (element, language) {
|
163 |
|
164 |
|
165 | element.className = element.className.replace(RegExp(lang, 'gi'), '');
|
166 |
|
167 |
|
168 |
|
169 | element.classList.add('language-' + language);
|
170 | },
|
171 |
|
172 | |
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 | isActive: function (element, className, defaultActivation) {
|
192 | var no = 'no-' + className;
|
193 |
|
194 | while (element) {
|
195 | var classList = element.classList;
|
196 | if (classList.contains(className)) {
|
197 | return true;
|
198 | }
|
199 | if (classList.contains(no)) {
|
200 | return false;
|
201 | }
|
202 | element = element.parentElement;
|
203 | }
|
204 | return !!defaultActivation;
|
205 | }
|
206 | },
|
207 |
|
208 | |
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 | languages: {
|
216 | |
217 |
|
218 |
|
219 | plain: plainTextGrammar,
|
220 | plaintext: plainTextGrammar,
|
221 | text: plainTextGrammar,
|
222 | txt: plainTextGrammar,
|
223 |
|
224 | |
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 | extend: function (id, redef) {
|
253 | var lang = _.util.clone(_.languages[id]);
|
254 |
|
255 | for (var key in redef) {
|
256 | lang[key] = redef[key];
|
257 | }
|
258 |
|
259 | return lang;
|
260 | },
|
261 |
|
262 | |
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 | insertBefore: function (inside, before, insert, root) {
|
338 | root = root || (_.languages);
|
339 | var grammar = root[inside];
|
340 |
|
341 | var ret = {};
|
342 |
|
343 | for (var token in grammar) {
|
344 | if (grammar.hasOwnProperty(token)) {
|
345 |
|
346 | if (token == before) {
|
347 | for (var newToken in insert) {
|
348 | if (insert.hasOwnProperty(newToken)) {
|
349 | ret[newToken] = insert[newToken];
|
350 | }
|
351 | }
|
352 | }
|
353 |
|
354 |
|
355 | if (!insert.hasOwnProperty(token)) {
|
356 | ret[token] = grammar[token];
|
357 | }
|
358 | }
|
359 | }
|
360 |
|
361 | var old = root[inside];
|
362 | root[inside] = ret;
|
363 |
|
364 |
|
365 | _.languages.DFS(_.languages, function (key, value) {
|
366 | if (value === old && key != inside) {
|
367 | this[key] = ret;
|
368 | }
|
369 | });
|
370 |
|
371 | return ret;
|
372 | },
|
373 |
|
374 |
|
375 | DFS: function DFS(o, callback, type, visited) {
|
376 | visited = visited || {};
|
377 |
|
378 | var objId = _.util.objId;
|
379 |
|
380 | for (var i in o) {
|
381 | if (o.hasOwnProperty(i)) {
|
382 | callback.call(o, i, o[i], type || i);
|
383 |
|
384 | var property = o[i];
|
385 | var propertyType = _.util.type(property);
|
386 |
|
387 | if (propertyType === 'Object' && !visited[objId(property)]) {
|
388 | visited[objId(property)] = true;
|
389 | DFS(property, callback, null, visited);
|
390 | } else if (propertyType === 'Array' && !visited[objId(property)]) {
|
391 | visited[objId(property)] = true;
|
392 | DFS(property, callback, i, visited);
|
393 | }
|
394 | }
|
395 | }
|
396 | }
|
397 | },
|
398 |
|
399 | plugins: {},
|
400 |
|
401 |
|
402 | |
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | highlight: function (text, grammar, language) {
|
423 | var env = {
|
424 | code: text,
|
425 | grammar: grammar,
|
426 | language: language
|
427 | };
|
428 | _.hooks.run('before-tokenize', env);
|
429 | env.tokens = _.tokenize(env.code, env.grammar);
|
430 | _.hooks.run('after-tokenize', env);
|
431 | return Token.stringify(_.util.encode(env.tokens), env.language);
|
432 | },
|
433 |
|
434 | |
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | tokenize: function (text, grammar) {
|
459 | var rest = grammar.rest;
|
460 | if (rest) {
|
461 | for (var token in rest) {
|
462 | grammar[token] = rest[token];
|
463 | }
|
464 |
|
465 | delete grammar.rest;
|
466 | }
|
467 |
|
468 | var tokenList = new LinkedList();
|
469 | addAfter(tokenList, tokenList.head, text);
|
470 |
|
471 | matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
472 |
|
473 | return toArray(tokenList);
|
474 | },
|
475 |
|
476 | |
477 |
|
478 |
|
479 |
|
480 |
|
481 | hooks: {
|
482 | all: {},
|
483 |
|
484 | |
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 | add: function (name, callback) {
|
497 | var hooks = _.hooks.all;
|
498 |
|
499 | hooks[name] = hooks[name] || [];
|
500 |
|
501 | hooks[name].push(callback);
|
502 | },
|
503 |
|
504 | |
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 | run: function (name, env) {
|
514 | var callbacks = _.hooks.all[name];
|
515 |
|
516 | if (!callbacks || !callbacks.length) {
|
517 | return;
|
518 | }
|
519 |
|
520 | for (var i = 0, callback; (callback = callbacks[i++]);) {
|
521 | callback(env);
|
522 | }
|
523 | }
|
524 | },
|
525 |
|
526 | Token: Token
|
527 | };
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 | |
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 | function Token(type, content, alias, matchedStr) {
|
547 | |
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 | this.type = type;
|
557 | |
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 | this.content = content;
|
566 | |
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 | this.alias = alias;
|
574 |
|
575 | this.length = (matchedStr || '').length | 0;
|
576 | }
|
577 |
|
578 | |
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 | |
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 | Token.stringify = function stringify(o, language) {
|
607 | if (typeof o == 'string') {
|
608 | return o;
|
609 | }
|
610 | if (Array.isArray(o)) {
|
611 | var s = '';
|
612 | o.forEach(function (e) {
|
613 | s += stringify(e, language);
|
614 | });
|
615 | return s;
|
616 | }
|
617 |
|
618 | var env = {
|
619 | type: o.type,
|
620 | content: stringify(o.content, language),
|
621 | tag: 'span',
|
622 | classes: ['token', o.type],
|
623 | attributes: {},
|
624 | language: language
|
625 | };
|
626 |
|
627 | var aliases = o.alias;
|
628 | if (aliases) {
|
629 | if (Array.isArray(aliases)) {
|
630 | Array.prototype.push.apply(env.classes, aliases);
|
631 | } else {
|
632 | env.classes.push(aliases);
|
633 | }
|
634 | }
|
635 |
|
636 | _.hooks.run('wrap', env);
|
637 |
|
638 | var attributes = '';
|
639 | for (var name in env.attributes) {
|
640 | attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
|
641 | }
|
642 |
|
643 | return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
|
644 | };
|
645 |
|
646 | |
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 | function matchPattern(pattern, pos, text, lookbehind) {
|
654 | pattern.lastIndex = pos;
|
655 | var match = pattern.exec(text);
|
656 | if (match && lookbehind && match[1]) {
|
657 |
|
658 | var lookbehindLength = match[1].length;
|
659 | match.index += lookbehindLength;
|
660 | match[0] = match[0].slice(lookbehindLength);
|
661 | }
|
662 | return match;
|
663 | }
|
664 |
|
665 | |
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 | function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
680 | for (var token in grammar) {
|
681 | if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
682 | continue;
|
683 | }
|
684 |
|
685 | var patterns = grammar[token];
|
686 | patterns = Array.isArray(patterns) ? patterns : [patterns];
|
687 |
|
688 | for (var j = 0; j < patterns.length; ++j) {
|
689 | if (rematch && rematch.cause == token + ',' + j) {
|
690 | return;
|
691 | }
|
692 |
|
693 | var patternObj = patterns[j];
|
694 | var inside = patternObj.inside;
|
695 | var lookbehind = !!patternObj.lookbehind;
|
696 | var greedy = !!patternObj.greedy;
|
697 | var alias = patternObj.alias;
|
698 |
|
699 | if (greedy && !patternObj.pattern.global) {
|
700 |
|
701 | var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
702 | patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
|
703 | }
|
704 |
|
705 |
|
706 | var pattern = patternObj.pattern || patternObj;
|
707 |
|
708 | for (
|
709 | var currentNode = startNode.next, pos = startPos;
|
710 | currentNode !== tokenList.tail;
|
711 | pos += currentNode.value.length, currentNode = currentNode.next
|
712 | ) {
|
713 |
|
714 | if (rematch && pos >= rematch.reach) {
|
715 | break;
|
716 | }
|
717 |
|
718 | var str = currentNode.value;
|
719 |
|
720 | if (tokenList.length > text.length) {
|
721 |
|
722 | return;
|
723 | }
|
724 |
|
725 | if (str instanceof Token) {
|
726 | continue;
|
727 | }
|
728 |
|
729 | var removeCount = 1;
|
730 | var match;
|
731 |
|
732 | if (greedy) {
|
733 | match = matchPattern(pattern, pos, text, lookbehind);
|
734 | if (!match || match.index >= text.length) {
|
735 | break;
|
736 | }
|
737 |
|
738 | var from = match.index;
|
739 | var to = match.index + match[0].length;
|
740 | var p = pos;
|
741 |
|
742 |
|
743 | p += currentNode.value.length;
|
744 | while (from >= p) {
|
745 | currentNode = currentNode.next;
|
746 | p += currentNode.value.length;
|
747 | }
|
748 |
|
749 | p -= currentNode.value.length;
|
750 | pos = p;
|
751 |
|
752 |
|
753 | if (currentNode.value instanceof Token) {
|
754 | continue;
|
755 | }
|
756 |
|
757 |
|
758 | for (
|
759 | var k = currentNode;
|
760 | k !== tokenList.tail && (p < to || typeof k.value === 'string');
|
761 | k = k.next
|
762 | ) {
|
763 | removeCount++;
|
764 | p += k.value.length;
|
765 | }
|
766 | removeCount--;
|
767 |
|
768 |
|
769 | str = text.slice(pos, p);
|
770 | match.index -= pos;
|
771 | } else {
|
772 | match = matchPattern(pattern, 0, str, lookbehind);
|
773 | if (!match) {
|
774 | continue;
|
775 | }
|
776 | }
|
777 |
|
778 |
|
779 | var from = match.index;
|
780 | var matchStr = match[0];
|
781 | var before = str.slice(0, from);
|
782 | var after = str.slice(from + matchStr.length);
|
783 |
|
784 | var reach = pos + str.length;
|
785 | if (rematch && reach > rematch.reach) {
|
786 | rematch.reach = reach;
|
787 | }
|
788 |
|
789 | var removeFrom = currentNode.prev;
|
790 |
|
791 | if (before) {
|
792 | removeFrom = addAfter(tokenList, removeFrom, before);
|
793 | pos += before.length;
|
794 | }
|
795 |
|
796 | removeRange(tokenList, removeFrom, removeCount);
|
797 |
|
798 | var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
799 | currentNode = addAfter(tokenList, removeFrom, wrapped);
|
800 |
|
801 | if (after) {
|
802 | addAfter(tokenList, currentNode, after);
|
803 | }
|
804 |
|
805 | if (removeCount > 1) {
|
806 |
|
807 |
|
808 |
|
809 |
|
810 | var nestedRematch = {
|
811 | cause: token + ',' + j,
|
812 | reach: reach
|
813 | };
|
814 | matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
815 |
|
816 |
|
817 | if (rematch && nestedRematch.reach > rematch.reach) {
|
818 | rematch.reach = nestedRematch.reach;
|
819 | }
|
820 | }
|
821 | }
|
822 | }
|
823 | }
|
824 | }
|
825 |
|
826 | |
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 |
|
834 |
|
835 | |
836 |
|
837 |
|
838 |
|
839 | function LinkedList() {
|
840 |
|
841 | var head = { value: null, prev: null, next: null };
|
842 |
|
843 | var tail = { value: null, prev: head, next: null };
|
844 | head.next = tail;
|
845 |
|
846 |
|
847 | this.head = head;
|
848 |
|
849 | this.tail = tail;
|
850 | this.length = 0;
|
851 | }
|
852 |
|
853 | |
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 | function addAfter(list, node, value) {
|
863 |
|
864 | var next = node.next;
|
865 |
|
866 | var newNode = { value: value, prev: node, next: next };
|
867 | node.next = newNode;
|
868 | next.prev = newNode;
|
869 | list.length++;
|
870 |
|
871 | return newNode;
|
872 | }
|
873 | |
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 | function removeRange(list, node, count) {
|
882 | var next = node.next;
|
883 | for (var i = 0; i < count && next !== list.tail; i++) {
|
884 | next = next.next;
|
885 | }
|
886 | node.next = next;
|
887 | next.prev = node;
|
888 | list.length -= i;
|
889 | }
|
890 | |
891 |
|
892 |
|
893 |
|
894 |
|
895 | function toArray(list) {
|
896 | var array = [];
|
897 | var node = list.head.next;
|
898 | while (node !== list.tail) {
|
899 | array.push(node.value);
|
900 | node = node.next;
|
901 | }
|
902 | return array;
|
903 | }
|
904 |
|
905 | return _;
|
906 |
|
907 | }());
|
908 |
|
909 | var prism = Prism;
|
910 | Prism.default = Prism;
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 | prism.languages.markup = {
|
917 | 'comment': {
|
918 | pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
919 | greedy: true
|
920 | },
|
921 | 'prolog': {
|
922 | pattern: /<\?[\s\S]+?\?>/,
|
923 | greedy: true
|
924 | },
|
925 | 'doctype': {
|
926 |
|
927 | pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
928 | greedy: true,
|
929 | inside: {
|
930 | 'internal-subset': {
|
931 | pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
932 | lookbehind: true,
|
933 | greedy: true,
|
934 | inside: null
|
935 |
|
936 | },
|
937 | 'string': {
|
938 | pattern: /"[^"]*"|'[^']*'/,
|
939 | greedy: true
|
940 | },
|
941 | 'punctuation': /^<!|>$|[[\]]/,
|
942 | 'doctype-tag': /^DOCTYPE/i,
|
943 | 'name': /[^\s<>'"]+/
|
944 | }
|
945 | },
|
946 | 'cdata': {
|
947 | pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
948 | greedy: true
|
949 | },
|
950 | 'tag': {
|
951 | pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
952 | greedy: true,
|
953 | inside: {
|
954 | 'tag': {
|
955 | pattern: /^<\/?[^\s>\/]+/,
|
956 | inside: {
|
957 | 'punctuation': /^<\/?/,
|
958 | 'namespace': /^[^\s>\/:]+:/
|
959 | }
|
960 | },
|
961 | 'special-attr': [],
|
962 | 'attr-value': {
|
963 | pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
964 | inside: {
|
965 | 'punctuation': [{
|
966 | pattern: /^=/,
|
967 | alias: 'attr-equals'
|
968 | }, /"|'/]
|
969 | }
|
970 | },
|
971 | 'punctuation': /\/?>/,
|
972 | 'attr-name': {
|
973 | pattern: /[^\s>\/]+/,
|
974 | inside: {
|
975 | 'namespace': /^[^\s>\/:]+:/
|
976 | }
|
977 | }
|
978 | }
|
979 | },
|
980 | 'entity': [{
|
981 | pattern: /&[\da-z]{1,8};/i,
|
982 | alias: 'named-entity'
|
983 | }, /&#x?[\da-f]{1,8};/i]
|
984 | };
|
985 | prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = prism.languages.markup['entity'];
|
986 | prism.languages.markup['doctype'].inside['internal-subset'].inside = prism.languages.markup;
|
987 |
|
988 | prism.hooks.add('wrap', function (env) {
|
989 | if (env.type === 'entity') {
|
990 | env.attributes['title'] = env.content.replace(/&/, '&');
|
991 | }
|
992 | });
|
993 | Object.defineProperty(prism.languages.markup.tag, 'addInlined', {
|
994 | |
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 | value: function addInlined(tagName, lang) {
|
1006 | var includedCdataInside = {};
|
1007 | includedCdataInside['language-' + lang] = {
|
1008 | pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
1009 | lookbehind: true,
|
1010 | inside: prism.languages[lang]
|
1011 | };
|
1012 | includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
|
1013 | var inside = {
|
1014 | 'included-cdata': {
|
1015 | pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
1016 | inside: includedCdataInside
|
1017 | }
|
1018 | };
|
1019 | inside['language-' + lang] = {
|
1020 | pattern: /[\s\S]+/,
|
1021 | inside: prism.languages[lang]
|
1022 | };
|
1023 | var def = {};
|
1024 | def[tagName] = {
|
1025 | pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () {
|
1026 | return tagName;
|
1027 | }), 'i'),
|
1028 | lookbehind: true,
|
1029 | greedy: true,
|
1030 | inside: inside
|
1031 | };
|
1032 | prism.languages.insertBefore('markup', 'cdata', def);
|
1033 | }
|
1034 | });
|
1035 | Object.defineProperty(prism.languages.markup.tag, 'addAttribute', {
|
1036 | |
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 | value: function (attrName, lang) {
|
1048 | prism.languages.markup.tag.inside['special-attr'].push({
|
1049 | pattern: RegExp(/(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, 'i'),
|
1050 | lookbehind: true,
|
1051 | inside: {
|
1052 | 'attr-name': /^[^\s=]+/,
|
1053 | 'attr-value': {
|
1054 | pattern: /=[\s\S]+/,
|
1055 | inside: {
|
1056 | 'value': {
|
1057 | pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
1058 | lookbehind: true,
|
1059 | alias: [lang, 'language-' + lang],
|
1060 | inside: prism.languages[lang]
|
1061 | },
|
1062 | 'punctuation': [{
|
1063 | pattern: /^=/,
|
1064 | alias: 'attr-equals'
|
1065 | }, /"|'/]
|
1066 | }
|
1067 | }
|
1068 | }
|
1069 | });
|
1070 | }
|
1071 | });
|
1072 | prism.languages.html = prism.languages.markup;
|
1073 | prism.languages.mathml = prism.languages.markup;
|
1074 | prism.languages.svg = prism.languages.markup;
|
1075 | prism.languages.xml = prism.languages.extend('markup', {});
|
1076 | prism.languages.ssml = prism.languages.xml;
|
1077 | prism.languages.atom = prism.languages.xml;
|
1078 | prism.languages.rss = prism.languages.xml;
|
1079 |
|
1080 |
|
1081 | (function (Prism) {
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 | var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
|
1087 | var commandAfterHeredoc = {
|
1088 | pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
1089 | lookbehind: true,
|
1090 | alias: 'punctuation',
|
1091 |
|
1092 | inside: null
|
1093 |
|
1094 | };
|
1095 | var insideString = {
|
1096 | 'bash': commandAfterHeredoc,
|
1097 | 'environment': {
|
1098 | pattern: RegExp('\\$' + envVars),
|
1099 | alias: 'constant'
|
1100 | },
|
1101 | 'variable': [
|
1102 | {
|
1103 | pattern: /\$?\(\([\s\S]+?\)\)/,
|
1104 | greedy: true,
|
1105 | inside: {
|
1106 |
|
1107 | 'variable': [{
|
1108 | pattern: /(^\$\(\([\s\S]+)\)\)/,
|
1109 | lookbehind: true
|
1110 | }, /^\$\(\(/],
|
1111 | 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
1112 |
|
1113 | 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
1114 |
|
1115 | 'punctuation': /\(\(?|\)\)?|,|;/
|
1116 | }
|
1117 | },
|
1118 | {
|
1119 | pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
1120 | greedy: true,
|
1121 | inside: {
|
1122 | 'variable': /^\$\(|^`|\)$|`$/
|
1123 | }
|
1124 | },
|
1125 | {
|
1126 | pattern: /\$\{[^}]+\}/,
|
1127 | greedy: true,
|
1128 | inside: {
|
1129 | 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
1130 | 'punctuation': /[\[\]]/,
|
1131 | 'environment': {
|
1132 | pattern: RegExp('(\\{)' + envVars),
|
1133 | lookbehind: true,
|
1134 | alias: 'constant'
|
1135 | }
|
1136 | }
|
1137 | }, /\$(?:\w+|[#?*!@$])/],
|
1138 |
|
1139 | 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
1140 | };
|
1141 | Prism.languages.bash = {
|
1142 | 'shebang': {
|
1143 | pattern: /^#!\s*\/.*/,
|
1144 | alias: 'important'
|
1145 | },
|
1146 | 'comment': {
|
1147 | pattern: /(^|[^"{\\$])#.*/,
|
1148 | lookbehind: true
|
1149 | },
|
1150 | 'function-name': [
|
1151 |
|
1152 |
|
1153 |
|
1154 | {
|
1155 |
|
1156 | pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
1157 | lookbehind: true,
|
1158 | alias: 'function'
|
1159 | }, {
|
1160 |
|
1161 | pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
|
1162 | alias: 'function'
|
1163 | }],
|
1164 |
|
1165 | 'for-or-select': {
|
1166 | pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
1167 | alias: 'variable',
|
1168 | lookbehind: true
|
1169 | },
|
1170 |
|
1171 |
|
1172 | 'assign-left': {
|
1173 | pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
|
1174 | inside: {
|
1175 | 'environment': {
|
1176 | pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
|
1177 | lookbehind: true,
|
1178 | alias: 'constant'
|
1179 | }
|
1180 | },
|
1181 | alias: 'variable',
|
1182 | lookbehind: true
|
1183 | },
|
1184 | 'string': [
|
1185 | {
|
1186 | pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
1187 | lookbehind: true,
|
1188 | greedy: true,
|
1189 | inside: insideString
|
1190 | },
|
1191 |
|
1192 | {
|
1193 | pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
1194 | lookbehind: true,
|
1195 | greedy: true,
|
1196 | inside: {
|
1197 | 'bash': commandAfterHeredoc
|
1198 | }
|
1199 | },
|
1200 | {
|
1201 |
|
1202 | pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
1203 | lookbehind: true,
|
1204 | greedy: true,
|
1205 | inside: insideString
|
1206 | }, {
|
1207 |
|
1208 | pattern: /(^|[^$\\])'[^']*'/,
|
1209 | lookbehind: true,
|
1210 | greedy: true
|
1211 | }, {
|
1212 |
|
1213 | pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
1214 | greedy: true,
|
1215 | inside: {
|
1216 | 'entity': insideString.entity
|
1217 | }
|
1218 | }],
|
1219 | 'environment': {
|
1220 | pattern: RegExp('\\$?' + envVars),
|
1221 | alias: 'constant'
|
1222 | },
|
1223 | 'variable': insideString.variable,
|
1224 | 'function': {
|
1225 | pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
|
1226 | lookbehind: true
|
1227 | },
|
1228 | 'keyword': {
|
1229 | pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
1230 | lookbehind: true
|
1231 | },
|
1232 |
|
1233 | 'builtin': {
|
1234 | pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
|
1235 | lookbehind: true,
|
1236 |
|
1237 | alias: 'class-name'
|
1238 | },
|
1239 | 'boolean': {
|
1240 | pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
|
1241 | lookbehind: true
|
1242 | },
|
1243 | 'file-descriptor': {
|
1244 | pattern: /\B&\d\b/,
|
1245 | alias: 'important'
|
1246 | },
|
1247 | 'operator': {
|
1248 |
|
1249 | pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
1250 | inside: {
|
1251 | 'file-descriptor': {
|
1252 | pattern: /^\d/,
|
1253 | alias: 'important'
|
1254 | }
|
1255 | }
|
1256 | },
|
1257 | 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
1258 | 'number': {
|
1259 | pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
1260 | lookbehind: true
|
1261 | }
|
1262 | };
|
1263 | commandAfterHeredoc.inside = Prism.languages.bash;
|
1264 |
|
1265 |
|
1266 | var toBeCopied = ['comment', 'function-name', 'for-or-select', 'assign-left', 'string', 'environment', 'function', 'keyword', 'builtin', 'boolean', 'file-descriptor', 'operator', 'punctuation', 'number'];
|
1267 | var inside = insideString.variable[1].inside;
|
1268 |
|
1269 | for (var i = 0; i < toBeCopied.length; i++) {
|
1270 | inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
|
1271 | }
|
1272 |
|
1273 | Prism.languages.shell = Prism.languages.bash;
|
1274 | })(prism);
|
1275 |
|
1276 |
|
1277 |
|
1278 | prism.languages.clike = {
|
1279 | 'comment': [{
|
1280 | pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
1281 | lookbehind: true,
|
1282 | greedy: true
|
1283 | }, {
|
1284 | pattern: /(^|[^\\:])\/\/.*/,
|
1285 | lookbehind: true,
|
1286 | greedy: true
|
1287 | }],
|
1288 | 'string': {
|
1289 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
1290 | greedy: true
|
1291 | },
|
1292 | 'class-name': {
|
1293 | pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
1294 | lookbehind: true,
|
1295 | inside: {
|
1296 | 'punctuation': /[.\\]/
|
1297 | }
|
1298 | },
|
1299 | 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
1300 | 'boolean': /\b(?:false|true)\b/,
|
1301 | 'function': /\b\w+(?=\()/,
|
1302 | 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
1303 | 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
1304 | 'punctuation': /[{}[\];(),.:]/
|
1305 | };
|
1306 |
|
1307 |
|
1308 | prism.languages.c = prism.languages.extend('clike', {
|
1309 | 'comment': {
|
1310 | pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
1311 | greedy: true
|
1312 | },
|
1313 | 'string': {
|
1314 |
|
1315 | pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
1316 | greedy: true
|
1317 | },
|
1318 | 'class-name': {
|
1319 | pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
1320 | lookbehind: true
|
1321 | },
|
1322 | 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
1323 | 'function': /\b[a-z_]\w*(?=\s*\()/i,
|
1324 | 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
1325 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
1326 | });
|
1327 | prism.languages.insertBefore('c', 'string', {
|
1328 | 'char': {
|
1329 |
|
1330 | pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
1331 | greedy: true
|
1332 | }
|
1333 | });
|
1334 | prism.languages.insertBefore('c', 'string', {
|
1335 | 'macro': {
|
1336 |
|
1337 |
|
1338 | pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
1339 | lookbehind: true,
|
1340 | greedy: true,
|
1341 | alias: 'property',
|
1342 | inside: {
|
1343 | 'string': [{
|
1344 |
|
1345 | pattern: /^(#\s*include\s*)<[^>]+>/,
|
1346 | lookbehind: true
|
1347 | }, prism.languages.c['string']],
|
1348 | 'char': prism.languages.c['char'],
|
1349 | 'comment': prism.languages.c['comment'],
|
1350 | 'macro-name': [{
|
1351 | pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
1352 | lookbehind: true
|
1353 | }, {
|
1354 | pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
1355 | lookbehind: true,
|
1356 | alias: 'function'
|
1357 | }],
|
1358 |
|
1359 | 'directive': {
|
1360 | pattern: /^(#\s*)[a-z]+/,
|
1361 | lookbehind: true,
|
1362 | alias: 'keyword'
|
1363 | },
|
1364 | 'directive-hash': /^#/,
|
1365 | 'punctuation': /##|\\(?=[\r\n])/,
|
1366 | 'expression': {
|
1367 | pattern: /\S[\s\S]*/,
|
1368 | inside: prism.languages.c
|
1369 | }
|
1370 | }
|
1371 | }
|
1372 | });
|
1373 | prism.languages.insertBefore('c', 'function', {
|
1374 |
|
1375 | 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
1376 | });
|
1377 | delete prism.languages.c['boolean'];
|
1378 |
|
1379 |
|
1380 | (function (Prism) {
|
1381 | var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
|
1382 | var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () {
|
1383 | return keyword.source;
|
1384 | });
|
1385 | Prism.languages.cpp = Prism.languages.extend('c', {
|
1386 | 'class-name': [{
|
1387 | pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g, function () {
|
1388 | return keyword.source;
|
1389 | })),
|
1390 | lookbehind: true
|
1391 | },
|
1392 |
|
1393 |
|
1394 |
|
1395 | /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
|
1396 |
|
1397 | /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
|
1398 |
|
1399 | /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],
|
1400 | 'keyword': keyword,
|
1401 | 'number': {
|
1402 | pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
|
1403 | greedy: true
|
1404 | },
|
1405 | 'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
|
1406 | 'boolean': /\b(?:false|true)\b/
|
1407 | });
|
1408 | Prism.languages.insertBefore('cpp', 'string', {
|
1409 | 'module': {
|
1410 | // https://en.cppreference.com/w/cpp/language/modules
|
1411 | pattern: RegExp(/(\b(?:import|module)\s+)/.source + '(?:' + // header-name
|
1412 | /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + '|' + // module name or partition or both
|
1413 | /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () {
|
1414 | return modName;
|
1415 | }) + ')'),
|
1416 | lookbehind: true,
|
1417 | greedy: true,
|
1418 | inside: {
|
1419 | 'string': /^[<"][\s\S]+/,
|
1420 | 'operator': /:/,
|
1421 | 'punctuation': /\./
|
1422 | }
|
1423 | },
|
1424 | 'raw-string': {
|
1425 | pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
|
1426 | alias: 'string',
|
1427 | greedy: true
|
1428 | }
|
1429 | });
|
1430 | Prism.languages.insertBefore('cpp', 'keyword', {
|
1431 | 'generic-function': {
|
1432 | pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
|
1433 | inside: {
|
1434 | 'function': /^\w+/,
|
1435 | 'generic': {
|
1436 | pattern: /<[\s\S]+/,
|
1437 | alias: 'class-name',
|
1438 | inside: Prism.languages.cpp
|
1439 | }
|
1440 | }
|
1441 | }
|
1442 | });
|
1443 | Prism.languages.insertBefore('cpp', 'operator', {
|
1444 | 'double-colon': {
|
1445 | pattern: /::/,
|
1446 | alias: 'punctuation'
|
1447 | }
|
1448 | });
|
1449 | Prism.languages.insertBefore('cpp', 'class-name', {
|
1450 | // the base clause is an optional list of parent classes
|
1451 | // https://en.cppreference.com/w/cpp/language/class
|
1452 | 'base-clause': {
|
1453 | pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
|
1454 | lookbehind: true,
|
1455 | greedy: true,
|
1456 | inside: Prism.languages.extend('cpp', {})
|
1457 | }
|
1458 | });
|
1459 | Prism.languages.insertBefore('inside', 'double-colon', {
|
1460 | // All untokenized words that are not namespaces should be class names
|
1461 | 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
|
1462 | }, Prism.languages.cpp['base-clause']);
|
1463 | })(prism);
|
1464 | /* "prismjs/components/prism-css" */
|
1465 |
|
1466 |
|
1467 | (function (Prism) {
|
1468 | var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
1469 | Prism.languages.css = {
|
1470 | 'comment': /\/\*[\s\S]*?\*\//,
|
1471 | 'atrule': {
|
1472 | pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
|
1473 | inside: {
|
1474 | 'rule': /^@[\w-]+/,
|
1475 | 'selector-function-argument': {
|
1476 | pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
1477 | lookbehind: true,
|
1478 | alias: 'selector'
|
1479 | },
|
1480 | 'keyword': {
|
1481 | pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
1482 | lookbehind: true
|
1483 | } // See rest below
|
1484 |
|
1485 | }
|
1486 | },
|
1487 | 'url': {
|
1488 | // https://drafts.csswg.org/css-values-3/#urls
|
1489 | pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
1490 | greedy: true,
|
1491 | inside: {
|
1492 | 'function': /^url/i,
|
1493 | 'punctuation': /^\(|\)$/,
|
1494 | 'string': {
|
1495 | pattern: RegExp('^' + string.source + '$'),
|
1496 | alias: 'url'
|
1497 | }
|
1498 | }
|
1499 | },
|
1500 | 'selector': {
|
1501 | pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
|
1502 | lookbehind: true
|
1503 | },
|
1504 | 'string': {
|
1505 | pattern: string,
|
1506 | greedy: true
|
1507 | },
|
1508 | 'property': {
|
1509 | pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
1510 | lookbehind: true
|
1511 | },
|
1512 | 'important': /!important\b/i,
|
1513 | 'function': {
|
1514 | pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
1515 | lookbehind: true
|
1516 | },
|
1517 | 'punctuation': /[(){};:,]/
|
1518 | };
|
1519 | Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
1520 | var markup = Prism.languages.markup;
|
1521 |
|
1522 | if (markup) {
|
1523 | markup.tag.addInlined('style', 'css');
|
1524 | markup.tag.addAttribute('style', 'css');
|
1525 | }
|
1526 | })(prism);
|
1527 | /* "prismjs/components/prism-css-extras" */
|
1528 |
|
1529 |
|
1530 | (function (Prism) {
|
1531 | var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
|
1532 | var selectorInside;
|
1533 | Prism.languages.css.selector = {
|
1534 | pattern: Prism.languages.css.selector.pattern,
|
1535 | lookbehind: true,
|
1536 | inside: selectorInside = {
|
1537 | 'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,
|
1538 | 'pseudo-class': /:[-\w]+/,
|
1539 | 'class': /\.[-\w]+/,
|
1540 | 'id': /#[-\w]+/,
|
1541 | 'attribute': {
|
1542 | pattern: RegExp('\\[(?:[^[\\]"\']|' + string.source + ')*\\]'),
|
1543 | greedy: true,
|
1544 | inside: {
|
1545 | 'punctuation': /^\[|\]$/,
|
1546 | 'case-sensitivity': {
|
1547 | pattern: /(\s)[si]$/i,
|
1548 | lookbehind: true,
|
1549 | alias: 'keyword'
|
1550 | },
|
1551 | 'namespace': {
|
1552 | pattern: /^(\s*)(?:(?!\s)[-*\w\xA0-\uFFFF])*\|(?!=)/,
|
1553 | lookbehind: true,
|
1554 | inside: {
|
1555 | 'punctuation': /\|$/
|
1556 | }
|
1557 | },
|
1558 | 'attr-name': {
|
1559 | pattern: /^(\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+/,
|
1560 | lookbehind: true
|
1561 | },
|
1562 | 'attr-value': [string, {
|
1563 | pattern: /(=\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+(?=\s*$)/,
|
1564 | lookbehind: true
|
1565 | }],
|
1566 | 'operator': /[|~*^$]?=/
|
1567 | }
|
1568 | },
|
1569 | 'n-th': [{
|
1570 | pattern: /(\(\s*)[+-]?\d*[\dn](?:\s*[+-]\s*\d+)?(?=\s*\))/,
|
1571 | lookbehind: true,
|
1572 | inside: {
|
1573 | 'number': /[\dn]+/,
|
1574 | 'operator': /[+-]/
|
1575 | }
|
1576 | }, {
|
1577 | pattern: /(\(\s*)(?:even|odd)(?=\s*\))/i,
|
1578 | lookbehind: true
|
1579 | }],
|
1580 | 'combinator': />|\+|~|\|\|/,
|
1581 | // the `tag` token has been existed and removed.
|
1582 | // because we can't find a perfect tokenize to match it.
|
1583 | // if you want to add it, please read https://github.com/PrismJS/prism/pull/2373 first.
|
1584 | 'punctuation': /[(),]/
|
1585 | }
|
1586 | };
|
1587 | Prism.languages.css['atrule'].inside['selector-function-argument'].inside = selectorInside;
|
1588 | Prism.languages.insertBefore('css', 'property', {
|
1589 | 'variable': {
|
1590 | pattern: /(^|[^-\w\xA0-\uFFFF])--(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*/i,
|
1591 | lookbehind: true
|
1592 | }
|
1593 | });
|
1594 | var unit = {
|
1595 | pattern: /(\b\d+)(?:%|[a-z]+(?![\w-]))/,
|
1596 | lookbehind: true
|
1597 | }; // 123 -123 .123 -.123 12.3 -12.3
|
1598 |
|
1599 | var number = {
|
1600 | pattern: /(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)/,
|
1601 | lookbehind: true
|
1602 | };
|
1603 | Prism.languages.insertBefore('css', 'function', {
|
1604 | 'operator': {
|
1605 | pattern: /(\s)[+\-*\/](?=\s)/,
|
1606 | lookbehind: true
|
1607 | },
|
1608 | // CAREFUL!
|
1609 | // Previewers and Inline color use hexcode and color.
|
1610 | 'hexcode': {
|
1611 | pattern: /\B#[\da-f]{3,8}\b/i,
|
1612 | alias: 'color'
|
1613 | },
|
1614 | 'color': [{
|
1615 | pattern: /(^|[^\w-])(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)(?![\w-])/i,
|
1616 | lookbehind: true
|
1617 | }, {
|
1618 | pattern: /\b(?:hsl|rgb)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:hsl|rgb)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,
|
1619 | inside: {
|
1620 | 'unit': unit,
|
1621 | 'number': number,
|
1622 | 'function': /[\w-]+(?=\()/,
|
1623 | 'punctuation': /[(),]/
|
1624 | }
|
1625 | }],
|
1626 | // it's important that there is no boundary assertion after the hex digits
|
1627 | 'entity': /\\[\da-f]{1,8}/i,
|
1628 | 'unit': unit,
|
1629 | 'number': number
|
1630 | });
|
1631 | })(prism);
|
1632 | /* "prismjs/components/prism-javascript" */
|
1633 |
|
1634 |
|
1635 | prism.languages.javascript = prism.languages.extend('clike', {
|
1636 | 'class-name': [prism.languages.clike['class-name'], {
|
1637 | pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
1638 | lookbehind: true
|
1639 | }],
|
1640 | 'keyword': [{
|
1641 | pattern: /((?:^|\})\s*)catch\b/,
|
1642 | lookbehind: true
|
1643 | }, {
|
1644 | pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
1645 | lookbehind: true
|
1646 | }],
|
1647 | // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
1648 | 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
1649 | 'number': {
|
1650 | pattern: RegExp(/(^|[^\w$])/.source + '(?:' + ( // constant
|
1651 | /NaN|Infinity/.source + '|' + // binary integer
|
1652 | /0[bB][01]+(?:_[01]+)*n?/.source + '|' + // octal integer
|
1653 | /0[oO][0-7]+(?:_[0-7]+)*n?/.source + '|' + // hexadecimal integer
|
1654 | /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + '|' + // decimal bigint
|
1655 | /\d+(?:_\d+)*n/.source + '|' + // decimal number (integer or float) but no bigint
|
1656 | /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ')' + /(?![\w$])/.source),
|
1657 | lookbehind: true
|
1658 | },
|
1659 | 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
1660 | });
|
1661 | prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
1662 | prism.languages.insertBefore('javascript', 'keyword', {
|
1663 | 'regex': {
|
1664 | // eslint-disable-next-line regexp/no-dupe-characters-character-class
|
1665 | pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
|
1666 | lookbehind: true,
|
1667 | greedy: true,
|
1668 | inside: {
|
1669 | 'regex-source': {
|
1670 | pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
1671 | lookbehind: true,
|
1672 | alias: 'language-regex',
|
1673 | inside: prism.languages.regex
|
1674 | },
|
1675 | 'regex-delimiter': /^\/|\/$/,
|
1676 | 'regex-flags': /^[a-z]+$/
|
1677 | }
|
1678 | },
|
1679 | // This must be declared before keyword because we use "function" inside the look-forward
|
1680 | 'function-variable': {
|
1681 | pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
1682 | alias: 'function'
|
1683 | },
|
1684 | 'parameter': [{
|
1685 | pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
1686 | lookbehind: true,
|
1687 | inside: prism.languages.javascript
|
1688 | }, {
|
1689 | pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
1690 | lookbehind: true,
|
1691 | inside: prism.languages.javascript
|
1692 | }, {
|
1693 | pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
1694 | lookbehind: true,
|
1695 | inside: prism.languages.javascript
|
1696 | }, {
|
1697 | pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
1698 | lookbehind: true,
|
1699 | inside: prism.languages.javascript
|
1700 | }],
|
1701 | 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
1702 | });
|
1703 | prism.languages.insertBefore('javascript', 'string', {
|
1704 | 'hashbang': {
|
1705 | pattern: /^#!.*/,
|
1706 | greedy: true,
|
1707 | alias: 'comment'
|
1708 | },
|
1709 | 'template-string': {
|
1710 | pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
1711 | greedy: true,
|
1712 | inside: {
|
1713 | 'template-punctuation': {
|
1714 | pattern: /^`|`$/,
|
1715 | alias: 'string'
|
1716 | },
|
1717 | 'interpolation': {
|
1718 | pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
1719 | lookbehind: true,
|
1720 | inside: {
|
1721 | 'interpolation-punctuation': {
|
1722 | pattern: /^\$\{|\}$/,
|
1723 | alias: 'punctuation'
|
1724 | },
|
1725 | rest: prism.languages.javascript
|
1726 | }
|
1727 | },
|
1728 | 'string': /[\s\S]+/
|
1729 | }
|
1730 | },
|
1731 | 'string-property': {
|
1732 | pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
1733 | lookbehind: true,
|
1734 | greedy: true,
|
1735 | alias: 'property'
|
1736 | }
|
1737 | });
|
1738 | prism.languages.insertBefore('javascript', 'operator', {
|
1739 | 'literal-property': {
|
1740 | pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
1741 | lookbehind: true,
|
1742 | alias: 'property'
|
1743 | }
|
1744 | });
|
1745 |
|
1746 | if (prism.languages.markup) {
|
1747 | prism.languages.markup.tag.addInlined('script', 'javascript'); // add attribute support for all DOM events.
|
1748 | // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
|
1749 |
|
1750 | prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 'javascript');
|
1751 | }
|
1752 |
|
1753 | prism.languages.js = prism.languages.javascript;
|
1754 | /* "prismjs/components/prism-coffeescript" */
|
1755 |
|
1756 | (function (Prism) {
|
1757 | // Ignore comments starting with { to privilege string interpolation highlighting
|
1758 | var comment = /#(?!\{).+/;
|
1759 | var interpolation = {
|
1760 | pattern: /#\{[^}]+\}/,
|
1761 | alias: 'variable'
|
1762 | };
|
1763 | Prism.languages.coffeescript = Prism.languages.extend('javascript', {
|
1764 | 'comment': comment,
|
1765 | 'string': [// Strings are multiline
|
1766 | {
|
1767 | pattern: /'(?:\\[\s\S]|[^\\'])*'/,
|
1768 | greedy: true
|
1769 | }, {
|
1770 | // Strings are multiline
|
1771 | pattern: /"(?:\\[\s\S]|[^\\"])*"/,
|
1772 | greedy: true,
|
1773 | inside: {
|
1774 | 'interpolation': interpolation
|
1775 | }
|
1776 | }],
|
1777 | 'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
|
1778 | 'class-member': {
|
1779 | pattern: /@(?!\d)\w+/,
|
1780 | alias: 'variable'
|
1781 | }
|
1782 | });
|
1783 | Prism.languages.insertBefore('coffeescript', 'comment', {
|
1784 | 'multiline-comment': {
|
1785 | pattern: /###[\s\S]+?###/,
|
1786 | alias: 'comment'
|
1787 | },
|
1788 | // Block regexp can contain comments and interpolation
|
1789 | 'block-regex': {
|
1790 | pattern: /\/{3}[\s\S]*?\/{3}/,
|
1791 | alias: 'regex',
|
1792 | inside: {
|
1793 | 'comment': comment,
|
1794 | 'interpolation': interpolation
|
1795 | }
|
1796 | }
|
1797 | });
|
1798 | Prism.languages.insertBefore('coffeescript', 'string', {
|
1799 | 'inline-javascript': {
|
1800 | pattern: /`(?:\\[\s\S]|[^\\`])*`/,
|
1801 | inside: {
|
1802 | 'delimiter': {
|
1803 | pattern: /^`|`$/,
|
1804 | alias: 'punctuation'
|
1805 | },
|
1806 | 'script': {
|
1807 | pattern: /[\s\S]+/,
|
1808 | alias: 'language-javascript',
|
1809 | inside: Prism.languages.javascript
|
1810 | }
|
1811 | }
|
1812 | },
|
1813 | // Block strings
|
1814 | 'multiline-string': [{
|
1815 | pattern: /'''[\s\S]*?'''/,
|
1816 | greedy: true,
|
1817 | alias: 'string'
|
1818 | }, {
|
1819 | pattern: /"""[\s\S]*?"""/,
|
1820 | greedy: true,
|
1821 | alias: 'string',
|
1822 | inside: {
|
1823 | interpolation: interpolation
|
1824 | }
|
1825 | }]
|
1826 | });
|
1827 | Prism.languages.insertBefore('coffeescript', 'keyword', {
|
1828 | // Object property
|
1829 | 'property': /(?!\d)\w+(?=\s*:(?!:))/
|
1830 | });
|
1831 | delete Prism.languages.coffeescript['template-string'];
|
1832 | Prism.languages.coffee = Prism.languages.coffeescript;
|
1833 | })(prism);
|
1834 | /* "prismjs/components/prism-yaml" */
|
1835 |
|
1836 |
|
1837 | (function (Prism) {
|
1838 | // https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
|
1839 | // https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
|
1840 | var anchorOrAlias = /[*&][^\s[\]{},]+/; // https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
|
1841 |
|
1842 | var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/; // https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
|
1843 |
|
1844 | var properties = '(?:' + tag.source + '(?:[ \t]+' + anchorOrAlias.source + ')?|' + anchorOrAlias.source + '(?:[ \t]+' + tag.source + ')?)'; // https://yaml.org/spec/1.2/spec.html#ns-plain(n,c)
|
1845 | // This is a simplified version that doesn't support "#" and multiline keys
|
1846 | // All these long scarry character classes are simplified versions of YAML's characters
|
1847 |
|
1848 | var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, function () {
|
1849 | return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
|
1850 | });
|
1851 | var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
|
1852 | /**
|
1853 | *
|
1854 | * @param {string} value
|
1855 | * @param {string} [flags]
|
1856 | * @returns {RegExp}
|
1857 | */
|
1858 |
|
1859 | function createValuePattern(value, flags) {
|
1860 | flags = (flags || '').replace(/m/g, '') + 'm'; // add m flag
|
1861 |
|
1862 | var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, function () {
|
1863 | return properties;
|
1864 | }).replace(/<<value>>/g, function () {
|
1865 | return value;
|
1866 | });
|
1867 | return RegExp(pattern, flags);
|
1868 | }
|
1869 |
|
1870 | Prism.languages.yaml = {
|
1871 | 'scalar': {
|
1872 | pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, function () {
|
1873 | return properties;
|
1874 | })),
|
1875 | lookbehind: true,
|
1876 | alias: 'string'
|
1877 | },
|
1878 | 'comment': /#.*/,
|
1879 | 'key': {
|
1880 | pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, function () {
|
1881 | return properties;
|
1882 | }).replace(/<<key>>/g, function () {
|
1883 | return '(?:' + plainKey + '|' + string + ')';
|
1884 | })),
|
1885 | lookbehind: true,
|
1886 | greedy: true,
|
1887 | alias: 'atrule'
|
1888 | },
|
1889 | 'directive': {
|
1890 | pattern: /(^[ \t]*)%.+/m,
|
1891 | lookbehind: true,
|
1892 | alias: 'important'
|
1893 | },
|
1894 | 'datetime': {
|
1895 | pattern: createValuePattern(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
|
1896 | lookbehind: true,
|
1897 | alias: 'number'
|
1898 | },
|
1899 | 'boolean': {
|
1900 | pattern: createValuePattern(/false|true/.source, 'i'),
|
1901 | lookbehind: true,
|
1902 | alias: 'important'
|
1903 | },
|
1904 | 'null': {
|
1905 | pattern: createValuePattern(/null|~/.source, 'i'),
|
1906 | lookbehind: true,
|
1907 | alias: 'important'
|
1908 | },
|
1909 | 'string': {
|
1910 | pattern: createValuePattern(string),
|
1911 | lookbehind: true,
|
1912 | greedy: true
|
1913 | },
|
1914 | 'number': {
|
1915 | pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, 'i'),
|
1916 | lookbehind: true
|
1917 | },
|
1918 | 'tag': tag,
|
1919 | 'important': anchorOrAlias,
|
1920 | 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
|
1921 | };
|
1922 | Prism.languages.yml = Prism.languages.yaml;
|
1923 | })(prism);
|
1924 | /* "prismjs/components/prism-markdown" */
|
1925 |
|
1926 |
|
1927 | (function (Prism) {
|
1928 | // Allow only one line break
|
1929 | var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;
|
1930 | /**
|
1931 | * This function is intended for the creation of the bold or italic pattern.
|
1932 | *
|
1933 | * This also adds a lookbehind group to the given pattern to ensure that the pattern is not backslash-escaped.
|
1934 | *
|
1935 | * _Note:_ Keep in mind that this adds a capturing group.
|
1936 | *
|
1937 | * @param {string} pattern
|
1938 | * @returns {RegExp}
|
1939 | */
|
1940 |
|
1941 | function createInline(pattern) {
|
1942 | pattern = pattern.replace(/<inner>/g, function () {
|
1943 | return inner;
|
1944 | });
|
1945 | return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')');
|
1946 | }
|
1947 |
|
1948 | var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
|
1949 | var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g, function () {
|
1950 | return tableCell;
|
1951 | });
|
1952 | var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;
|
1953 | Prism.languages.markdown = Prism.languages.extend('markup', {});
|
1954 | Prism.languages.insertBefore('markdown', 'prolog', {
|
1955 | 'front-matter-block': {
|
1956 | pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,
|
1957 | lookbehind: true,
|
1958 | greedy: true,
|
1959 | inside: {
|
1960 | 'punctuation': /^---|---$/,
|
1961 | 'front-matter': {
|
1962 | pattern: /\S+(?:\s+\S+)*/,
|
1963 | alias: ['yaml', 'language-yaml'],
|
1964 | inside: Prism.languages.yaml
|
1965 | }
|
1966 | }
|
1967 | },
|
1968 | 'blockquote': {
|
1969 | // > ...
|
1970 | pattern: /^>(?:[\t ]*>)*/m,
|
1971 | alias: 'punctuation'
|
1972 | },
|
1973 | 'table': {
|
1974 | pattern: RegExp('^' + tableRow + tableLine + '(?:' + tableRow + ')*', 'm'),
|
1975 | inside: {
|
1976 | 'table-data-rows': {
|
1977 | pattern: RegExp('^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$'),
|
1978 | lookbehind: true,
|
1979 | inside: {
|
1980 | 'table-data': {
|
1981 | pattern: RegExp(tableCell),
|
1982 | inside: Prism.languages.markdown
|
1983 | },
|
1984 | 'punctuation': /\|/
|
1985 | }
|
1986 | },
|
1987 | 'table-line': {
|
1988 | pattern: RegExp('^(' + tableRow + ')' + tableLine + '$'),
|
1989 | lookbehind: true,
|
1990 | inside: {
|
1991 | 'punctuation': /\||:?-{3,}:?/
|
1992 | }
|
1993 | },
|
1994 | 'table-header-row': {
|
1995 | pattern: RegExp('^' + tableRow + '$'),
|
1996 | inside: {
|
1997 | 'table-header': {
|
1998 | pattern: RegExp(tableCell),
|
1999 | alias: 'important',
|
2000 | inside: Prism.languages.markdown
|
2001 | },
|
2002 | 'punctuation': /\|/
|
2003 | }
|
2004 | }
|
2005 | }
|
2006 | },
|
2007 | 'code': [{
|
2008 | // Prefixed by 4 spaces or 1 tab and preceded by an empty line
|
2009 | pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,
|
2010 | lookbehind: true,
|
2011 | alias: 'keyword'
|
2012 | }, {
|
2013 | // ```optional language
|
2014 | // code block
|
2015 | // ```
|
2016 | pattern: /^```[\s\S]*?^```$/m,
|
2017 | greedy: true,
|
2018 | inside: {
|
2019 | 'code-block': {
|
2020 | pattern: /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,
|
2021 | lookbehind: true
|
2022 | },
|
2023 | 'code-language': {
|
2024 | pattern: /^(```).+/,
|
2025 | lookbehind: true
|
2026 | },
|
2027 | 'punctuation': /```/
|
2028 | }
|
2029 | }],
|
2030 | 'title': [{
|
2031 | // title 1
|
2032 | // =======
|
2033 | // title 2
|
2034 | // -------
|
2035 | pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,
|
2036 | alias: 'important',
|
2037 | inside: {
|
2038 | punctuation: /==+$|--+$/
|
2039 | }
|
2040 | }, {
|
2041 | // # title 1
|
2042 | // ###### title 6
|
2043 | pattern: /(^\s*)#.+/m,
|
2044 | lookbehind: true,
|
2045 | alias: 'important',
|
2046 | inside: {
|
2047 | punctuation: /^#+|#+$/
|
2048 | }
|
2049 | }],
|
2050 | 'hr': {
|
2051 | // ***
|
2052 | // ---
|
2053 | // * * *
|
2054 | // -----------
|
2055 | pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,
|
2056 | lookbehind: true,
|
2057 | alias: 'punctuation'
|
2058 | },
|
2059 | 'list': {
|
2060 | // * item
|
2061 | // + item
|
2062 | // - item
|
2063 | // 1. item
|
2064 | pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
|
2065 | lookbehind: true,
|
2066 | alias: 'punctuation'
|
2067 | },
|
2068 | 'url-reference': {
|
2069 | // [id]: http://example.com "Optional title"
|
2070 | // [id]: http://example.com 'Optional title'
|
2071 | // [id]: http://example.com (Optional title)
|
2072 | // [id]: <http://example.com> "Optional title"
|
2073 | pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
|
2074 | inside: {
|
2075 | 'variable': {
|
2076 | pattern: /^(!?\[)[^\]]+/,
|
2077 | lookbehind: true
|
2078 | },
|
2079 | 'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
|
2080 | 'punctuation': /^[\[\]!:]|[<>]/
|
2081 | },
|
2082 | alias: 'url'
|
2083 | },
|
2084 | 'bold': {
|
2085 | // **strong**
|
2086 | // __strong__
|
2087 | // allow one nested instance of italic text using the same delimiter
|
2088 | pattern: createInline(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),
|
2089 | lookbehind: true,
|
2090 | greedy: true,
|
2091 | inside: {
|
2092 | 'content': {
|
2093 | pattern: /(^..)[\s\S]+(?=..$)/,
|
2094 | lookbehind: true,
|
2095 | inside: {} // see below
|
2096 |
|
2097 | },
|
2098 | 'punctuation': /\*\*|__/
|
2099 | }
|
2100 | },
|
2101 | 'italic': {
|
2102 | // *em*
|
2103 | // _em_
|
2104 | // allow one nested instance of bold text using the same delimiter
|
2105 | pattern: createInline(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),
|
2106 | lookbehind: true,
|
2107 | greedy: true,
|
2108 | inside: {
|
2109 | 'content': {
|
2110 | pattern: /(^.)[\s\S]+(?=.$)/,
|
2111 | lookbehind: true,
|
2112 | inside: {} // see below
|
2113 |
|
2114 | },
|
2115 | 'punctuation': /[*_]/
|
2116 | }
|
2117 | },
|
2118 | 'strike': {
|
2119 | // ~~strike through~~
|
2120 | // ~strike~
|
2121 | // eslint-disable-next-line regexp/strict
|
2122 | pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source),
|
2123 | lookbehind: true,
|
2124 | greedy: true,
|
2125 | inside: {
|
2126 | 'content': {
|
2127 | pattern: /(^~~?)[\s\S]+(?=\1$)/,
|
2128 | lookbehind: true,
|
2129 | inside: {} // see below
|
2130 |
|
2131 | },
|
2132 | 'punctuation': /~~?/
|
2133 | }
|
2134 | },
|
2135 | 'code-snippet': {
|
2136 | // `code`
|
2137 | // ``code``
|
2138 | pattern: /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,
|
2139 | lookbehind: true,
|
2140 | greedy: true,
|
2141 | alias: ['code', 'keyword']
|
2142 | },
|
2143 | 'url': {
|
2144 | // [example](http://example.com "Optional title")
|
2145 | // [example][id]
|
2146 | // [example] [id]
|
2147 | pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),
|
2148 | lookbehind: true,
|
2149 | greedy: true,
|
2150 | inside: {
|
2151 | 'operator': /^!/,
|
2152 | 'content': {
|
2153 | pattern: /(^\[)[^\]]+(?=\])/,
|
2154 | lookbehind: true,
|
2155 | inside: {} // see below
|
2156 |
|
2157 | },
|
2158 | 'variable': {
|
2159 | pattern: /(^\][ \t]?\[)[^\]]+(?=\]$)/,
|
2160 | lookbehind: true
|
2161 | },
|
2162 | 'url': {
|
2163 | pattern: /(^\]\()[^\s)]+/,
|
2164 | lookbehind: true
|
2165 | },
|
2166 | 'string': {
|
2167 | pattern: /(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,
|
2168 | lookbehind: true
|
2169 | }
|
2170 | }
|
2171 | }
|
2172 | });
|
2173 | ['url', 'bold', 'italic', 'strike'].forEach(function (token) {
|
2174 | ['url', 'bold', 'italic', 'strike', 'code-snippet'].forEach(function (inside) {
|
2175 | if (token !== inside) {
|
2176 | Prism.languages.markdown[token].inside.content.inside[inside] = Prism.languages.markdown[inside];
|
2177 | }
|
2178 | });
|
2179 | });
|
2180 | Prism.hooks.add('after-tokenize', function (env) {
|
2181 | if (env.language !== 'markdown' && env.language !== 'md') {
|
2182 | return;
|
2183 | }
|
2184 |
|
2185 | function walkTokens(tokens) {
|
2186 | if (!tokens || typeof tokens === 'string') {
|
2187 | return;
|
2188 | }
|
2189 |
|
2190 | for (var i = 0, l = tokens.length; i < l; i++) {
|
2191 | var token = tokens[i];
|
2192 |
|
2193 | if (token.type !== 'code') {
|
2194 | walkTokens(token.content);
|
2195 | continue;
|
2196 | }
|
2197 | /*
|
2198 | * Add the correct `language-xxxx` class to this code block. Keep in mind that the `code-language` token
|
2199 | * is optional. But the grammar is defined so that there is only one case we have to handle:
|
2200 | *
|
2201 | * token.content = [
|
2202 | * <span class="punctuation">```</span>,
|
2203 | * <span class="code-language">xxxx</span>,
|
2204 | * '\n', // exactly one new lines (\r or \n or \r\n)
|
2205 | * <span class="code-block">...</span>,
|
2206 | * '\n', // exactly one new lines again
|
2207 | * <span class="punctuation">```</span>
|
2208 | * ];
|
2209 | */
|
2210 |
|
2211 |
|
2212 | var codeLang = token.content[1];
|
2213 | var codeBlock = token.content[3];
|
2214 |
|
2215 | if (codeLang && codeBlock && codeLang.type === 'code-language' && codeBlock.type === 'code-block' && typeof codeLang.content === 'string') {
|
2216 | // this might be a language that Prism does not support
|
2217 | // do some replacements to support C++, C#, and F#
|
2218 | var lang = codeLang.content.replace(/\b#/g, 'sharp').replace(/\b\+\+/g, 'pp'); // only use the first word
|
2219 |
|
2220 | lang = (/[a-z][\w-]*/i.exec(lang) || [''])[0].toLowerCase();
|
2221 | var alias = 'language-' + lang; // add alias
|
2222 |
|
2223 | if (!codeBlock.alias) {
|
2224 | codeBlock.alias = [alias];
|
2225 | } else if (typeof codeBlock.alias === 'string') {
|
2226 | codeBlock.alias = [codeBlock.alias, alias];
|
2227 | } else {
|
2228 | codeBlock.alias.push(alias);
|
2229 | }
|
2230 | }
|
2231 | }
|
2232 | }
|
2233 |
|
2234 | walkTokens(env.tokens);
|
2235 | });
|
2236 | Prism.hooks.add('wrap', function (env) {
|
2237 | if (env.type !== 'code-block') {
|
2238 | return;
|
2239 | }
|
2240 |
|
2241 | var codeLang = '';
|
2242 |
|
2243 | for (var i = 0, l = env.classes.length; i < l; i++) {
|
2244 | var cls = env.classes[i];
|
2245 | var match = /language-(.+)/.exec(cls);
|
2246 |
|
2247 | if (match) {
|
2248 | codeLang = match[1];
|
2249 | break;
|
2250 | }
|
2251 | }
|
2252 |
|
2253 | var grammar = Prism.languages[codeLang];
|
2254 |
|
2255 | if (!grammar) {
|
2256 | if (codeLang && codeLang !== 'none' && Prism.plugins.autoloader) {
|
2257 | var id = 'md-' + new Date().valueOf() + '-' + Math.floor(Math.random() * 1e16);
|
2258 | env.attributes['id'] = id;
|
2259 | Prism.plugins.autoloader.loadLanguages(codeLang, function () {
|
2260 | var ele = document.getElementById(id);
|
2261 |
|
2262 | if (ele) {
|
2263 | ele.innerHTML = Prism.highlight(ele.textContent, Prism.languages[codeLang], codeLang);
|
2264 | }
|
2265 | });
|
2266 | }
|
2267 | } else {
|
2268 | env.content = Prism.highlight(textContent(env.content), grammar, codeLang);
|
2269 | }
|
2270 | });
|
2271 | var tagPattern = RegExp(Prism.languages.markup.tag.pattern.source, 'gi');
|
2272 | /**
|
2273 | * A list of known entity names.
|
2274 | *
|
2275 | * This will always be incomplete to save space. The current list is the one used by lowdash's unescape function.
|
2276 | *
|
2277 | * @see {@link https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/unescape.js#L2}
|
2278 | */
|
2279 |
|
2280 | var KNOWN_ENTITY_NAMES = {
|
2281 | 'amp': '&',
|
2282 | 'lt': '<',
|
2283 | 'gt': '>',
|
2284 | 'quot': '"'
|
2285 | }; // IE 11 doesn't support `String.fromCodePoint`
|
2286 |
|
2287 | var fromCodePoint = String.fromCodePoint || String.fromCharCode;
|
2288 | /**
|
2289 | * Returns the text content of a given HTML source code string.
|
2290 | *
|
2291 | * @param {string} html
|
2292 | * @returns {string}
|
2293 | */
|
2294 |
|
2295 | function textContent(html) {
|
2296 | // remove all tags
|
2297 | var text = html.replace(tagPattern, ''); // decode known entities
|
2298 |
|
2299 | text = text.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function (m, code) {
|
2300 | code = code.toLowerCase();
|
2301 |
|
2302 | if (code[0] === '#') {
|
2303 | var value;
|
2304 |
|
2305 | if (code[1] === 'x') {
|
2306 | value = parseInt(code.slice(2), 16);
|
2307 | } else {
|
2308 | value = Number(code.slice(1));
|
2309 | }
|
2310 |
|
2311 | return fromCodePoint(value);
|
2312 | } else {
|
2313 | var known = KNOWN_ENTITY_NAMES[code];
|
2314 |
|
2315 | if (known) {
|
2316 | return known;
|
2317 | } // unable to decode
|
2318 |
|
2319 |
|
2320 | return m;
|
2321 | }
|
2322 | });
|
2323 | return text;
|
2324 | }
|
2325 |
|
2326 | Prism.languages.md = Prism.languages.markdown;
|
2327 | })(prism);
|
2328 | /* "prismjs/components/prism-graphql" */
|
2329 |
|
2330 |
|
2331 | prism.languages.graphql = {
|
2332 | 'comment': /#.*/,
|
2333 | 'description': {
|
2334 | pattern: /(?:"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*")(?=\s*[a-z_])/i,
|
2335 | greedy: true,
|
2336 | alias: 'string',
|
2337 | inside: {
|
2338 | 'language-markdown': {
|
2339 | pattern: /(^"(?:"")?)(?!\1)[\s\S]+(?=\1$)/,
|
2340 | lookbehind: true,
|
2341 | inside: prism.languages.markdown
|
2342 | }
|
2343 | }
|
2344 | },
|
2345 | 'string': {
|
2346 | pattern: /"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*"/,
|
2347 | greedy: true
|
2348 | },
|
2349 | 'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
2350 | 'boolean': /\b(?:false|true)\b/,
|
2351 | 'variable': /\$[a-z_]\w*/i,
|
2352 | 'directive': {
|
2353 | pattern: /@[a-z_]\w*/i,
|
2354 | alias: 'function'
|
2355 | },
|
2356 | 'attr-name': {
|
2357 | pattern: /\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,
|
2358 | greedy: true
|
2359 | },
|
2360 | 'atom-input': {
|
2361 | pattern: /\b[A-Z]\w*Input\b/,
|
2362 | alias: 'class-name'
|
2363 | },
|
2364 | 'scalar': /\b(?:Boolean|Float|ID|Int|String)\b/,
|
2365 | 'constant': /\b[A-Z][A-Z_\d]*\b/,
|
2366 | 'class-name': {
|
2367 | pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,
|
2368 | lookbehind: true
|
2369 | },
|
2370 | 'fragment': {
|
2371 | pattern: /(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,
|
2372 | lookbehind: true,
|
2373 | alias: 'function'
|
2374 | },
|
2375 | 'definition-mutation': {
|
2376 | pattern: /(\bmutation\s+)[a-zA-Z_]\w*/,
|
2377 | lookbehind: true,
|
2378 | alias: 'function'
|
2379 | },
|
2380 | 'definition-query': {
|
2381 | pattern: /(\bquery\s+)[a-zA-Z_]\w*/,
|
2382 | lookbehind: true,
|
2383 | alias: 'function'
|
2384 | },
|
2385 | 'keyword': /\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,
|
2386 | 'operator': /[!=|&]|\.{3}/,
|
2387 | 'property-query': /\w+(?=\s*\()/,
|
2388 | 'object': /\w+(?=\s*\{)/,
|
2389 | 'punctuation': /[!(){}\[\]:=,]/,
|
2390 | 'property': /\w+/
|
2391 | };
|
2392 | prism.hooks.add('after-tokenize', function afterTokenizeGraphql(env) {
|
2393 | if (env.language !== 'graphql') {
|
2394 | return;
|
2395 | }
|
2396 | /**
|
2397 | * get the graphql token stream that we want to customize
|
2398 | *
|
2399 | * @typedef {InstanceType<import("./prism-core")["Token"]>} Token
|
2400 | * @type {Token[]}
|
2401 | */
|
2402 |
|
2403 |
|
2404 | var validTokens = env.tokens.filter(function (token) {
|
2405 | return typeof token !== 'string' && token.type !== 'comment' && token.type !== 'scalar';
|
2406 | });
|
2407 | var currentIndex = 0;
|
2408 | /**
|
2409 | * Returns whether the token relative to the current index has the given type.
|
2410 | *
|
2411 | * @param {number} offset
|
2412 | * @returns {Token | undefined}
|
2413 | */
|
2414 |
|
2415 | function getToken(offset) {
|
2416 | return validTokens[currentIndex + offset];
|
2417 | }
|
2418 | /**
|
2419 | * Returns whether the token relative to the current index has the given type.
|
2420 | *
|
2421 | * @param {readonly string[]} types
|
2422 | * @param {number} [offset=0]
|
2423 | * @returns {boolean}
|
2424 | */
|
2425 |
|
2426 |
|
2427 | function isTokenType(types, offset) {
|
2428 | offset = offset || 0;
|
2429 |
|
2430 | for (var i = 0; i < types.length; i++) {
|
2431 | var token = getToken(i + offset);
|
2432 |
|
2433 | if (!token || token.type !== types[i]) {
|
2434 | return false;
|
2435 | }
|
2436 | }
|
2437 |
|
2438 | return true;
|
2439 | }
|
2440 | /**
|
2441 | * Returns the index of the closing bracket to an opening bracket.
|
2442 | *
|
2443 | * It is assumed that `token[currentIndex - 1]` is an opening bracket.
|
2444 | *
|
2445 | * If no closing bracket could be found, `-1` will be returned.
|
2446 | *
|
2447 | * @param {RegExp} open
|
2448 | * @param {RegExp} close
|
2449 | * @returns {number}
|
2450 | */
|
2451 |
|
2452 |
|
2453 | function findClosingBracket(open, close) {
|
2454 | var stackHeight = 1;
|
2455 |
|
2456 | for (var i = currentIndex; i < validTokens.length; i++) {
|
2457 | var token = validTokens[i];
|
2458 | var content = token.content;
|
2459 |
|
2460 | if (token.type === 'punctuation' && typeof content === 'string') {
|
2461 | if (open.test(content)) {
|
2462 | stackHeight++;
|
2463 | } else if (close.test(content)) {
|
2464 | stackHeight--;
|
2465 |
|
2466 | if (stackHeight === 0) {
|
2467 | return i;
|
2468 | }
|
2469 | }
|
2470 | }
|
2471 | }
|
2472 |
|
2473 | return -1;
|
2474 | }
|
2475 | /**
|
2476 | * Adds an alias to the given token.
|
2477 | *
|
2478 | * @param {Token} token
|
2479 | * @param {string} alias
|
2480 | * @returns {void}
|
2481 | */
|
2482 |
|
2483 |
|
2484 | function addAlias(token, alias) {
|
2485 | var aliases = token.alias;
|
2486 |
|
2487 | if (!aliases) {
|
2488 | token.alias = aliases = [];
|
2489 | } else if (!Array.isArray(aliases)) {
|
2490 | token.alias = aliases = [aliases];
|
2491 | }
|
2492 |
|
2493 | aliases.push(alias);
|
2494 | }
|
2495 |
|
2496 | for (; currentIndex < validTokens.length;) {
|
2497 | var startToken = validTokens[currentIndex++]; // add special aliases for mutation tokens
|
2498 |
|
2499 | if (startToken.type === 'keyword' && startToken.content === 'mutation') {
|
2500 | // any array of the names of all input variables (if any)
|
2501 | var inputVariables = [];
|
2502 |
|
2503 | if (isTokenType(['definition-mutation', 'punctuation']) && getToken(1).content === '(') {
|
2504 | // definition
|
2505 | currentIndex += 2; // skip 'definition-mutation' and 'punctuation'
|
2506 |
|
2507 | var definitionEnd = findClosingBracket(/^\($/, /^\)$/);
|
2508 |
|
2509 | if (definitionEnd === -1) {
|
2510 | continue;
|
2511 | } // find all input variables
|
2512 |
|
2513 |
|
2514 | for (; currentIndex < definitionEnd; currentIndex++) {
|
2515 | var t = getToken(0);
|
2516 |
|
2517 | if (t.type === 'variable') {
|
2518 | addAlias(t, 'variable-input');
|
2519 | inputVariables.push(t.content);
|
2520 | }
|
2521 | }
|
2522 |
|
2523 | currentIndex = definitionEnd + 1;
|
2524 | }
|
2525 |
|
2526 | if (isTokenType(['punctuation', 'property-query']) && getToken(0).content === '{') {
|
2527 | currentIndex++; // skip opening bracket
|
2528 |
|
2529 | addAlias(getToken(0), 'property-mutation');
|
2530 |
|
2531 | if (inputVariables.length > 0) {
|
2532 | var mutationEnd = findClosingBracket(/^\{$/, /^\}$/);
|
2533 |
|
2534 | if (mutationEnd === -1) {
|
2535 | continue;
|
2536 | } // give references to input variables a special alias
|
2537 |
|
2538 |
|
2539 | for (var i = currentIndex; i < mutationEnd; i++) {
|
2540 | var varToken = validTokens[i];
|
2541 |
|
2542 | if (varToken.type === 'variable' && inputVariables.indexOf(varToken.content) >= 0) {
|
2543 | addAlias(varToken, 'variable-input');
|
2544 | }
|
2545 | }
|
2546 | }
|
2547 | }
|
2548 | }
|
2549 | }
|
2550 | });
|
2551 | /* "prismjs/components/prism-sql" */
|
2552 |
|
2553 | prism.languages.sql = {
|
2554 | 'comment': {
|
2555 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
2556 | lookbehind: true
|
2557 | },
|
2558 | 'variable': [{
|
2559 | pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
|
2560 | greedy: true
|
2561 | }, /@[\w.$]+/],
|
2562 | 'string': {
|
2563 | pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
|
2564 | greedy: true,
|
2565 | lookbehind: true
|
2566 | },
|
2567 | 'identifier': {
|
2568 | pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
|
2569 | greedy: true,
|
2570 | lookbehind: true,
|
2571 | inside: {
|
2572 | 'punctuation': /^`|`$/
|
2573 | }
|
2574 | },
|
2575 | 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
2576 | // Should we highlight user defined functions too?
|
2577 | 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
|
2578 | 'boolean': /\b(?:FALSE|NULL|TRUE)\b/i,
|
2579 | 'number': /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
2580 | 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
2581 | 'punctuation': /[;[\]()`,.]/
|
2582 | };
|
2583 | /* "prismjs/components/prism-js-templates" */
|
2584 |
|
2585 | (function (Prism) {
|
2586 | var templateString = Prism.languages.javascript['template-string']; // see the pattern in prism-javascript.js
|
2587 |
|
2588 | var templateLiteralPattern = templateString.pattern.source;
|
2589 | var interpolationObject = templateString.inside['interpolation'];
|
2590 | var interpolationPunctuationObject = interpolationObject.inside['interpolation-punctuation'];
|
2591 | var interpolationPattern = interpolationObject.pattern.source;
|
2592 | /**
|
2593 | * Creates a new pattern to match a template string with a special tag.
|
2594 | *
|
2595 | * This will return `undefined` if there is no grammar with the given language id.
|
2596 | *
|
2597 | * @param {string} language The language id of the embedded language. E.g. `markdown`.
|
2598 | * @param {string} tag The regex pattern to match the tag.
|
2599 | * @returns {object | undefined}
|
2600 | * @example
|
2601 | * createTemplate('css', /\bcss/.source);
|
2602 | */
|
2603 |
|
2604 | function createTemplate(language, tag) {
|
2605 | if (!Prism.languages[language]) {
|
2606 | return undefined;
|
2607 | }
|
2608 |
|
2609 | return {
|
2610 | pattern: RegExp('((?:' + tag + ')\\s*)' + templateLiteralPattern),
|
2611 | lookbehind: true,
|
2612 | greedy: true,
|
2613 | inside: {
|
2614 | 'template-punctuation': {
|
2615 | pattern: /^`|`$/,
|
2616 | alias: 'string'
|
2617 | },
|
2618 | 'embedded-code': {
|
2619 | pattern: /[\s\S]+/,
|
2620 | alias: language
|
2621 | }
|
2622 | }
|
2623 | };
|
2624 | }
|
2625 |
|
2626 | Prism.languages.javascript['template-string'] = [// styled-jsx:
|
2627 | // css`a { color: #25F; }`
|
2628 | // styled-components:
|
2629 | // styled.h1`color: red;`
|
2630 | createTemplate('css', /\b(?:styled(?:\([^)]*\))?(?:\s*\.\s*\w+(?:\([^)]*\))*)*|css(?:\s*\.\s*(?:global|resolve))?|createGlobalStyle|keyframes)/.source), // html`<p></p>`
|
2631 | // div.innerHTML = `<p></p>`
|
2632 | createTemplate('html', /\bhtml|\.\s*(?:inner|outer)HTML\s*\+?=/.source), // svg`<path fill="#fff" d="M55.37 ..."/>`
|
2633 | createTemplate('svg', /\bsvg/.source), // md`# h1`, markdown`## h2`
|
2634 | createTemplate('markdown', /\b(?:markdown|md)/.source), // gql`...`, graphql`...`, graphql.experimental`...`
|
2635 | createTemplate('graphql', /\b(?:gql|graphql(?:\s*\.\s*experimental)?)/.source), // sql`...`
|
2636 | createTemplate('sql', /\bsql/.source), // vanilla template string
|
2637 | templateString].filter(Boolean);
|
2638 | /**
|
2639 | * Returns a specific placeholder literal for the given language.
|
2640 | *
|
2641 | * @param {number} counter
|
2642 | * @param {string} language
|
2643 | * @returns {string}
|
2644 | */
|
2645 |
|
2646 | function getPlaceholder(counter, language) {
|
2647 | return '___' + language.toUpperCase() + '_' + counter + '___';
|
2648 | }
|
2649 | /**
|
2650 | * Returns the tokens of `Prism.tokenize` but also runs the `before-tokenize` and `after-tokenize` hooks.
|
2651 | *
|
2652 | * @param {string} code
|
2653 | * @param {any} grammar
|
2654 | * @param {string} language
|
2655 | * @returns {(string|Token)[]}
|
2656 | */
|
2657 |
|
2658 |
|
2659 | function tokenizeWithHooks(code, grammar, language) {
|
2660 | var env = {
|
2661 | code: code,
|
2662 | grammar: grammar,
|
2663 | language: language
|
2664 | };
|
2665 | Prism.hooks.run('before-tokenize', env);
|
2666 | env.tokens = Prism.tokenize(env.code, env.grammar);
|
2667 | Prism.hooks.run('after-tokenize', env);
|
2668 | return env.tokens;
|
2669 | }
|
2670 | /**
|
2671 | * Returns the token of the given JavaScript interpolation expression.
|
2672 | *
|
2673 | * @param {string} expression The code of the expression. E.g. `"${42}"`
|
2674 | * @returns {Token}
|
2675 | */
|
2676 |
|
2677 |
|
2678 | function tokenizeInterpolationExpression(expression) {
|
2679 | var tempGrammar = {};
|
2680 | tempGrammar['interpolation-punctuation'] = interpolationPunctuationObject;
|
2681 | /** @type {Array} */
|
2682 |
|
2683 | var tokens = Prism.tokenize(expression, tempGrammar);
|
2684 |
|
2685 | if (tokens.length === 3) {
|
2686 | /**
|
2687 | * The token array will look like this
|
2688 | * [
|
2689 | * ["interpolation-punctuation", "${"]
|
2690 | * "..." // JavaScript expression of the interpolation
|
2691 | * ["interpolation-punctuation", "}"]
|
2692 | * ]
|
2693 | */
|
2694 | var args = [1, 1];
|
2695 | args.push.apply(args, tokenizeWithHooks(tokens[1], Prism.languages.javascript, 'javascript'));
|
2696 | tokens.splice.apply(tokens, args);
|
2697 | }
|
2698 |
|
2699 | return new Prism.Token('interpolation', tokens, interpolationObject.alias, expression);
|
2700 | }
|
2701 | /**
|
2702 | * Tokenizes the given code with support for JavaScript interpolation expressions mixed in.
|
2703 | *
|
2704 | * This function has 3 phases:
|
2705 | *
|
2706 | * 1. Replace all JavaScript interpolation expression with a placeholder.
|
2707 | * The placeholder will have the syntax of a identify of the target language.
|
2708 | * 2. Tokenize the code with placeholders.
|
2709 | * 3. Tokenize the interpolation expressions and re-insert them into the tokenize code.
|
2710 | * The insertion only works if a placeholder hasn't been "ripped apart" meaning that the placeholder has been
|
2711 | * tokenized as two tokens by the grammar of the embedded language.
|
2712 | *
|
2713 | * @param {string} code
|
2714 | * @param {object} grammar
|
2715 | * @param {string} language
|
2716 | * @returns {Token}
|
2717 | */
|
2718 |
|
2719 |
|
2720 | function tokenizeEmbedded(code, grammar, language) {
|
2721 | // 1. First filter out all interpolations
|
2722 | // because they might be escaped, we need a lookbehind, so we use Prism
|
2723 |
|
2724 | /** @type {(Token|string)[]} */
|
2725 | var _tokens = Prism.tokenize(code, {
|
2726 | 'interpolation': {
|
2727 | pattern: RegExp(interpolationPattern),
|
2728 | lookbehind: true
|
2729 | }
|
2730 | }); // replace all interpolations with a placeholder which is not in the code already
|
2731 |
|
2732 |
|
2733 | var placeholderCounter = 0;
|
2734 | /** @type {Object<string, string>} */
|
2735 |
|
2736 | var placeholderMap = {};
|
2737 |
|
2738 | var embeddedCode = _tokens.map(function (token) {
|
2739 | if (typeof token === 'string') {
|
2740 | return token;
|
2741 | } else {
|
2742 | var interpolationExpression = token.content;
|
2743 | var placeholder;
|
2744 |
|
2745 | while (code.indexOf(placeholder = getPlaceholder(placeholderCounter++, language)) !== -1) {
|
2746 | /* noop */
|
2747 | }
|
2748 |
|
2749 | placeholderMap[placeholder] = interpolationExpression;
|
2750 | return placeholder;
|
2751 | }
|
2752 | }).join(''); // 2. Tokenize the embedded code
|
2753 |
|
2754 |
|
2755 | var embeddedTokens = tokenizeWithHooks(embeddedCode, grammar, language); // 3. Re-insert the interpolation
|
2756 |
|
2757 | var placeholders = Object.keys(placeholderMap);
|
2758 | placeholderCounter = 0;
|
2759 | /**
|
2760 | *
|
2761 | * @param {(Token|string)[]} tokens
|
2762 | * @returns {void}
|
2763 | */
|
2764 |
|
2765 | function walkTokens(tokens) {
|
2766 | for (var i = 0; i < tokens.length; i++) {
|
2767 | if (placeholderCounter >= placeholders.length) {
|
2768 | return;
|
2769 | }
|
2770 |
|
2771 | var token = tokens[i];
|
2772 |
|
2773 | if (typeof token === 'string' || typeof token.content === 'string') {
|
2774 | var placeholder = placeholders[placeholderCounter];
|
2775 | var s = typeof token === 'string' ? token :
|
2776 | /** @type {string} */
|
2777 | token.content;
|
2778 | var index = s.indexOf(placeholder);
|
2779 |
|
2780 | if (index !== -1) {
|
2781 | ++placeholderCounter;
|
2782 | var before = s.substring(0, index);
|
2783 | var middle = tokenizeInterpolationExpression(placeholderMap[placeholder]);
|
2784 | var after = s.substring(index + placeholder.length);
|
2785 | var replacement = [];
|
2786 |
|
2787 | if (before) {
|
2788 | replacement.push(before);
|
2789 | }
|
2790 |
|
2791 | replacement.push(middle);
|
2792 |
|
2793 | if (after) {
|
2794 | var afterTokens = [after];
|
2795 | walkTokens(afterTokens);
|
2796 | replacement.push.apply(replacement, afterTokens);
|
2797 | }
|
2798 |
|
2799 | if (typeof token === 'string') {
|
2800 | tokens.splice.apply(tokens, [i, 1].concat(replacement));
|
2801 | i += replacement.length - 1;
|
2802 | } else {
|
2803 | token.content = replacement;
|
2804 | }
|
2805 | }
|
2806 | } else {
|
2807 | var content = token.content;
|
2808 |
|
2809 | if (Array.isArray(content)) {
|
2810 | walkTokens(content);
|
2811 | } else {
|
2812 | walkTokens([content]);
|
2813 | }
|
2814 | }
|
2815 | }
|
2816 | }
|
2817 |
|
2818 | walkTokens(embeddedTokens);
|
2819 | return new Prism.Token(language, embeddedTokens, 'language-' + language, code);
|
2820 | }
|
2821 | /**
|
2822 | * The languages for which JS templating will handle tagged template literals.
|
2823 | *
|
2824 | * JS templating isn't active for only JavaScript but also related languages like TypeScript, JSX, and TSX.
|
2825 | */
|
2826 |
|
2827 |
|
2828 | var supportedLanguages = {
|
2829 | 'javascript': true,
|
2830 | 'js': true,
|
2831 | 'typescript': true,
|
2832 | 'ts': true,
|
2833 | 'jsx': true,
|
2834 | 'tsx': true
|
2835 | };
|
2836 | Prism.hooks.add('after-tokenize', function (env) {
|
2837 | if (!(env.language in supportedLanguages)) {
|
2838 | return;
|
2839 | }
|
2840 | /**
|
2841 | * Finds and tokenizes all template strings with an embedded languages.
|
2842 | *
|
2843 | * @param {(Token | string)[]} tokens
|
2844 | * @returns {void}
|
2845 | */
|
2846 |
|
2847 |
|
2848 | function findTemplateStrings(tokens) {
|
2849 | for (var i = 0, l = tokens.length; i < l; i++) {
|
2850 | var token = tokens[i];
|
2851 |
|
2852 | if (typeof token === 'string') {
|
2853 | continue;
|
2854 | }
|
2855 |
|
2856 | var content = token.content;
|
2857 |
|
2858 | if (!Array.isArray(content)) {
|
2859 | if (typeof content !== 'string') {
|
2860 | findTemplateStrings([content]);
|
2861 | }
|
2862 |
|
2863 | continue;
|
2864 | }
|
2865 |
|
2866 | if (token.type === 'template-string') {
|
2867 | /**
|
2868 | * A JavaScript template-string token will look like this:
|
2869 | *
|
2870 | * ["template-string", [
|
2871 | * ["template-punctuation", "`"],
|
2872 | * (
|
2873 | * An array of "string" and "interpolation" tokens. This is the simple string case.
|
2874 | * or
|
2875 | * ["embedded-code", "..."] This is the token containing the embedded code.
|
2876 | * It also has an alias which is the language of the embedded code.
|
2877 | * ),
|
2878 | * ["template-punctuation", "`"]
|
2879 | * ]]
|
2880 | */
|
2881 | var embedded = content[1];
|
2882 |
|
2883 | if (content.length === 3 && typeof embedded !== 'string' && embedded.type === 'embedded-code') {
|
2884 | // get string content
|
2885 | var code = stringContent(embedded);
|
2886 | var alias = embedded.alias;
|
2887 | var language = Array.isArray(alias) ? alias[0] : alias;
|
2888 | var grammar = Prism.languages[language];
|
2889 |
|
2890 | if (!grammar) {
|
2891 | // the embedded language isn't registered.
|
2892 | continue;
|
2893 | }
|
2894 |
|
2895 | content[1] = tokenizeEmbedded(code, grammar, language);
|
2896 | }
|
2897 | } else {
|
2898 | findTemplateStrings(content);
|
2899 | }
|
2900 | }
|
2901 | }
|
2902 |
|
2903 | findTemplateStrings(env.tokens);
|
2904 | });
|
2905 | /**
|
2906 | * Returns the string content of a token or token stream.
|
2907 | *
|
2908 | * @param {string | Token | (string | Token)[]} value
|
2909 | * @returns {string}
|
2910 | */
|
2911 |
|
2912 | function stringContent(value) {
|
2913 | if (typeof value === 'string') {
|
2914 | return value;
|
2915 | } else if (Array.isArray(value)) {
|
2916 | return value.map(stringContent).join('');
|
2917 | } else {
|
2918 | return stringContent(value.content);
|
2919 | }
|
2920 | }
|
2921 | })(prism);
|
2922 | /* "prismjs/components/prism-typescript" */
|
2923 |
|
2924 |
|
2925 | (function (Prism) {
|
2926 | Prism.languages.typescript = Prism.languages.extend('javascript', {
|
2927 | 'class-name': {
|
2928 | pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
|
2929 | lookbehind: true,
|
2930 | greedy: true,
|
2931 | inside: null // see below
|
2932 |
|
2933 | },
|
2934 | 'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/
|
2935 | }); // The keywords TypeScript adds to JavaScript
|
2936 |
|
2937 | Prism.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/, // keywords that have to be followed by an identifier
|
2938 | /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/, // This is for `import type *, {}`
|
2939 | /\btype\b(?=\s*(?:[\{*]|$))/); // doesn't work with TS because TS is too complex
|
2940 |
|
2941 | delete Prism.languages.typescript['parameter'];
|
2942 | delete Prism.languages.typescript['literal-property']; // a version of typescript specifically for highlighting types
|
2943 |
|
2944 | var typeInside = Prism.languages.extend('typescript', {});
|
2945 | delete typeInside['class-name'];
|
2946 | Prism.languages.typescript['class-name'].inside = typeInside;
|
2947 | Prism.languages.insertBefore('typescript', 'function', {
|
2948 | 'decorator': {
|
2949 | pattern: /@[$\w\xA0-\uFFFF]+/,
|
2950 | inside: {
|
2951 | 'at': {
|
2952 | pattern: /^@/,
|
2953 | alias: 'operator'
|
2954 | },
|
2955 | 'function': /^[\s\S]+/
|
2956 | }
|
2957 | },
|
2958 | 'generic-function': {
|
2959 | // e.g. foo<T extends "bar" | "baz">( ...
|
2960 | pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
|
2961 | greedy: true,
|
2962 | inside: {
|
2963 | 'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
|
2964 | 'generic': {
|
2965 | pattern: /<[\s\S]+/,
|
2966 | // everything after the first <
|
2967 | alias: 'class-name',
|
2968 | inside: typeInside
|
2969 | }
|
2970 | }
|
2971 | }
|
2972 | });
|
2973 | Prism.languages.ts = Prism.languages.typescript;
|
2974 | })(prism);
|
2975 | /* "prismjs/components/prism-js-extras" */
|
2976 |
|
2977 |
|
2978 | (function (Prism) {
|
2979 | Prism.languages.insertBefore('javascript', 'function-variable', {
|
2980 | 'method-variable': {
|
2981 | pattern: RegExp('(\\.\\s*)' + Prism.languages.javascript['function-variable'].pattern.source),
|
2982 | lookbehind: true,
|
2983 | alias: ['function-variable', 'method', 'function', 'property-access']
|
2984 | }
|
2985 | });
|
2986 | Prism.languages.insertBefore('javascript', 'function', {
|
2987 | 'method': {
|
2988 | pattern: RegExp('(\\.\\s*)' + Prism.languages.javascript['function'].source),
|
2989 | lookbehind: true,
|
2990 | alias: ['function', 'property-access']
|
2991 | }
|
2992 | });
|
2993 | Prism.languages.insertBefore('javascript', 'constant', {
|
2994 | 'known-class-name': [{
|
2995 | // standard built-ins
|
2996 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
|
2997 | pattern: /\b(?:(?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)?Array|ArrayBuffer|BigInt|Boolean|DataView|Date|Error|Function|Intl|JSON|(?:Weak)?(?:Map|Set)|Math|Number|Object|Promise|Proxy|Reflect|RegExp|String|Symbol|WebAssembly)\b/,
|
2998 | alias: 'class-name'
|
2999 | }, {
|
3000 | // errors
|
3001 | pattern: /\b(?:[A-Z]\w*)Error\b/,
|
3002 | alias: 'class-name'
|
3003 | }]
|
3004 | });
|
3005 | /**
|
3006 | * Replaces the `<ID>` placeholder in the given pattern with a pattern for general JS identifiers.
|
3007 | *
|
3008 | * @param {string} source
|
3009 | * @param {string} [flags]
|
3010 | * @returns {RegExp}
|
3011 | */
|
3012 |
|
3013 | function withId(source, flags) {
|
3014 | return RegExp(source.replace(/<ID>/g, function () {
|
3015 | return /(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/.source;
|
3016 | }), flags);
|
3017 | }
|
3018 |
|
3019 | Prism.languages.insertBefore('javascript', 'keyword', {
|
3020 | 'imports': {
|
3021 | // https://tc39.es/ecma262/#sec-imports
|
3022 | pattern: withId(/(\bimport\b\s*)(?:<ID>(?:\s*,\s*(?:\*\s*as\s+<ID>|\{[^{}]*\}))?|\*\s*as\s+<ID>|\{[^{}]*\})(?=\s*\bfrom\b)/.source),
|
3023 | lookbehind: true,
|
3024 | inside: Prism.languages.javascript
|
3025 | },
|
3026 | 'exports': {
|
3027 | // https://tc39.es/ecma262/#sec-exports
|
3028 | pattern: withId(/(\bexport\b\s*)(?:\*(?:\s*as\s+<ID>)?(?=\s*\bfrom\b)|\{[^{}]*\})/.source),
|
3029 | lookbehind: true,
|
3030 | inside: Prism.languages.javascript
|
3031 | }
|
3032 | });
|
3033 | Prism.languages.javascript['keyword'].unshift({
|
3034 | pattern: /\b(?:as|default|export|from|import)\b/,
|
3035 | alias: 'module'
|
3036 | }, {
|
3037 | pattern: /\b(?:await|break|catch|continue|do|else|finally|for|if|return|switch|throw|try|while|yield)\b/,
|
3038 | alias: 'control-flow'
|
3039 | }, {
|
3040 | pattern: /\bnull\b/,
|
3041 | alias: ['null', 'nil']
|
3042 | }, {
|
3043 | pattern: /\bundefined\b/,
|
3044 | alias: 'nil'
|
3045 | });
|
3046 | Prism.languages.insertBefore('javascript', 'operator', {
|
3047 | 'spread': {
|
3048 | pattern: /\.{3}/,
|
3049 | alias: 'operator'
|
3050 | },
|
3051 | 'arrow': {
|
3052 | pattern: /=>/,
|
3053 | alias: 'operator'
|
3054 | }
|
3055 | });
|
3056 | Prism.languages.insertBefore('javascript', 'punctuation', {
|
3057 | 'property-access': {
|
3058 | pattern: withId(/(\.\s*)#?<ID>/.source),
|
3059 | lookbehind: true
|
3060 | },
|
3061 | 'maybe-class-name': {
|
3062 | pattern: /(^|[^$\w\xA0-\uFFFF])[A-Z][$\w\xA0-\uFFFF]+/,
|
3063 | lookbehind: true
|
3064 | },
|
3065 | 'dom': {
|
3066 | // this contains only a few commonly used DOM variables
|
3067 | pattern: /\b(?:document|(?:local|session)Storage|location|navigator|performance|window)\b/,
|
3068 | alias: 'variable'
|
3069 | },
|
3070 | 'console': {
|
3071 | pattern: /\bconsole(?=\s*\.)/,
|
3072 | alias: 'class-name'
|
3073 | }
|
3074 | }); // add 'maybe-class-name' to tokens which might be a class name
|
3075 |
|
3076 | var maybeClassNameTokens = ['function', 'function-variable', 'method', 'method-variable', 'property-access'];
|
3077 |
|
3078 | for (var i = 0; i < maybeClassNameTokens.length; i++) {
|
3079 | var token = maybeClassNameTokens[i];
|
3080 | var value = Prism.languages.javascript[token]; // convert regex to object
|
3081 |
|
3082 | if (Prism.util.type(value) === 'RegExp') {
|
3083 | value = Prism.languages.javascript[token] = {
|
3084 | pattern: value
|
3085 | };
|
3086 | } // keep in mind that we don't support arrays
|
3087 |
|
3088 |
|
3089 | var inside = value.inside || {};
|
3090 | value.inside = inside;
|
3091 | inside['maybe-class-name'] = /^[A-Z][\s\S]*/;
|
3092 | }
|
3093 | })(prism);
|
3094 | /* "prismjs/components/prism-jsx" */
|
3095 |
|
3096 |
|
3097 | (function (Prism) {
|
3098 | var javascript = Prism.util.clone(Prism.languages.javascript);
|
3099 | var space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
|
3100 | var braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
|
3101 | var spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
|
3102 | /**
|
3103 | * @param {string} source
|
3104 | * @param {string} [flags]
|
3105 | */
|
3106 |
|
3107 | function re(source, flags) {
|
3108 | source = source.replace(/<S>/g, function () {
|
3109 | return space;
|
3110 | }).replace(/<BRACES>/g, function () {
|
3111 | return braces;
|
3112 | }).replace(/<SPREAD>/g, function () {
|
3113 | return spread;
|
3114 | });
|
3115 | return RegExp(source, flags);
|
3116 | }
|
3117 |
|
3118 | spread = re(spread).source;
|
3119 | Prism.languages.jsx = Prism.languages.extend('markup', javascript);
|
3120 | Prism.languages.jsx.tag.pattern = re(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source);
|
3121 | Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/;
|
3122 | Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
|
3123 | Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
|
3124 | Prism.languages.jsx.tag.inside['comment'] = javascript['comment'];
|
3125 | Prism.languages.insertBefore('inside', 'attr-name', {
|
3126 | 'spread': {
|
3127 | pattern: re(/<SPREAD>/.source),
|
3128 | inside: Prism.languages.jsx
|
3129 | }
|
3130 | }, Prism.languages.jsx.tag);
|
3131 | Prism.languages.insertBefore('inside', 'special-attr', {
|
3132 | 'script': {
|
3133 | // Allow for two levels of nesting
|
3134 | pattern: re(/=<BRACES>/.source),
|
3135 | alias: 'language-javascript',
|
3136 | inside: {
|
3137 | 'script-punctuation': {
|
3138 | pattern: /^=(?=\{)/,
|
3139 | alias: 'punctuation'
|
3140 | },
|
3141 | rest: Prism.languages.jsx
|
3142 | }
|
3143 | }
|
3144 | }, Prism.languages.jsx.tag); // The following will handle plain text inside tags
|
3145 |
|
3146 | var stringifyToken = function (token) {
|
3147 | if (!token) {
|
3148 | return '';
|
3149 | }
|
3150 |
|
3151 | if (typeof token === 'string') {
|
3152 | return token;
|
3153 | }
|
3154 |
|
3155 | if (typeof token.content === 'string') {
|
3156 | return token.content;
|
3157 | }
|
3158 |
|
3159 | return token.content.map(stringifyToken).join('');
|
3160 | };
|
3161 |
|
3162 | var walkTokens = function (tokens) {
|
3163 | var openedTags = [];
|
3164 |
|
3165 | for (var i = 0; i < tokens.length; i++) {
|
3166 | var token = tokens[i];
|
3167 | var notTagNorBrace = false;
|
3168 |
|
3169 | if (typeof token !== 'string') {
|
3170 | if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
|
3171 | // We found a tag, now find its kind
|
3172 | if (token.content[0].content[0].content === '</') {
|
3173 | // Closing tag
|
3174 | if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
|
3175 | // Pop matching opening tag
|
3176 | openedTags.pop();
|
3177 | }
|
3178 | } else {
|
3179 | if (token.content[token.content.length - 1].content === '/>') ; else {
|
3180 | // Opening tag
|
3181 | openedTags.push({
|
3182 | tagName: stringifyToken(token.content[0].content[1]),
|
3183 | openedBraces: 0
|
3184 | });
|
3185 | }
|
3186 | }
|
3187 | } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
|
3188 | // Here we might have entered a JSX context inside a tag
|
3189 | openedTags[openedTags.length - 1].openedBraces++;
|
3190 | } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
|
3191 | // Here we might have left a JSX context inside a tag
|
3192 | openedTags[openedTags.length - 1].openedBraces--;
|
3193 | } else {
|
3194 | notTagNorBrace = true;
|
3195 | }
|
3196 | }
|
3197 |
|
3198 | if (notTagNorBrace || typeof token === 'string') {
|
3199 | if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
|
3200 | // Here we are inside a tag, and not inside a JSX context.
|
3201 | // That's plain text: drop any tokens matched.
|
3202 | var plainText = stringifyToken(token); // And merge text with adjacent text
|
3203 |
|
3204 | if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
|
3205 | plainText += stringifyToken(tokens[i + 1]);
|
3206 | tokens.splice(i + 1, 1);
|
3207 | }
|
3208 |
|
3209 | if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
|
3210 | plainText = stringifyToken(tokens[i - 1]) + plainText;
|
3211 | tokens.splice(i - 1, 1);
|
3212 | i--;
|
3213 | }
|
3214 |
|
3215 | tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
|
3216 | }
|
3217 | }
|
3218 |
|
3219 | if (token.content && typeof token.content !== 'string') {
|
3220 | walkTokens(token.content);
|
3221 | }
|
3222 | }
|
3223 | };
|
3224 |
|
3225 | Prism.hooks.add('after-tokenize', function (env) {
|
3226 | if (env.language !== 'jsx' && env.language !== 'tsx') {
|
3227 | return;
|
3228 | }
|
3229 |
|
3230 | walkTokens(env.tokens);
|
3231 | });
|
3232 | })(prism);
|
3233 | /* "prismjs/components/prism-diff" */
|
3234 |
|
3235 |
|
3236 | (function (Prism) {
|
3237 | Prism.languages.diff = {
|
3238 | 'coord': [// Match all kinds of coord lines (prefixed by "+++", "---" or "***").
|
3239 | /^(?:\*{3}|-{3}|\+{3}).*$/m, // Match "@@ ... @@" coord lines in unified diff.
|
3240 | /^@@.*@@$/m, // Match coord lines in normal diff (starts with a number).
|
3241 | /^\d.*$/m] // deleted, inserted, unchanged, diff
|
3242 |
|
3243 | };
|
3244 | /**
|
3245 | * A map from the name of a block to its line prefix.
|
3246 | *
|
3247 | * @type {Object<string, string>}
|
3248 | */
|
3249 |
|
3250 | var PREFIXES = {
|
3251 | 'deleted-sign': '-',
|
3252 | 'deleted-arrow': '<',
|
3253 | 'inserted-sign': '+',
|
3254 | 'inserted-arrow': '>',
|
3255 | 'unchanged': ' ',
|
3256 | 'diff': '!'
|
3257 | }; // add a token for each prefix
|
3258 |
|
3259 | Object.keys(PREFIXES).forEach(function (name) {
|
3260 | var prefix = PREFIXES[name];
|
3261 | var alias = [];
|
3262 |
|
3263 | if (!/^\w+$/.test(name)) {
|
3264 | // "deleted-sign" -> "deleted"
|
3265 | alias.push(/\w+/.exec(name)[0]);
|
3266 | }
|
3267 |
|
3268 | if (name === 'diff') {
|
3269 | alias.push('bold');
|
3270 | }
|
3271 |
|
3272 | Prism.languages.diff[name] = {
|
3273 | pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'),
|
3274 | alias: alias,
|
3275 | inside: {
|
3276 | 'line': {
|
3277 | pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/,
|
3278 | lookbehind: true
|
3279 | },
|
3280 | 'prefix': {
|
3281 | pattern: /[\s\S]/,
|
3282 | alias: /\w+/.exec(name)[0]
|
3283 | }
|
3284 | }
|
3285 | };
|
3286 | }); // make prefixes available to Diff plugin
|
3287 |
|
3288 | Object.defineProperty(Prism.languages.diff, 'PREFIXES', {
|
3289 | value: PREFIXES
|
3290 | });
|
3291 | })(prism);
|
3292 | /* "prismjs/components/prism-git" */
|
3293 |
|
3294 |
|
3295 | prism.languages.git = {
|
3296 | /*
|
3297 | * A simple one line comment like in a git status command
|
3298 | * For instance:
|
3299 | * $ git status
|
3300 | * # On branch infinite-scroll
|
3301 | * # Your branch and 'origin/sharedBranches/frontendTeam/infinite-scroll' have diverged,
|
3302 | * # and have 1 and 2 different commits each, respectively.
|
3303 | * nothing to commit (working directory clean)
|
3304 | */
|
3305 | 'comment': /^#.*/m,
|
3306 |
|
3307 | /*
|
3308 | * Regexp to match the changed lines in a git diff output. Check the example below.
|
3309 | */
|
3310 | 'deleted': /^[-–].*/m,
|
3311 | 'inserted': /^\+.*/m,
|
3312 |
|
3313 | /*
|
3314 | * a string (double and simple quote)
|
3315 | */
|
3316 | 'string': /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
|
3317 |
|
3318 | /*
|
3319 | * a git command. It starts with a random prompt finishing by a $, then "git" then some other parameters
|
3320 | * For instance:
|
3321 | * $ git add file.txt
|
3322 | */
|
3323 | 'command': {
|
3324 | pattern: /^.*\$ git .*$/m,
|
3325 | inside: {
|
3326 | /*
|
3327 | * A git command can contain a parameter starting by a single or a double dash followed by a string
|
3328 | * For instance:
|
3329 | * $ git diff --cached
|
3330 | * $ git log -p
|
3331 | */
|
3332 | 'parameter': /\s--?\w+/
|
3333 | }
|
3334 | },
|
3335 |
|
3336 | /*
|
3337 | * Coordinates displayed in a git diff command
|
3338 | * For instance:
|
3339 | * $ git diff
|
3340 | * diff --git file.txt file.txt
|
3341 | * index 6214953..1d54a52 100644
|
3342 | * --- file.txt
|
3343 | * +++ file.txt
|
3344 | * @@ -1 +1,2 @@
|
3345 | * -Here's my tetx file
|
3346 | * +Here's my text file
|
3347 | * +And this is the second line
|
3348 | */
|
3349 | 'coord': /^@@.*@@$/m,
|
3350 |
|
3351 | /*
|
3352 | * Match a "commit [SHA1]" line in a git log output.
|
3353 | * For instance:
|
3354 | * $ git log
|
3355 | * commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
|
3356 | * Author: lgiraudel
|
3357 | * Date: Mon Feb 17 11:18:34 2014 +0100
|
3358 | *
|
3359 | * Add of a new line
|
3360 | */
|
3361 | 'commit-sha1': /^commit \w{40}$/m
|
3362 | };
|
3363 | /* "prismjs/components/prism-go" */
|
3364 |
|
3365 | prism.languages.go = prism.languages.extend('clike', {
|
3366 | 'string': {
|
3367 | pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
|
3368 | lookbehind: true,
|
3369 | greedy: true
|
3370 | },
|
3371 | 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
3372 | 'boolean': /\b(?:_|false|iota|nil|true)\b/,
|
3373 | 'number': [// binary and octal integers
|
3374 | /\b0(?:b[01_]+|o[0-7_]+)i?\b/i, // hexadecimal integers and floats
|
3375 | /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i, // decimal integers and floats
|
3376 | /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],
|
3377 | 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
3378 | 'builtin': /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
|
3379 | });
|
3380 | prism.languages.insertBefore('go', 'string', {
|
3381 | 'char': {
|
3382 | pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
|
3383 | greedy: true
|
3384 | }
|
3385 | });
|
3386 | delete prism.languages.go['class-name'];
|
3387 | /* "prismjs/components/prism-handlebars" */
|
3388 |
|
3389 | (function (Prism) {
|
3390 | Prism.languages.handlebars = {
|
3391 | 'comment': /\{\{![\s\S]*?\}\}/,
|
3392 | 'delimiter': {
|
3393 | pattern: /^\{\{\{?|\}\}\}?$/,
|
3394 | alias: 'punctuation'
|
3395 | },
|
3396 | 'string': /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
|
3397 | 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][+-]?\d+)?/,
|
3398 | 'boolean': /\b(?:false|true)\b/,
|
3399 | 'block': {
|
3400 | pattern: /^(\s*(?:~\s*)?)[#\/]\S+?(?=\s*(?:~\s*)?$|\s)/,
|
3401 | lookbehind: true,
|
3402 | alias: 'keyword'
|
3403 | },
|
3404 | 'brackets': {
|
3405 | pattern: /\[[^\]]+\]/,
|
3406 | inside: {
|
3407 | punctuation: /\[|\]/,
|
3408 | variable: /[\s\S]+/
|
3409 | }
|
3410 | },
|
3411 | 'punctuation': /[!"#%&':()*+,.\/;<=>@\[\\\]^`{|}~]/,
|
3412 | 'variable': /[^!"#%&'()*+,\/;<=>@\[\\\]^`{|}~\s]+/
|
3413 | };
|
3414 | Prism.hooks.add('before-tokenize', function (env) {
|
3415 | var handlebarsPattern = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/g;
|
3416 | Prism.languages['markup-templating'].buildPlaceholders(env, 'handlebars', handlebarsPattern);
|
3417 | });
|
3418 | Prism.hooks.add('after-tokenize', function (env) {
|
3419 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'handlebars');
|
3420 | });
|
3421 | Prism.languages.hbs = Prism.languages.handlebars;
|
3422 | })(prism);
|
3423 | /* "prismjs/components/prism-json" */
|
3424 | // https://www.json.org/json-en.html
|
3425 |
|
3426 |
|
3427 | prism.languages.json = {
|
3428 | 'property': {
|
3429 | pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
3430 | lookbehind: true,
|
3431 | greedy: true
|
3432 | },
|
3433 | 'string': {
|
3434 | pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
3435 | lookbehind: true,
|
3436 | greedy: true
|
3437 | },
|
3438 | 'comment': {
|
3439 | pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
3440 | greedy: true
|
3441 | },
|
3442 | 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
3443 | 'punctuation': /[{}[\],]/,
|
3444 | 'operator': /:/,
|
3445 | 'boolean': /\b(?:false|true)\b/,
|
3446 | 'null': {
|
3447 | pattern: /\bnull\b/,
|
3448 | alias: 'keyword'
|
3449 | }
|
3450 | };
|
3451 | prism.languages.webmanifest = prism.languages.json;
|
3452 | /* "prismjs/components/prism-less" */
|
3453 |
|
3454 | /* FIXME :
|
3455 | :extend() is not handled specifically : its highlighting is buggy.
|
3456 | Mixin usage must be inside a ruleset to be highlighted.
|
3457 | At-rules (e.g. import) containing interpolations are buggy.
|
3458 | Detached rulesets are highlighted as at-rules.
|
3459 | A comment before a mixin usage prevents the latter to be properly highlighted.
|
3460 | */
|
3461 |
|
3462 | prism.languages.less = prism.languages.extend('css', {
|
3463 | 'comment': [/\/\*[\s\S]*?\*\//, {
|
3464 | pattern: /(^|[^\\])\/\/.*/,
|
3465 | lookbehind: true
|
3466 | }],
|
3467 | 'atrule': {
|
3468 | pattern: /@[\w-](?:\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};\s]|\s+(?!\s))*?(?=\s*\{)/,
|
3469 | inside: {
|
3470 | 'punctuation': /[:()]/
|
3471 | }
|
3472 | },
|
3473 | // selectors and mixins are considered the same
|
3474 | 'selector': {
|
3475 | pattern: /(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};@\s]|\s+(?!\s))*?(?=\s*\{)/,
|
3476 | inside: {
|
3477 | // mixin parameters
|
3478 | 'variable': /@+[\w-]+/
|
3479 | }
|
3480 | },
|
3481 | 'property': /(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/,
|
3482 | 'operator': /[+\-*\/]/
|
3483 | });
|
3484 | prism.languages.insertBefore('less', 'property', {
|
3485 | 'variable': [// Variable declaration (the colon must be consumed!)
|
3486 | {
|
3487 | pattern: /@[\w-]+\s*:/,
|
3488 | inside: {
|
3489 | 'punctuation': /:/
|
3490 | }
|
3491 | }, // Variable usage
|
3492 | /@@?[\w-]+/],
|
3493 | 'mixin-usage': {
|
3494 | pattern: /([{;]\s*)[.#](?!\d)[\w-].*?(?=[(;])/,
|
3495 | lookbehind: true,
|
3496 | alias: 'function'
|
3497 | }
|
3498 | });
|
3499 | /* "prismjs/components/prism-makefile" */
|
3500 |
|
3501 | prism.languages.makefile = {
|
3502 | 'comment': {
|
3503 | pattern: /(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,
|
3504 | lookbehind: true
|
3505 | },
|
3506 | 'string': {
|
3507 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
3508 | greedy: true
|
3509 | },
|
3510 | 'builtin-target': {
|
3511 | pattern: /\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,
|
3512 | alias: 'builtin'
|
3513 | },
|
3514 | 'target': {
|
3515 | pattern: /^(?:[^:=\s]|[ \t]+(?![\s:]))+(?=\s*:(?!=))/m,
|
3516 | alias: 'symbol',
|
3517 | inside: {
|
3518 | 'variable': /\$+(?:(?!\$)[^(){}:#=\s]+|(?=[({]))/
|
3519 | }
|
3520 | },
|
3521 | 'variable': /\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,
|
3522 | // Directives
|
3523 | 'keyword': /-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,
|
3524 | 'function': {
|
3525 | pattern: /(\()(?:abspath|addsuffix|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:list|s)?)(?=[ \t])/,
|
3526 | lookbehind: true
|
3527 | },
|
3528 | 'operator': /(?:::|[?:+!])?=|[|@]/,
|
3529 | 'punctuation': /[:;(){}]/
|
3530 | };
|
3531 | /* "prismjs/components/prism-objectivec" */
|
3532 |
|
3533 | prism.languages.objectivec = prism.languages.extend('c', {
|
3534 | 'string': {
|
3535 | pattern: /@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
3536 | greedy: true
|
3537 | },
|
3538 | 'keyword': /\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,
|
3539 | 'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/
|
3540 | });
|
3541 | delete prism.languages.objectivec['class-name'];
|
3542 | prism.languages.objc = prism.languages.objectivec;
|
3543 | /* "prismjs/components/prism-ocaml" */
|
3544 | // https://ocaml.org/manual/lex.html
|
3545 |
|
3546 | prism.languages.ocaml = {
|
3547 | 'comment': {
|
3548 | pattern: /\(\*[\s\S]*?\*\)/,
|
3549 | greedy: true
|
3550 | },
|
3551 | 'char': {
|
3552 | pattern: /'(?:[^\\\r\n']|\\(?:.|[ox]?[0-9a-f]{1,3}))'/i,
|
3553 | greedy: true
|
3554 | },
|
3555 | 'string': [{
|
3556 | pattern: /"(?:\\(?:[\s\S]|\r\n)|[^\\\r\n"])*"/,
|
3557 | greedy: true
|
3558 | }, {
|
3559 | pattern: /\{([a-z_]*)\|[\s\S]*?\|\1\}/,
|
3560 | greedy: true
|
3561 | }],
|
3562 | 'number': [// binary and octal
|
3563 | /\b(?:0b[01][01_]*|0o[0-7][0-7_]*)\b/i, // hexadecimal
|
3564 | /\b0x[a-f0-9][a-f0-9_]*(?:\.[a-f0-9_]*)?(?:p[+-]?\d[\d_]*)?(?!\w)/i, // decimal
|
3565 | /\b\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?\d[\d_]*)?(?!\w)/i],
|
3566 | 'directive': {
|
3567 | pattern: /\B#\w+/,
|
3568 | alias: 'property'
|
3569 | },
|
3570 | 'label': {
|
3571 | pattern: /\B~\w+/,
|
3572 | alias: 'property'
|
3573 | },
|
3574 | 'type-variable': {
|
3575 | pattern: /\B'\w+/,
|
3576 | alias: 'function'
|
3577 | },
|
3578 | 'variant': {
|
3579 | pattern: /`\w+/,
|
3580 | alias: 'symbol'
|
3581 | },
|
3582 | // For the list of keywords and operators,
|
3583 | // see: http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#sec84
|
3584 | 'keyword': /\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,
|
3585 | 'boolean': /\b(?:false|true)\b/,
|
3586 | 'operator-like-punctuation': {
|
3587 | pattern: /\[[<>|]|[>|]\]|\{<|>\}/,
|
3588 | alias: 'punctuation'
|
3589 | },
|
3590 | // Custom operators are allowed
|
3591 | 'operator': /\.[.~]|:[=>]|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,
|
3592 | 'punctuation': /;;|::|[(){}\[\].,:;#]|\b_\b/
|
3593 | };
|
3594 | /* "prismjs/components/prism-python" */
|
3595 |
|
3596 | prism.languages.python = {
|
3597 | 'comment': {
|
3598 | pattern: /(^|[^\\])#.*/,
|
3599 | lookbehind: true,
|
3600 | greedy: true
|
3601 | },
|
3602 | 'string-interpolation': {
|
3603 | pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
3604 | greedy: true,
|
3605 | inside: {
|
3606 | 'interpolation': {
|
3607 | // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
3608 | pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
3609 | lookbehind: true,
|
3610 | inside: {
|
3611 | 'format-spec': {
|
3612 | pattern: /(:)[^:(){}]+(?=\}$)/,
|
3613 | lookbehind: true
|
3614 | },
|
3615 | 'conversion-option': {
|
3616 | pattern: /![sra](?=[:}]$)/,
|
3617 | alias: 'punctuation'
|
3618 | },
|
3619 | rest: null
|
3620 | }
|
3621 | },
|
3622 | 'string': /[\s\S]+/
|
3623 | }
|
3624 | },
|
3625 | 'triple-quoted-string': {
|
3626 | pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
3627 | greedy: true,
|
3628 | alias: 'string'
|
3629 | },
|
3630 | 'string': {
|
3631 | pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
3632 | greedy: true
|
3633 | },
|
3634 | 'function': {
|
3635 | pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
3636 | lookbehind: true
|
3637 | },
|
3638 | 'class-name': {
|
3639 | pattern: /(\bclass\s+)\w+/i,
|
3640 | lookbehind: true
|
3641 | },
|
3642 | 'decorator': {
|
3643 | pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
3644 | lookbehind: true,
|
3645 | alias: ['annotation', 'punctuation'],
|
3646 | inside: {
|
3647 | 'punctuation': /\./
|
3648 | }
|
3649 | },
|
3650 | 'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
3651 | 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
3652 | 'boolean': /\b(?:False|None|True)\b/,
|
3653 | 'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
3654 | 'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
3655 | 'punctuation': /[{}[\];(),.:]/
|
3656 | };
|
3657 | prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = prism.languages.python;
|
3658 | prism.languages.py = prism.languages.python;
|
3659 | /* "prismjs/components/prism-reason" */
|
3660 |
|
3661 | prism.languages.reason = prism.languages.extend('clike', {
|
3662 | 'string': {
|
3663 | pattern: /"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,
|
3664 | greedy: true
|
3665 | },
|
3666 | // 'class-name' must be matched *after* 'constructor' defined below
|
3667 | 'class-name': /\b[A-Z]\w*/,
|
3668 | 'keyword': /\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/,
|
3669 | 'operator': /\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:asr|land|lor|lsl|lsr|lxor|mod)\b/
|
3670 | });
|
3671 | prism.languages.insertBefore('reason', 'class-name', {
|
3672 | 'char': {
|
3673 | pattern: /'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'\\\r\n])'/,
|
3674 | greedy: true
|
3675 | },
|
3676 | // Negative look-ahead prevents from matching things like String.capitalize
|
3677 | 'constructor': /\b[A-Z]\w*\b(?!\s*\.)/,
|
3678 | 'label': {
|
3679 | pattern: /\b[a-z]\w*(?=::)/,
|
3680 | alias: 'symbol'
|
3681 | }
|
3682 | }); // We can't match functions property, so let's not even try.
|
3683 |
|
3684 | delete prism.languages.reason.function;
|
3685 | /* "prismjs/components/prism-sass" */
|
3686 |
|
3687 | (function (Prism) {
|
3688 | Prism.languages.sass = Prism.languages.extend('css', {
|
3689 | // Sass comments don't need to be closed, only indented
|
3690 | 'comment': {
|
3691 | pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t].+)*/m,
|
3692 | lookbehind: true,
|
3693 | greedy: true
|
3694 | }
|
3695 | });
|
3696 | Prism.languages.insertBefore('sass', 'atrule', {
|
3697 | // We want to consume the whole line
|
3698 | 'atrule-line': {
|
3699 | // Includes support for = and + shortcuts
|
3700 | pattern: /^(?:[ \t]*)[@+=].+/m,
|
3701 | greedy: true,
|
3702 | inside: {
|
3703 | 'atrule': /(?:@[\w-]+|[+=])/
|
3704 | }
|
3705 | }
|
3706 | });
|
3707 | delete Prism.languages.sass.atrule;
|
3708 | var variable = /\$[-\w]+|#\{\$[-\w]+\}/;
|
3709 | var operator = [/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|not|or)\b/, {
|
3710 | pattern: /(\s)-(?=\s)/,
|
3711 | lookbehind: true
|
3712 | }];
|
3713 | Prism.languages.insertBefore('sass', 'property', {
|
3714 | // We want to consume the whole line
|
3715 | 'variable-line': {
|
3716 | pattern: /^[ \t]*\$.+/m,
|
3717 | greedy: true,
|
3718 | inside: {
|
3719 | 'punctuation': /:/,
|
3720 | 'variable': variable,
|
3721 | 'operator': operator
|
3722 | }
|
3723 | },
|
3724 | // We want to consume the whole line
|
3725 | 'property-line': {
|
3726 | pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s].*)/m,
|
3727 | greedy: true,
|
3728 | inside: {
|
3729 | 'property': [/[^:\s]+(?=\s*:)/, {
|
3730 | pattern: /(:)[^:\s]+/,
|
3731 | lookbehind: true
|
3732 | }],
|
3733 | 'punctuation': /:/,
|
3734 | 'variable': variable,
|
3735 | 'operator': operator,
|
3736 | 'important': Prism.languages.sass.important
|
3737 | }
|
3738 | }
|
3739 | });
|
3740 | delete Prism.languages.sass.property;
|
3741 | delete Prism.languages.sass.important; // Now that whole lines for other patterns are consumed,
|
3742 | // what's left should be selectors
|
3743 |
|
3744 | Prism.languages.insertBefore('sass', 'punctuation', {
|
3745 | 'selector': {
|
3746 | pattern: /^([ \t]*)\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*)*/m,
|
3747 | lookbehind: true,
|
3748 | greedy: true
|
3749 | }
|
3750 | });
|
3751 | })(prism);
|
3752 | /* "prismjs/components/prism-scss" */
|
3753 |
|
3754 |
|
3755 | prism.languages.scss = prism.languages.extend('css', {
|
3756 | 'comment': {
|
3757 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
3758 | lookbehind: true
|
3759 | },
|
3760 | 'atrule': {
|
3761 | pattern: /@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,
|
3762 | inside: {
|
3763 | 'rule': /@[\w-]+/ // See rest below
|
3764 |
|
3765 | }
|
3766 | },
|
3767 | // url, compassified
|
3768 | 'url': /(?:[-a-z]+-)?url(?=\()/i,
|
3769 | // CSS selector regex is not appropriate for Sass
|
3770 | // since there can be lot more things (var, @ directive, nesting..)
|
3771 | // a selector must start at the end of a property or after a brace (end of other rules or nesting)
|
3772 | // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
|
3773 | // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
|
3774 | // can "pass" as a selector- e.g: proper#{$erty})
|
3775 | // this one was hard to do, so please be careful if you edit this one :)
|
3776 | 'selector': {
|
3777 | // Initial look-ahead is used to prevent matching of blank selectors
|
3778 | pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,
|
3779 | inside: {
|
3780 | 'parent': {
|
3781 | pattern: /&/,
|
3782 | alias: 'important'
|
3783 | },
|
3784 | 'placeholder': /%[-\w]+/,
|
3785 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
3786 | }
|
3787 | },
|
3788 | 'property': {
|
3789 | pattern: /(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,
|
3790 | inside: {
|
3791 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
3792 | }
|
3793 | }
|
3794 | });
|
3795 | prism.languages.insertBefore('scss', 'atrule', {
|
3796 | 'keyword': [/@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i, {
|
3797 | pattern: /( )(?:from|through)(?= )/,
|
3798 | lookbehind: true
|
3799 | }]
|
3800 | });
|
3801 | prism.languages.insertBefore('scss', 'important', {
|
3802 | // var and interpolated vars
|
3803 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
3804 | });
|
3805 | prism.languages.insertBefore('scss', 'function', {
|
3806 | 'module-modifier': {
|
3807 | pattern: /\b(?:as|hide|show|with)\b/i,
|
3808 | alias: 'keyword'
|
3809 | },
|
3810 | 'placeholder': {
|
3811 | pattern: /%[-\w]+/,
|
3812 | alias: 'selector'
|
3813 | },
|
3814 | 'statement': {
|
3815 | pattern: /\B!(?:default|optional)\b/i,
|
3816 | alias: 'keyword'
|
3817 | },
|
3818 | 'boolean': /\b(?:false|true)\b/,
|
3819 | 'null': {
|
3820 | pattern: /\bnull\b/,
|
3821 | alias: 'keyword'
|
3822 | },
|
3823 | 'operator': {
|
3824 | pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,
|
3825 | lookbehind: true
|
3826 | }
|
3827 | });
|
3828 | prism.languages.scss['atrule'].inside.rest = prism.languages.scss;
|
3829 | /* "prismjs/components/prism-stylus" */
|
3830 |
|
3831 | (function (Prism) {
|
3832 | var unit = {
|
3833 | pattern: /(\b\d+)(?:%|[a-z]+)/,
|
3834 | lookbehind: true
|
3835 | }; // 123 -123 .123 -.123 12.3 -12.3
|
3836 |
|
3837 | var number = {
|
3838 | pattern: /(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)/,
|
3839 | lookbehind: true
|
3840 | };
|
3841 | var inside = {
|
3842 | 'comment': {
|
3843 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
3844 | lookbehind: true
|
3845 | },
|
3846 | 'url': {
|
3847 | pattern: /\burl\((["']?).*?\1\)/i,
|
3848 | greedy: true
|
3849 | },
|
3850 | 'string': {
|
3851 | pattern: /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
|
3852 | greedy: true
|
3853 | },
|
3854 | 'interpolation': null,
|
3855 | // See below
|
3856 | 'func': null,
|
3857 | // See below
|
3858 | 'important': /\B!(?:important|optional)\b/i,
|
3859 | 'keyword': {
|
3860 | pattern: /(^|\s+)(?:(?:else|for|if|return|unless)(?=\s|$)|@[\w-]+)/,
|
3861 | lookbehind: true
|
3862 | },
|
3863 | 'hexcode': /#[\da-f]{3,6}/i,
|
3864 | 'color': [/\b(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)\b/i, {
|
3865 | pattern: /\b(?:hsl|rgb)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:hsl|rgb)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,
|
3866 | inside: {
|
3867 | 'unit': unit,
|
3868 | 'number': number,
|
3869 | 'function': /[\w-]+(?=\()/,
|
3870 | 'punctuation': /[(),]/
|
3871 | }
|
3872 | }],
|
3873 | 'entity': /\\[\da-f]{1,8}/i,
|
3874 | 'unit': unit,
|
3875 | 'boolean': /\b(?:false|true)\b/,
|
3876 | 'operator': [// We want non-word chars around "-" because it is
|
3877 | // accepted in property names.
|
3878 | /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.{2,3}|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/],
|
3879 | 'number': number,
|
3880 | 'punctuation': /[{}()\[\];:,]/
|
3881 | };
|
3882 | inside['interpolation'] = {
|
3883 | pattern: /\{[^\r\n}:]+\}/,
|
3884 | alias: 'variable',
|
3885 | inside: {
|
3886 | 'delimiter': {
|
3887 | pattern: /^\{|\}$/,
|
3888 | alias: 'punctuation'
|
3889 | },
|
3890 | rest: inside
|
3891 | }
|
3892 | };
|
3893 | inside['func'] = {
|
3894 | pattern: /[\w-]+\([^)]*\).*/,
|
3895 | inside: {
|
3896 | 'function': /^[^(]+/,
|
3897 | rest: inside
|
3898 | }
|
3899 | };
|
3900 | Prism.languages.stylus = {
|
3901 | 'atrule-declaration': {
|
3902 | pattern: /(^[ \t]*)@.+/m,
|
3903 | lookbehind: true,
|
3904 | inside: {
|
3905 | 'atrule': /^@[\w-]+/,
|
3906 | rest: inside
|
3907 | }
|
3908 | },
|
3909 | 'variable-declaration': {
|
3910 | pattern: /(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:\{[^{}]*\}|\S.*|$)/m,
|
3911 | lookbehind: true,
|
3912 | inside: {
|
3913 | 'variable': /^\S+/,
|
3914 | rest: inside
|
3915 | }
|
3916 | },
|
3917 | 'statement': {
|
3918 | pattern: /(^[ \t]*)(?:else|for|if|return|unless)[ \t].+/m,
|
3919 | lookbehind: true,
|
3920 | inside: {
|
3921 | 'keyword': /^\S+/,
|
3922 | rest: inside
|
3923 | }
|
3924 | },
|
3925 | // A property/value pair cannot end with a comma or a brace
|
3926 | // It cannot have indented content unless it ended with a semicolon
|
3927 | 'property-declaration': {
|
3928 | pattern: /((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)(?!\s)[^{\r\n]*(?:;|[^{\r\n,]$(?!(?:\r?\n|\r)(?:\{|\2[ \t])))/m,
|
3929 | lookbehind: true,
|
3930 | inside: {
|
3931 | 'property': {
|
3932 | pattern: /^[^\s:]+/,
|
3933 | inside: {
|
3934 | 'interpolation': inside.interpolation
|
3935 | }
|
3936 | },
|
3937 | rest: inside
|
3938 | }
|
3939 | },
|
3940 | // A selector can contain parentheses only as part of a pseudo-element
|
3941 | // It can span multiple lines.
|
3942 | // It must end with a comma or an accolade or have indented content.
|
3943 | 'selector': {
|
3944 | pattern: /(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t])))/m,
|
3945 | lookbehind: true,
|
3946 | inside: {
|
3947 | 'interpolation': inside.interpolation,
|
3948 | 'comment': inside.comment,
|
3949 | 'punctuation': /[{},]/
|
3950 | }
|
3951 | },
|
3952 | 'func': inside.func,
|
3953 | 'string': inside.string,
|
3954 | 'comment': {
|
3955 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
3956 | lookbehind: true,
|
3957 | greedy: true
|
3958 | },
|
3959 | 'interpolation': inside.interpolation,
|
3960 | 'punctuation': /[{}()\[\];:.]/
|
3961 | };
|
3962 | })(prism);
|
3963 | /* "prismjs/components/prism-tsx" */
|
3964 |
|
3965 |
|
3966 | (function (Prism) {
|
3967 | var typescript = Prism.util.clone(Prism.languages.typescript);
|
3968 | Prism.languages.tsx = Prism.languages.extend('jsx', typescript); // doesn't work with TS because TS is too complex
|
3969 |
|
3970 | delete Prism.languages.tsx['parameter'];
|
3971 | delete Prism.languages.tsx['literal-property']; // This will prevent collisions between TSX tags and TS generic types.
|
3972 | // Idea by https://github.com/karlhorky
|
3973 | // Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928
|
3974 |
|
3975 | var tag = Prism.languages.tsx.tag;
|
3976 | tag.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + '(?:' + tag.pattern.source + ')', tag.pattern.flags);
|
3977 | tag.lookbehind = true;
|
3978 | })(prism);
|
3979 | /* "prismjs/components/prism-wasm" */
|
3980 |
|
3981 |
|
3982 | prism.languages.wasm = {
|
3983 | 'comment': [/\(;[\s\S]*?;\)/, {
|
3984 | pattern: /;;.*/,
|
3985 | greedy: true
|
3986 | }],
|
3987 | 'string': {
|
3988 | pattern: /"(?:\\[\s\S]|[^"\\])*"/,
|
3989 | greedy: true
|
3990 | },
|
3991 | 'keyword': [{
|
3992 | pattern: /\b(?:align|offset)=/,
|
3993 | inside: {
|
3994 | 'operator': /=/
|
3995 | }
|
3996 | }, {
|
3997 | pattern: /\b(?:(?:f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|neg?|nearest|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|sqrt|store(?:8|16|32)?|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))?|memory\.(?:grow|size))\b/,
|
3998 | inside: {
|
3999 | 'punctuation': /\./
|
4000 | }
|
4001 | }, /\b(?:anyfunc|block|br(?:_if|_table)?|call(?:_indirect)?|data|drop|elem|else|end|export|func|get_(?:global|local)|global|if|import|local|loop|memory|module|mut|nop|offset|param|result|return|select|set_(?:global|local)|start|table|tee_local|then|type|unreachable)\b/],
|
4002 | 'variable': /\$[\w!#$%&'*+\-./:<=>?@\\^`|~]+/,
|
4003 | 'number': /[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/,
|
4004 | 'punctuation': /[()]/
|
4005 | };
|
4006 |
|
4007 | module.exports = prism;
|