History

Update Prism.js

Thibaut Courouble committed 8 years ago

Commit e8a20a81 parent 0429e071 file · +633 −376Browse files

Unified · Split

assets/javascripts/vendor/prism.js+633−376
@@ -1,4 +1,5 @@
1−/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+django+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+jsx+crystal+rust+scss+sql+typescript+yaml */
1+/* PrismJS 1.15.0
2+https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+django+elixir+markup-templating+erlang+go+java+json+kotlin+lua+crystal+nginx+nim+perl+php+sql+scss+python+jsx+typescript+rust+yaml */
23 var _self = (typeof window !== 'undefined')
34 ? window // if in browser
45 : (
@@ -16,11 +17,12 @@ var _self = (typeof window !== 'undefined') · 11 unmodified lines
1617 var Prism = (function(){
1718
1819 // Private helper vars
19−var lang = /\blang(?:uage)?-(\w+)\b/i;
20+var lang = /\blang(?:uage)?-([\w-]+)\b/i;
2021 var uniqueId = 0;
2122
2223 var _ = _self.Prism = {
2324 manual: _self.Prism && _self.Prism.manual,
25+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
2426 util: {
2527 encode: function (tokens) {
2628 if (tokens instanceof Token) {
@@ -44,23 +46,38 @@ var _ = _self.Prism = { · 17 unmodified lines
4446 },
4547
4648 // Deep clone a language definition (e.g. to extend it)
47− clone: function (o) {
49+ clone: function (o, visited) {
4850 var type = _.util.type(o);
51+ visited = visited || {};
4952
5053 switch (type) {
5154 case 'Object':
55+ if (visited[_.util.objId(o)]) {
56+ return visited[_.util.objId(o)];
57+ }
5258 var clone = {};
59+ visited[_.util.objId(o)] = clone;
5360
5461 for (var key in o) {
5562 if (o.hasOwnProperty(key)) {
56− clone[key] = _.util.clone(o[key]);
63+ clone[key] = _.util.clone(o[key], visited);
5764 }
5865 }
5966
6067 return clone;
6168
6269 case 'Array':
63− return o.map(function(v) { return _.util.clone(v); });
70+ if (visited[_.util.objId(o)]) {
71+ return visited[_.util.objId(o)];
72+ }
73+ var clone = [];
74+ visited[_.util.objId(o)] = clone;
75+
76+ o.forEach(function (v, i) {
77+ clone[i] = _.util.clone(v, visited);
78+ });
79+
80+ return clone;
6481 }
6582
6683 return o;
@@ -155,6 +172,10 @@ var _ = _self.Prism = { · 88 unmodified lines
155172 plugins: {},
156173
157174 highlightAll: function(async, callback) {
175+ _.highlightAllUnder(document, async, callback);
176+ },
177+
178+ highlightAllUnder: function(container, async, callback) {
158179 var env = {
159180 callback: callback,
160181 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
@@ -162,7 +183,7 @@ var _ = _self.Prism = { · 1 unmodified line
162183
163184 _.hooks.run("before-highlightall", env);
164185
165− var elements = env.elements || document.querySelectorAll(env.selector);
186+ var elements = env.elements || container.querySelectorAll(env.selector);
166187
167188 for (var i=0, element; element = elements[i++];) {
168189 _.highlightElement(element, async === true, env.callback);
@@ -185,11 +206,13 @@ var _ = _self.Prism = { · 16 unmodified lines
185206 // Set language on the element, if not present
186207 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
187208
188− // Set language on the parent, for styling
189− parent = element.parentNode;
209+ if (element.parentNode) {
210+ // Set language on the parent, for styling
211+ parent = element.parentNode;
190212
191− if (/pre/i.test(parent.nodeName)) {
192− parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
213+ if (/pre/i.test(parent.nodeName)) {
214+ parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
215+ }
193216 }
194217
195218 var code = element.textContent;
@@ -251,8 +274,15 @@ var _ = _self.Prism = { · 55 unmodified lines
251274 },
252275
253276 highlight: function (text, grammar, language) {
254− var tokens = _.tokenize(text, grammar);
255− return Token.stringify(_.util.encode(tokens), language);
277+ var env = {
278+ code: text,
279+ grammar: grammar,
280+ language: language
281+ };
282+ _.hooks.run('before-tokenize', env);
283+ env.tokens = _.tokenize(env.code, env.grammar);
284+ _.hooks.run('after-tokenize', env);
285+ return Token.stringify(_.util.encode(env.tokens), env.language);
256286 },
257287
258288 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
@@ -300,15 +330,9 @@ var _ = _self.Prism = { · 41 unmodified lines
300330 continue;
301331 }
302332
303− pattern.lastIndex = 0;
304−
305− var match = pattern.exec(str),
306− delNum = 1;
307−
308− // Greedy patterns can override/remove up to two previously matched tokens
309− if (!match && greedy && i != strarr.length - 1) {
333+ if (greedy && i != strarr.length - 1) {
310334 pattern.lastIndex = pos;
311− match = pattern.exec(text);
335+ var match = pattern.exec(text);
312336 if (!match) {
313337 break;
314338 }
@@ -327,11 +351,8 @@ var _ = _self.Prism = { · 12 unmodified lines
327351 }
328352 }
329353
330− /*
331− * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
332− * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
333− */
334− if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
354+ // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
355+ if (strarr[i] instanceof Token) {
335356 continue;
336357 }
337358
@@ -339,6 +360,11 @@ var _ = _self.Prism = { · 1 unmodified line
339360 delNum = k - i;
340361 str = text.slice(pos, p);
341362 match.index -= pos;
363+ } else {
364+ pattern.lastIndex = 0;
365+
366+ var match = pattern.exec(str),
367+ delNum = 1;
342368 }
343369
344370 if (!match) {
@@ -350,7 +376,7 @@ var _ = _self.Prism = { · 5 unmodified lines
350376 }
351377
352378 if(lookbehind) {
353− lookbehindLength = match[1].length;
379+ lookbehindLength = match[1] ? match[1].length : 0;
354380 }
355381
356382 var from = match.index + lookbehindLength,
@@ -480,18 +506,21 @@ Token.stringify = function(o, language, parent) { · 123 unmodified lines
480506 // // in Node.js
481507 // return _self.Prism;
482508 // }
483−// // In worker
484−// _self.addEventListener('message', function(evt) {
485−// var message = JSON.parse(evt.data),
486−// lang = message.language,
487−// code = message.code,
488−// immediateClose = message.immediateClose;
489−
490−// _self.postMessage(_.highlight(code, _.languages[lang], lang));
491−// if (immediateClose) {
492−// _self.close();
493−// }
494−// }, false);
509+
510+// if (!_.disableWorkerMessageHandler) {
511+// // In worker
512+// _self.addEventListener('message', function (evt) {
513+// var message = JSON.parse(evt.data),
514+// lang = message.language,
515+// code = message.code,
516+// immediateClose = message.immediateClose;
517+
518+// _self.postMessage(_.highlight(code, _.languages[lang], lang));
519+// if (immediateClose) {
520+// _self.close();
521+// }
522+// }, false);
523+// }
495524
496525 // return _self.Prism;
497526 // }
@@ -535,7 +564,8 @@ Prism.languages.markup = { · 37 unmodified lines
535564 'doctype': /<!DOCTYPE[\s\S]+?>/i,
536565 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
537566 'tag': {
538− pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
567+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
568+ greedy: true,
539569 inside: {
540570 'tag': {
541571 pattern: /^<\/?[^\s>\/]+/i,
@@ -600,13 +630,13 @@ Prism.languages.css = { · 58 unmodified lines
600630 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
601631 greedy: true
602632 },
603− 'property': /[\w-]+(?=\s*:)/i,
633+ 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
604634 'important': /\B!important\b/i,
605635 'function': /[-a-z0-9]+(?=\()/i,
606636 'punctuation': /[(){};:]/
607637 };
608638
609−Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
639+Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
610640
611641 if (Prism.languages.markup) {
612642 Prism.languages.insertBefore('markup', 'tag', {
@@ -614,10 +644,11 @@ if (Prism.languages.markup) { · 1 unmodified line
614644 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
615645 lookbehind: true,
616646 inside: Prism.languages.css,
617− alias: 'language-css'
647+ alias: 'language-css',
648+ greedy: true
618649 }
619650 });
620−
651+
621652 Prism.languages.insertBefore('inside', 'attr-value', {
622653 'style-attr': {
623654 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
@@ -644,7 +675,8 @@ Prism.languages.clike = { · 20 unmodified lines
644675 },
645676 {
646677 pattern: /(^|[^\\:])\/\/.*/,
647− lookbehind: true
678+ lookbehind: true,
679+ greedy: true
648680 }
649681 ],
650682 'string': {
@@ -661,51 +693,53 @@ Prism.languages.clike = { · 10 unmodified lines
661693 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
662694 'boolean': /\b(?:true|false)\b/,
663695 'function': /[a-z0-9_]+(?=\()/i,
664− 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
696+ 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
665697 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
666698 'punctuation': /[{}[\];(),.:]/
667699 };
668700
669701 Prism.languages.javascript = Prism.languages.extend('clike', {
670702 'keyword': /\b(?: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|var|void|while|with|yield)\b/,
671− 'number': /\b-?(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+(?:[Ee][+-]?\d+)?|NaN|Infinity)\b/,
703+ 'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
672704 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
673− 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*\()/i,
705+ 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,
674706 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
675707 });
676708
677709 Prism.languages.insertBefore('javascript', 'keyword', {
678710 'regex': {
679− pattern: /(^|[^/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
711+ pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,
680712 lookbehind: true,
681713 greedy: true
682714 },
683715 // This must be declared before keyword because we use "function" inside the look-forward
684716 'function-variable': {
685− pattern: /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)\s*=>))/i,
717+ pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,
686718 alias: 'function'
687− }
719+ },
720+ 'constant': /\b[A-Z][A-Z\d_]*\b/
688721 });
689722
690723 Prism.languages.insertBefore('javascript', 'string', {
691724 'template-string': {
692− pattern: /`(?:\\[\s\S]|[^\\`])*`/,
725+ pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,
693726 greedy: true,
694727 inside: {
695728 'interpolation': {
696− pattern: /\$\{[^}]+\}/,
729+ pattern: /\${[^}]+}/,
697730 inside: {
698731 'interpolation-punctuation': {
699− pattern: /^\$\{|\}$/,
732+ pattern: /^\${|}$/,
700733 alias: 'punctuation'
701734 },
702− rest: Prism.languages.javascript
735+ rest: null // See below
703736 }
704737 },
705738 'string': /[\s\S]+/
706739 }
707740 }
708741 });
742+Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript;
709743
710744 if (Prism.languages.markup) {
711745 Prism.languages.insertBefore('markup', 'tag', {
@@ -713,7 +747,8 @@ if (Prism.languages.markup) { · 1 unmodified line
713747 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
714748 lookbehind: true,
715749 inside: Prism.languages.javascript,
716− alias: 'language-javascript'
750+ alias: 'language-javascript',
751+ greedy: true
717752 }
718753 });
719754 }
@@ -723,7 +758,7 @@ Prism.languages.js = Prism.languages.javascript; · 3 unmodified lines
723758 Prism.languages.c = Prism.languages.extend('clike', {
724759 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
725760 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,
726− 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
761+ 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
727762 });
728763
729764 Prism.languages.insertBefore('c', 'string', {
@@ -768,7 +803,7 @@ delete Prism.languages.c['boolean']; · 38 unmodified lines
768803 },
769804 /^\$\(\(/
770805 ],
771− number: /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee]-?\d+)?)\b/,
806+ number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
772807 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
773808 operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
774809 // If there is no $ sign at the beginning highlight (( and )) as punctuation
@@ -778,6 +813,7 @@ delete Prism.languages.c['boolean']; · 3 unmodified lines
778813 // Command Substitution
779814 {
780815 pattern: /\$\([^)]+\)|`[^`]+`/,
816+ greedy: true,
781817 inside: {
782818 variable: /^\$\(|^`|\)$|`$/
783819 }
@@ -804,7 +840,7 @@ delete Prism.languages.c['boolean']; · 20 unmodified lines
804840 inside: insideString
805841 },
806842 {
807− pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
843+ pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
808844 greedy: true,
809845 inside: insideString
810846 }
@@ -812,7 +848,7 @@ delete Prism.languages.c['boolean']; · 1 unmodified line
812848 'variable': insideString.variable,
813849 // Originally based on http://ss64.com/bash/
814850 'function': {
815− pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/,
851+ pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/,
816852 lookbehind: true
817853 },
818854 'keyword': {
@@ -828,15 +864,18 @@ delete Prism.languages.c['boolean']; · 9 unmodified lines
828864 };
829865
830866 var inside = insideString.variable[1].inside;
867+ inside.string = Prism.languages.bash.string;
831868 inside['function'] = Prism.languages.bash['function'];
832869 inside.keyword = Prism.languages.bash.keyword;
833− inside.boolean = Prism.languages.bash.boolean;
870+ inside['boolean'] = Prism.languages.bash['boolean'];
834871 inside.operator = Prism.languages.bash.operator;
835872 inside.punctuation = Prism.languages.bash.punctuation;
873+
874+ Prism.languages.shell = Prism.languages.bash;
836875 })(Prism);
837876
838877 Prism.languages.cpp = Prism.languages.extend('c', {
839− 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
878+ 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
840879 'boolean': /\b(?:true|false)\b/,
841880 'operator': /--?|\+\+?|!=?|<{1,2}=?|>{1,2}=?|->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|\|?|\?|\*|\/|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/
842881 });
@@ -847,6 +886,15 @@ Prism.languages.insertBefore('cpp', 'keyword', { · 4 unmodified lines
847886 lookbehind: true
848887 }
849888 });
889+
890+Prism.languages.insertBefore('cpp', 'string', {
891+ 'raw-string': {
892+ pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
893+ alias: 'string',
894+ greedy: true
895+ }
896+});
897+
850898 (function(Prism) {
851899
852900 // Ignore comments starting with { to privilege string interpolation highlighting
@@ -947,10 +995,13 @@ delete Prism.languages.coffeescript['template-string']; · 94 unmodified lines
947995 (function(Prism) {
948996 Prism.languages.ruby = Prism.languages.extend('clike', {
949997 'comment': [
950− /#(?!\{[^\r\n]*?\}).*/,
951− /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m
998+ /#.*/,
999+ {
1000+ pattern: /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m,
1001+ greedy: true
1002+ }
9521003 ],
953− 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
1004+ 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
9541005 });
9551006
9561007 var interpolation = {
@@ -960,7 +1011,7 @@ delete Prism.languages.coffeescript['template-string']; · 3 unmodified lines
9601011 pattern: /^#\{|\}$/,
9611012 alias: 'tag'
9621013 },
963− rest: Prism.util.clone(Prism.languages.ruby)
1014+ rest: Prism.languages.ruby
9641015 }
9651016 };
9661017
@@ -1009,7 +1060,10 @@ delete Prism.languages.coffeescript['template-string']; · 42 unmodified lines
10091060 }
10101061 ],
10111062 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
1012− 'symbol': /:[a-zA-Z_]\w*(?:[?!]|\b)/
1063+ 'symbol': {
1064+ pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
1065+ lookbehind: true
1066+ }
10131067 });
10141068
10151069 Prism.languages.insertBefore('ruby', 'number', {
@@ -1127,6 +1181,30 @@ Prism.languages.insertBefore('d', 'function', { · 111 unmodified lines
11271181 alias: 'variable'
11281182 }
11291183 });
1184+Prism.languages.dart = Prism.languages.extend('clike', {
1185+ 'string': [
1186+ {
1187+ pattern: /r?("""|''')[\s\S]*?\1/,
1188+ greedy: true
1189+ },
1190+ {
1191+ pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
1192+ greedy: true
1193+ }
1194+ ],
1195+ 'keyword': [
1196+ /\b(?:async|sync|yield)\*/,
1197+ /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/
1198+ ],
1199+ 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
1200+});
1201+
1202+Prism.languages.insertBefore('dart','function',{
1203+ 'metadata': {
1204+ pattern: /@\w+/,
1205+ alias: 'symbol'
1206+ }
1207+});
11301208 // Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
11311209 // Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
11321210
@@ -1170,15 +1248,15 @@ if (Prism.languages.css) { · 37 unmodified lines
11701248 Prism.languages.jinja2 = Prism.languages.django;
11711249
11721250 Prism.languages.elixir = {
1173− // Negative look-ahead is needed for string interpolation
1174− // Negative look-behind is needed to avoid highlighting markdown headers in
1175− // multi-line doc strings
11761251 'comment': {
1177− pattern: /(^|[^#])#(?![{#]).*/m,
1252+ pattern: /#.*/m,
11781253 lookbehind: true
11791254 },
11801255 // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
1181− 'regex': /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
1256+ 'regex': {
1257+ pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
1258+ greedy: true
1259+ },
11821260 'string': [
11831261 {
11841262 // ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>
@@ -1225,7 +1303,7 @@ Prism.languages.elixir = { · 40 unmodified lines
12251303 alias: 'variable'
12261304 },
12271305 'attribute': {
1228− pattern: /@[\S]+/,
1306+ pattern: /@\w+/,
12291307 alias: 'variable'
12301308 },
12311309 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
@@ -1256,13 +1334,102 @@ Prism.languages.elixir.string.forEach(function(o) { · 24 unmodified lines
12561334 pattern: /^#\{|\}$/,
12571335 alias: 'punctuation'
12581336 },
1259− rest: Prism.util.clone(Prism.languages.elixir)
1337+ rest: Prism.languages.elixir
12601338 }
12611339 }
12621340 };
12631341 });
12641342
12651343
1344+Prism.languages['markup-templating'] = {};
1345+
1346+Object.defineProperties(Prism.languages['markup-templating'], {
1347+ buildPlaceholders: {
1348+ // Tokenize all inline templating expressions matching placeholderPattern
1349+ // If the replaceFilter function is provided, it will be called with every match.
1350+ // If it returns false, the match will not be replaced.
1351+ value: function (env, language, placeholderPattern, replaceFilter) {
1352+ if (env.language !== language) {
1353+ return;
1354+ }
1355+
1356+ env.tokenStack = [];
1357+
1358+ env.code = env.code.replace(placeholderPattern, function(match) {
1359+ if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
1360+ return match;
1361+ }
1362+ var i = env.tokenStack.length;
1363+ // Check for existing strings
1364+ while (env.code.indexOf('___' + language.toUpperCase() + i + '___') !== -1)
1365+ ++i;
1366+
1367+ // Create a sparse array
1368+ env.tokenStack[i] = match;
1369+
1370+ return '___' + language.toUpperCase() + i + '___';
1371+ });
1372+
1373+ // Switch the grammar to markup
1374+ env.grammar = Prism.languages.markup;
1375+ }
1376+ },
1377+ tokenizePlaceholders: {
1378+ // Replace placeholders with proper tokens after tokenizing
1379+ value: function (env, language) {
1380+ if (env.language !== language || !env.tokenStack) {
1381+ return;
1382+ }
1383+
1384+ // Switch the grammar back
1385+ env.grammar = Prism.languages[language];
1386+
1387+ var j = 0;
1388+ var keys = Object.keys(env.tokenStack);
1389+ var walkTokens = function (tokens) {
1390+ if (j >= keys.length) {
1391+ return;
1392+ }
1393+ for (var i = 0; i < tokens.length; i++) {
1394+ var token = tokens[i];
1395+ if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
1396+ var k = keys[j];
1397+ var t = env.tokenStack[k];
1398+ var s = typeof token === 'string' ? token : token.content;
1399+
1400+ var index = s.indexOf('___' + language.toUpperCase() + k + '___');
1401+ if (index > -1) {
1402+ ++j;
1403+ var before = s.substring(0, index);
1404+ var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar, language), 'language-' + language, t);
1405+ var after = s.substring(index + ('___' + language.toUpperCase() + k + '___').length);
1406+ var replacement;
1407+ if (before || after) {
1408+ replacement = [before, middle, after].filter(function (v) { return !!v; });
1409+ walkTokens(replacement);
1410+ } else {
1411+ replacement = middle;
1412+ }
1413+ if (typeof token === 'string') {
1414+ Array.prototype.splice.apply(tokens, [i, 1].concat(replacement));
1415+ } else {
1416+ token.content = replacement;
1417+ }
1418+
1419+ if (j >= keys.length) {
1420+ break;
1421+ }
1422+ }
1423+ } else if (token.content && typeof token.content !== 'string') {
1424+ walkTokens(token.content);
1425+ }
1426+ }
1427+ };
1428+
1429+ walkTokens(env.tokens);
1430+ }
1431+ }
1432+});
12661433 Prism.languages.erlang = {
12671434 'comment': /%.+/,
12681435 'string': {
@@ -1282,7 +1449,7 @@ Prism.languages.erlang = { · 13 unmodified lines
12821449 'number': [
12831450 /\$\\?./,
12841451 /\d+#[a-z0-9]+/i,
1285− /(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/
1452+ /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
12861453 ],
12871454 'function': /\b[a-z][\w@]*(?=\()/,
12881455 'variable': {
@@ -1312,7 +1479,7 @@ Prism.languages.go = Prism.languages.extend('clike', { · 23 unmodified lines
13121479 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
13131480 'boolean': /\b(?:_|iota|nil|true|false)\b/,
13141481 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
1315− 'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
1482+ 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
13161483 'string': {
13171484 pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
13181485 greedy: true
@@ -1322,7 +1489,7 @@ delete Prism.languages.go['class-name']; · 3 unmodified lines
13221489
13231490 Prism.languages.java = Prism.languages.extend('clike', {
13241491 'keyword': /\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,
1325− 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,
1492+ 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp-]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?[df]?/i,
13261493 'operator': {
13271494 pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
13281495 lookbehind: true
@@ -1337,14 +1504,25 @@ Prism.languages.insertBefore('java','function', { · 8 unmodified lines
13371504 }
13381505 });
13391506
1507+Prism.languages.insertBefore('java', 'class-name', {
1508+ 'generics': {
1509+ pattern: /<\s*\w+(?:\.\w+)?(?:\s*,\s*\w+(?:\.\w+)?)*>/i,
1510+ alias: 'function',
1511+ inside: {
1512+ keyword: Prism.languages.java.keyword,
1513+ punctuation: /[<>(),.:]/
1514+ }
1515+ }
1516+});
1517+
13401518 Prism.languages.json = {
13411519 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
13421520 'string': {
13431521 pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
13441522 greedy: true
13451523 },
1346− 'number': /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][+-]?\d+)?)\b/,
1347− 'punctuation': /[{}[\]);,]/,
1524+ 'number': /-?\d+\.?\d*([Ee][+-]?\d+)?/,
1525+ 'punctuation': /[{}[\],]/,
13481526 'operator': /:/g,
13491527 'boolean': /\b(?:true|false)\b/i,
13501528 'null': /\bnull\b/i
@@ -1356,7 +1534,7 @@ Prism.languages.jsonp = Prism.languages.json; · 5 unmodified lines
13561534 Prism.languages.kotlin = Prism.languages.extend('clike', {
13571535 'keyword': {
13581536 // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
1359− pattern: /(^|[^.])\b(?:abstract|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|else|enum|final|finally|for|fun|get|if|import|in|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|out|override|package|private|protected|public|reified|return|sealed|set|super|tailrec|this|throw|to|try|val|var|when|where|while)\b/,
1537+ pattern: /(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,
13601538 lookbehind: true
13611539 },
13621540 'function': [
@@ -1366,7 +1544,7 @@ Prism.languages.jsonp = Prism.languages.json; · 3 unmodified lines
13661544 lookbehind: true
13671545 }
13681546 ],
1369− 'number': /\b(?:0[bx][\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?[fFL]?)\b/,
1547+ 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
13701548 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
13711549 });
13721550
@@ -1400,7 +1578,7 @@ Prism.languages.jsonp = Prism.languages.json; · 27 unmodified lines
14001578 pattern: /^\$\{|\}$/,
14011579 alias: 'variable'
14021580 },
1403− rest: Prism.util.clone(Prism.languages.kotlin)
1581+ rest: Prism.languages.kotlin
14041582 }
14051583 },
14061584 {
@@ -1414,6 +1592,7 @@ Prism.languages.jsonp = Prism.languages.json; · 7 unmodified lines
14141592 };
14151593
14161594 }(Prism));
1595+
14171596 Prism.languages.lua = {
14181597 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
14191598 // \z may be used to skip the following space
@@ -1434,16 +1613,68 @@ Prism.languages.lua = { · 14 unmodified lines
14341613 ],
14351614 'punctuation': /[\[\](){},;]|\.+|:+/
14361615 };
1616+(function(Prism) {
1617+ Prism.languages.crystal = Prism.languages.extend('ruby', {
1618+ keyword: [
1619+ /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|select|self|sizeof|struct|super|then|type|typeof|uninitialized|union|unless|until|when|while|with|yield|__DIR__|__END_LINE__|__FILE__|__LINE__)\b/,
1620+ {
1621+ pattern: /(\.\s*)(?:is_a|responds_to)\?/,
1622+ lookbehind: true
1623+ }
1624+ ],
1625+
1626+ number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/
1627+ });
1628+
1629+ Prism.languages.insertBefore('crystal', 'string', {
1630+ attribute: {
1631+ pattern: /@\[.+?\]/,
1632+ alias: 'attr-name',
1633+ inside: {
1634+ delimiter: {
1635+ pattern: /^@\[|\]$/,
1636+ alias: 'tag'
1637+ },
1638+ rest: Prism.languages.crystal
1639+ }
1640+ },
1641+
1642+ expansion: [
1643+ {
1644+ pattern: /\{\{.+?\}\}/,
1645+ inside: {
1646+ delimiter: {
1647+ pattern: /^\{\{|\}\}$/,
1648+ alias: 'tag'
1649+ },
1650+ rest: Prism.languages.crystal
1651+ }
1652+ },
1653+ {
1654+ pattern: /\{%.+?%\}/,
1655+ inside: {
1656+ delimiter: {
1657+ pattern: /^\{%|%\}$/,
1658+ alias: 'tag'
1659+ },
1660+ rest: Prism.languages.crystal
1661+ }
1662+ }
1663+ ]
1664+ });
1665+
1666+}(Prism));
1667+
14371668 Prism.languages.nginx = Prism.languages.extend('clike', {
1438− 'comment': {
1439− pattern: /(^|[^"{\\])#.*/,
1440− lookbehind: true
1441− },
1442− 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i
1669+ 'comment': {
1670+ pattern: /(^|[^"{\\])#.*/,
1671+ lookbehind: true
1672+ },
1673+ 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i
14431674 });
14441675
14451676 Prism.languages.insertBefore('nginx', 'keyword', {
1446− 'variable': /\$[a-z_]+/i
1677+ 'variable': /\$[a-z_]+/i
14471678 });
14481679 Prism.languages.nim = {
14491680 'comment': /#.*/,
@@ -1497,31 +1728,31 @@ Prism.languages.perl = { · 47 unmodified lines
14971728 pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
14981729 greedy: true
14991730 },
1500−
1731+
15011732 // q a...a
15021733 {
15031734 pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
15041735 greedy: true
15051736 },
1506−
1737+
15071738 // q(...)
15081739 {
15091740 pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
15101741 greedy: true
15111742 },
1512−
1743+
15131744 // q{...}
15141745 {
15151746 pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
15161747 greedy: true
15171748 },
1518−
1749+
15191750 // q[...]
15201751 {
15211752 pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
15221753 greedy: true
15231754 },
1524−
1755+
15251756 // q<...>
15261757 {
15271758 pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
@@ -1547,31 +1778,31 @@ Prism.languages.perl = { · 19 unmodified lines
15471778 pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
15481779 greedy: true
15491780 },
1550−
1781+
15511782 // m a...a
15521783 {
15531784 pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
15541785 greedy: true
15551786 },
1556−
1787+
15571788 // m(...)
15581789 {
15591790 pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
15601791 greedy: true
15611792 },
1562−
1793+
15631794 // m{...}
15641795 {
15651796 pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
15661797 greedy: true
15671798 },
1568−
1799+
15691800 // m[...]
15701801 {
15711802 pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
15721803 greedy: true
15731804 },
1574−
1805+
15751806 // m<...>
15761807 {
15771808 pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
@@ -1586,42 +1817,42 @@ Prism.languages.perl = { · 8 unmodified lines
15861817 lookbehind: true,
15871818 greedy: true
15881819 },
1589−
1820+
15901821 // s a...a...a
15911822 {
15921823 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
15931824 lookbehind: true,
15941825 greedy: true
15951826 },
1596−
1827+
15971828 // s(...)(...)
15981829 {
15991830 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
16001831 lookbehind: true,
16011832 greedy: true
16021833 },
1603−
1834+
16041835 // s{...}{...}
16051836 {
16061837 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
16071838 lookbehind: true,
16081839 greedy: true
16091840 },
1610−
1841+
16111842 // s[...][...]
16121843 {
16131844 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
16141845 lookbehind: true,
16151846 greedy: true
16161847 },
1617−
1848+
16181849 // s<...><...>
16191850 {
16201851 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
16211852 lookbehind: true,
16221853 greedy: true
16231854 },
1624−
1855+
16251856 // /.../
16261857 // The look-ahead tries to prevent two divisions on
16271858 // the same line from being highlighted as regex.
@@ -1665,7 +1896,7 @@ Prism.languages.perl = { · 37 unmodified lines
16651896 }
16661897 },
16671898 'keyword': /\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/,
1668− 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
1899+ 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
16691900 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
16701901 'punctuation': /[{}[\];(),:]/
16711902 };
@@ -1682,110 +1913,211 @@ Prism.languages.perl = { · 10 unmodified lines
16821913 * Adds the following new token classes:
16831914 * constant, delimiter, variable, function, package
16841915 */
1916+(function (Prism) {
1917+ Prism.languages.php = Prism.languages.extend('clike', {
1918+ 'keyword': /\b(?:and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
1919+ 'constant': /\b[A-Z0-9_]{2,}\b/,
1920+ 'comment': {
1921+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1922+ lookbehind: true
1923+ }
1924+ });
16851925
1686−Prism.languages.php = Prism.languages.extend('clike', {
1687− 'keyword': /\b(?:and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
1688− 'constant': /\b[A-Z0-9_]{2,}\b/,
1689− 'comment': {
1690− pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1691− lookbehind: true
1692− }
1693−});
1926+ Prism.languages.insertBefore('php', 'string', {
1927+ 'shell-comment': {
1928+ pattern: /(^|[^\\])#.*/,
1929+ lookbehind: true,
1930+ alias: 'comment'
1931+ }
1932+ });
16941933
1695−// Shell-like comments are matched after strings, because they are less
1696−// common than strings containing hashes...
1697−Prism.languages.insertBefore('php', 'class-name', {
1698− 'shell-comment': {
1699− pattern: /(^|[^\\])#.*/,
1700− lookbehind: true,
1701− alias: 'comment'
1702− }
1703−});
1934+ Prism.languages.insertBefore('php', 'keyword', {
1935+ 'delimiter': {
1936+ pattern: /\?>|<\?(?:php|=)?/i,
1937+ alias: 'important'
1938+ },
1939+ 'variable': /\$+(?:\w+\b|(?={))/i,
1940+ 'package': {
1941+ pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1942+ lookbehind: true,
1943+ inside: {
1944+ punctuation: /\\/
1945+ }
1946+ }
1947+ });
17041948
1705−Prism.languages.insertBefore('php', 'keyword', {
1706− 'delimiter': {
1707− pattern: /\?>|<\?(?:php|=)?/i,
1708− alias: 'important'
1709− },
1710− 'variable': /\$\w+\b/i,
1711− 'package': {
1712− pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1713− lookbehind: true,
1714− inside: {
1715− punctuation: /\\/
1949+ // Must be defined after the function pattern
1950+ Prism.languages.insertBefore('php', 'operator', {
1951+ 'property': {
1952+ pattern: /(->)[\w]+/,
1953+ lookbehind: true
17161954 }
1717− }
1718−});
1955+ });
17191956
1720−// Must be defined after the function pattern
1721−Prism.languages.insertBefore('php', 'operator', {
1722− 'property': {
1723− pattern: /(->)[\w]+/,
1724− lookbehind: true
1725− }
1726−});
1957+ Prism.languages.insertBefore('php', 'string', {
1958+ 'nowdoc-string': {
1959+ pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
1960+ greedy: true,
1961+ alias: 'string',
1962+ inside: {
1963+ 'delimiter': {
1964+ pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
1965+ alias: 'symbol',
1966+ inside: {
1967+ 'punctuation': /^<<<'?|[';]$/
1968+ }
1969+ }
1970+ }
1971+ },
1972+ 'heredoc-string': {
1973+ pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
1974+ greedy: true,
1975+ alias: 'string',
1976+ inside: {
1977+ 'delimiter': {
1978+ pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
1979+ alias: 'symbol',
1980+ inside: {
1981+ 'punctuation': /^<<<"?|[";]$/
1982+ }
1983+ },
1984+ 'interpolation': null // See below
1985+ }
1986+ },
1987+ 'single-quoted-string': {
1988+ pattern: /'(?:\\[\s\S]|[^\\'])*'/,
1989+ greedy: true,
1990+ alias: 'string'
1991+ },
1992+ 'double-quoted-string': {
1993+ pattern: /"(?:\\[\s\S]|[^\\"])*"/,
1994+ greedy: true,
1995+ alias: 'string',
1996+ inside: {
1997+ 'interpolation': null // See below
1998+ }
1999+ }
2000+ });
2001+ // The different types of PHP strings "replace" the C-like standard string
2002+ delete Prism.languages.php['string'];
17272003
1728−// Add HTML support if the markup language exists
1729−if (Prism.languages.markup) {
2004+ var string_interpolation = {
2005+ pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
2006+ lookbehind: true,
2007+ inside: {
2008+ rest: Prism.languages.php
2009+ }
2010+ };
2011+ Prism.languages.php['heredoc-string'].inside['interpolation'] = string_interpolation;
2012+ Prism.languages.php['double-quoted-string'].inside['interpolation'] = string_interpolation;
17302013
1731− // Tokenize all inline PHP blocks that are wrapped in <?php ?>
1732− // This allows for easy PHP + markup highlighting
1733− Prism.hooks.add('before-highlight', function(env) {
1734− if (env.language !== 'php' || !/(?:<\?php|<\?)/ig.test(env.code)) {
2014+ Prism.hooks.add('before-tokenize', function(env) {
2015+ if (!/(?:<\?php|<\?)/ig.test(env.code)) {
17352016 return;
17362017 }
17372018
1738− env.tokenStack = [];
1739−
1740− env.backupCode = env.code;
1741− env.code = env.code.replace(/(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig, function(match) {
1742− var i = env.tokenStack.length;
1743− // Check for existing strings
1744− while (env.backupCode.indexOf('___PHP' + i + '___') !== -1)
1745− ++i;
1746−
1747− // Create a sparse array
1748− env.tokenStack[i] = match;
1749−
1750− return '___PHP' + i + '___';
1751− });
2019+ var phpPattern = /(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig;
2020+ Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
2021+ });
17522022
1753− // Switch the grammar to markup
1754− env.grammar = Prism.languages.markup;
2023+ Prism.hooks.add('after-tokenize', function(env) {
2024+ Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
17552025 });
17562026
1757− // Restore env.code for other plugins (e.g. line-numbers)
1758− Prism.hooks.add('before-insert', function(env) {
1759− if (env.language === 'php' && env.backupCode) {
1760− env.code = env.backupCode;
1761− delete env.backupCode;
2027+}(Prism));
2028+Prism.languages.sql= {
2029+ 'comment': {
2030+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
2031+ lookbehind: true
2032+ },
2033+ 'string' : {
2034+ pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\])*\2/,
2035+ greedy: true,
2036+ lookbehind: true
2037+ },
2038+ 'variable': /@[\w.$]+|@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2039+ 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too?
2040+ '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(?:_INSERT|COL)?|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|RETURNS?|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,
2041+ 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2042+ 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
2043+ 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2044+ 'punctuation': /[;[\]()`,.]/
2045+};
2046+Prism.languages.scss = Prism.languages.extend('css', {
2047+ 'comment': {
2048+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
2049+ lookbehind: true
2050+ },
2051+ 'atrule': {
2052+ pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
2053+ inside: {
2054+ 'rule': /@[\w-]+/
2055+ // See rest below
17622056 }
1763− });
2057+ },
2058+ // url, compassified
2059+ 'url': /(?:[-a-z]+-)*url(?=\()/i,
2060+ // CSS selector regex is not appropriate for Sass
2061+ // since there can be lot more things (var, @ directive, nesting..)
2062+ // a selector must start at the end of a property or after a brace (end of other rules or nesting)
2063+ // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
2064+ // 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
2065+ // can "pass" as a selector- e.g: proper#{$erty})
2066+ // this one was hard to do, so please be careful if you edit this one :)
2067+ 'selector': {
2068+ // Initial look-ahead is used to prevent matching of blank selectors
2069+ pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|&|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
2070+ inside: {
2071+ 'parent': {
2072+ pattern: /&/,
2073+ alias: 'important'
2074+ },
2075+ 'placeholder': /%[-\w]+/,
2076+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2077+ }
2078+ }
2079+});
17642080
1765− // Re-insert the tokens after highlighting
1766− Prism.hooks.add('after-highlight', function(env) {
1767− if (env.language !== 'php' || !env.tokenStack) {
1768− return;
2081+Prism.languages.insertBefore('scss', 'atrule', {
2082+ 'keyword': [
2083+ /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
2084+ {
2085+ pattern: /( +)(?:from|through)(?= )/,
2086+ lookbehind: true
17692087 }
2088+ ]
2089+});
17702090
1771− // Switch the grammar back
1772− env.grammar = Prism.languages.php;
2091+Prism.languages.scss.property = {
2092+ pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2093+ inside: {
2094+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2095+ }
2096+};
17732097
1774− for (var i = 0, keys = Object.keys(env.tokenStack); i < keys.length; ++i) {
1775− var k = keys[i];
1776− var t = env.tokenStack[k];
2098+Prism.languages.insertBefore('scss', 'important', {
2099+ // var and interpolated vars
2100+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2101+});
17772102
1778− // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
1779− env.highlightedCode = env.highlightedCode.replace('___PHP' + k + '___',
1780− "<span class=\"token php language-php\">" +
1781− Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$') +
1782− "</span>");
1783− }
2103+Prism.languages.insertBefore('scss', 'function', {
2104+ 'placeholder': {
2105+ pattern: /%[-\w]+/,
2106+ alias: 'selector'
2107+ },
2108+ 'statement': {
2109+ pattern: /\B!(?:default|optional)\b/i,
2110+ alias: 'keyword'
2111+ },
2112+ 'boolean': /\b(?:true|false)\b/,
2113+ 'null': /\bnull\b/,
2114+ 'operator': {
2115+ pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2116+ lookbehind: true
2117+ }
2118+});
17842119
1785− env.element.innerHTML = env.highlightedCode;
1786− });
1787−}
1788−;
2120+Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
17892121 Prism.languages.python = {
17902122 'comment': {
17912123 pattern: /(^|[^\\])#.*/,
@@ -1811,7 +2143,7 @@ Prism.languages.python = { · 19 unmodified lines
18112143 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,
18122144 '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/,
18132145 'boolean': /\b(?:True|False|None)\b/,
1814− 'number': /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
2146+ 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
18152147 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
18162148 'punctuation': /[{}[\];(),.:]/
18172149 };
@@ -1821,93 +2153,134 @@ Prism.languages.python = { · 3 unmodified lines
18212153 var javascript = Prism.util.clone(Prism.languages.javascript);
18222154
18232155 Prism.languages.jsx = Prism.languages.extend('markup', javascript);
1824−Prism.languages.jsx.tag.pattern= /<\/?[\w.:-]+\s*(?:\s+(?:[\w\.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+|(?:\{[^}]*\})))?|\{\.{3}\w+\}))*\s*\/?>/i;
2156+Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
18252157
2158+Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
18262159 Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
18272160
18282161 Prism.languages.insertBefore('inside', 'attr-name', {
18292162 'spread': {
1830− pattern: /\{\.{3}\w+\}/,
2163+ pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
18312164 inside: {
1832− 'punctuation': /[{}]|\.{3}/,
2165+ 'punctuation': /\.{3}|[{}.]/,
18332166 'attr-value': /\w+/
18342167 }
18352168 }
18362169 }, Prism.languages.jsx.tag);
18372170
1838−var jsxExpression = Prism.util.clone(Prism.languages.jsx);
1839−
1840−delete jsxExpression.punctuation;
1841−
1842−jsxExpression = Prism.languages.insertBefore('jsx', 'operator', {
1843− 'punctuation': /=(?={)|[{}[\];(),.:]/
1844−}, { jsx: jsxExpression });
1845−
18462171 Prism.languages.insertBefore('inside', 'attr-value',{
18472172 'script': {
1848− // Allow for one level of nesting
1849− pattern: /=(\{(?:\{[^}]*\}|[^}])+\})/i,
1850− inside: jsxExpression,
2173+ // Allow for two levels of nesting
2174+ pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
2175+ inside: {
2176+ 'script-punctuation': {
2177+ pattern: /^=(?={)/,
2178+ alias: 'punctuation'
2179+ },
2180+ rest: Prism.languages.jsx
2181+ },
18512182 'alias': 'language-javascript'
18522183 }
18532184 }, Prism.languages.jsx.tag);
18542185
1855−}(Prism));
2186+// The following will handle plain text inside tags
2187+var stringifyToken = function (token) {
2188+ if (!token) {
2189+ return '';
2190+ }
2191+ if (typeof token === 'string') {
2192+ return token;
2193+ }
2194+ if (typeof token.content === 'string') {
2195+ return token.content;
2196+ }
2197+ return token.content.map(stringifyToken).join('');
2198+};
18562199
1857−(function(Prism) {
1858− Prism.languages.crystal = Prism.languages.extend('ruby', {
1859− keyword: [
1860− /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|select|self|sizeof|struct|super|then|type|typeof|uninitialized|union|unless|until|when|while|with|yield|__DIR__|__END_LINE__|__FILE__|__LINE__)\b/,
1861− {
1862− pattern: /(\.\s*)(?:is_a|responds_to)\?/,
1863− lookbehind: true
1864− }
1865− ],
2200+var walkTokens = function (tokens) {
2201+ var openedTags = [];
2202+ for (var i = 0; i < tokens.length; i++) {
2203+ var token = tokens[i];
2204+ var notTagNorBrace = false;
2205+
2206+ if (typeof token !== 'string') {
2207+ if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
2208+ // We found a tag, now find its kind
2209+
2210+ if (token.content[0].content[0].content === '</') {
2211+ // Closing tag
2212+ if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
2213+ // Pop matching opening tag
2214+ openedTags.pop();
2215+ }
2216+ } else {
2217+ if (token.content[token.content.length - 1].content === '/>') {
2218+ // Autoclosed tag, ignore
2219+ } else {
2220+ // Opening tag
2221+ openedTags.push({
2222+ tagName: stringifyToken(token.content[0].content[1]),
2223+ openedBraces: 0
2224+ });
2225+ }
2226+ }
2227+ } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
18662228
1867− number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[0-9a-fA-F_]*[0-9a-fA-F]|(?:\d(?:[0-9_]*\d)?)(?:\.[0-9_]*\d)?(?:[eE][+-]?[0-9_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/
1868− });
2229+ // Here we might have entered a JSX context inside a tag
2230+ openedTags[openedTags.length - 1].openedBraces++;
18692231
1870− var rest = Prism.util.clone(Prism.languages.crystal);
2232+ } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
18712233
1872− Prism.languages.insertBefore('crystal', 'string', {
1873− attribute: {
1874− pattern: /@\[.+?\]/,
1875− alias: 'attr-name',
1876− inside: {
1877− delimiter: {
1878− pattern: /^@\[|\]$/,
1879− alias: 'tag'
1880− },
1881− rest: rest
1882− }
1883− },
2234+ // Here we might have left a JSX context inside a tag
2235+ openedTags[openedTags.length - 1].openedBraces--;
18842236
1885− expansion: [
1886− {
1887− pattern: /\{\{.+?\}\}/,
1888− inside: {
1889− delimiter: {
1890− pattern: /^\{\{|\}\}$/,
1891− alias: 'tag'
1892− },
1893− rest: rest
2237+ } else {
2238+ notTagNorBrace = true
18942239 }
1895− },
1896− {
1897− pattern: /\{%.+?%\}/,
1898− inside: {
1899− delimiter: {
1900− pattern: /^\{%|%\}$/,
1901− alias: 'tag'
1902− },
1903− rest: rest
2240+ }
2241+ if (notTagNorBrace || typeof token === 'string') {
2242+ if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
2243+ // Here we are inside a tag, and not inside a JSX context.
2244+ // That's plain text: drop any tokens matched.
2245+ var plainText = stringifyToken(token);
2246+
2247+ // And merge text with adjacent text
2248+ if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
2249+ plainText += stringifyToken(tokens[i + 1]);
2250+ tokens.splice(i + 1, 1);
2251+ }
2252+ if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
2253+ plainText = stringifyToken(tokens[i - 1]) + plainText;
2254+ tokens.splice(i - 1, 1);
2255+ i--;
2256+ }
2257+
2258+ tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
19042259 }
19052260 }
1906− ]
1907− });
2261+
2262+ if (token.content && typeof token.content !== 'string') {
2263+ walkTokens(token.content);
2264+ }
2265+ }
2266+};
2267+
2268+Prism.hooks.add('after-tokenize', function (env) {
2269+ if (env.language !== 'jsx' && env.language !== 'tsx') {
2270+ return;
2271+ }
2272+ walkTokens(env.tokens);
2273+});
19082274
19092275 }(Prism));
19102276
2277+Prism.languages.typescript = Prism.languages.extend('javascript', {
2278+ // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2279+ 'keyword': /\b(?: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|var|void|while|with|yield|module|declare|constructor|namespace|abstract|require|type)\b/,
2280+ 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console)\b/,
2281+});
2282+
2283+Prism.languages.ts = Prism.languages.typescript;
19112284 /* TODO
19122285 Add support for Markdown notation inside doc comments
19132286 Add support for nested block comments...
@@ -1932,10 +2305,18 @@ Prism.languages.rust = { · 18 unmodified lines
19322305 greedy: true
19332306 },
19342307 {
1935− pattern: /b?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
2308+ pattern: /b?"(?:\\.|[^\\\r\n"])*"/,
19362309 greedy: true
19372310 }
19382311 ],
2312+ 'char': {
2313+ pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
2314+ alias: 'string'
2315+ },
2316+ 'lifetime-annotation': {
2317+ pattern: /'[^\s>']+/,
2318+ alias: 'symbol'
2319+ },
19392320 'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,
19402321
19412322 'attribute': {
@@ -1955,7 +2336,7 @@ Prism.languages.rust = { · 13 unmodified lines
19552336 },
19562337
19572338 // Hex, oct, bin, dec numbers with visual separators and type suffix
1958− 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,
2339+ 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,
19592340
19602341 // Closure params should not be confused with bitwise OR |
19612342 'closure-params': {
@@ -1966,107 +2347,8 @@ Prism.languages.rust = { · 4 unmodified lines
19662347 }
19672348 },
19682349 'punctuation': /[{}[\];(),:]|\.+|->/,
1969− 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
2350+ 'operator': /[-+*\/%!^]=?|=[=>]?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
19702351 };
1971−Prism.languages.scss = Prism.languages.extend('css', {
1972− 'comment': {
1973− pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1974− lookbehind: true
1975− },
1976− 'atrule': {
1977− pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
1978− inside: {
1979− 'rule': /@[\w-]+/
1980− // See rest below
1981− }
1982− },
1983− // url, compassified
1984− 'url': /(?:[-a-z]+-)*url(?=\()/i,
1985− // CSS selector regex is not appropriate for Sass
1986− // since there can be lot more things (var, @ directive, nesting..)
1987− // a selector must start at the end of a property or after a brace (end of other rules or nesting)
1988− // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
1989− // 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
1990− // can "pass" as a selector- e.g: proper#{$erty})
1991− // this one was hard to do, so please be careful if you edit this one :)
1992− 'selector': {
1993− // Initial look-ahead is used to prevent matching of blank selectors
1994− pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|&|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
1995− inside: {
1996− 'parent': {
1997− pattern: /&/,
1998− alias: 'important'
1999− },
2000− 'placeholder': /%[-\w]+/,
2001− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2002− }
2003− }
2004−});
2005−
2006−Prism.languages.insertBefore('scss', 'atrule', {
2007− 'keyword': [
2008− /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
2009− {
2010− pattern: /( +)(?:from|through)(?= )/,
2011− lookbehind: true
2012− }
2013− ]
2014−});
2015−
2016−Prism.languages.scss.property = {
2017− pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2018− inside: {
2019− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2020− }
2021−};
2022−
2023−Prism.languages.insertBefore('scss', 'important', {
2024− // var and interpolated vars
2025− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2026−});
2027−
2028−Prism.languages.insertBefore('scss', 'function', {
2029− 'placeholder': {
2030− pattern: /%[-\w]+/,
2031− alias: 'selector'
2032− },
2033− 'statement': {
2034− pattern: /\B!(?:default|optional)\b/i,
2035− alias: 'keyword'
2036− },
2037− 'boolean': /\b(?:true|false)\b/,
2038− 'null': /\bnull\b/,
2039− 'operator': {
2040− pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2041− lookbehind: true
2042− }
2043−});
2044−
2045−Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
2046−Prism.languages.sql= {
2047− 'comment': {
2048− pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
2049− lookbehind: true
2050− },
2051− 'string' : {
2052− pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\])*\2/,
2053− greedy: true,
2054− lookbehind: true
2055− },
2056− 'variable': /@[\w.$]+|@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2057− 'function': /\b(?:COUNT|SUM|AVG|MIN|MAX|FIRST|LAST|UCASE|LCASE|MID|LEN|ROUND|NOW|FORMAT)(?=\s*\()/i, // Should we highlight user defined functions too?
2058− '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 VARYING|CHARACTER (?:SET|VARYING)|CHARSET|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COLUMNS|COMMENT|COMMIT|COMMITTED|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|DATA(?:BASES?)?|DATE(?:TIME)?|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITER(?:S)?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE(?: PRECISION)?|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE KEY|ELSE|ENABLE|ENCLOSED BY|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPE(?:D BY)?|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|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTO|INVOKER|ISOLATION LEVEL|JOIN|KEYS?|KILL|LANGUAGE SQL|LAST|LEFT|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MODIFIES SQL DATA|MODIFY|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL(?: CHAR VARYING| CHARACTER(?: VARYING)?| VARCHAR)?|NATURAL|NCHAR(?: VARCHAR)?|NEXT|NO(?: SQL|CHECK|CYCLE)?|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|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READ(?:S SQL DATA|TEXT)?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEATABLE|REPLICATION|REQUIRE|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE MODE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|START(?:ING BY)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED BY|TEXT(?:SIZE)?|THEN|TIMESTAMP|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNPIVOT|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?)\b/i,
2059− 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2060− 'number': /\b-?(?:0x)?\d*\.?[\da-f]+\b/,
2061− 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2062− 'punctuation': /[;[\]()`,.]/
2063−};
2064−Prism.languages.typescript = Prism.languages.extend('javascript', {
2065− // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2066− 'keyword': /\b(?: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|var|void|while|with|yield|false|true|module|declare|constructor|string|Function|any|number|boolean|Array|symbol|namespace|abstract|require|type)\b/
2067−});
2068−
2069−Prism.languages.ts = Prism.languages.typescript;
20702352 Prism.languages.yaml = {
20712353 'scalar': {
20722354 pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
@@ -2105,35 +2387,10 @@ Prism.languages.yaml = { · 32 unmodified lines
21052387 greedy: true
21062388 },
21072389 'number': {
2108− pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+\-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
2390+ pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
21092391 lookbehind: true
21102392 },
21112393 'tag': /![^\s]+/,
21122394 'important': /[&*][\w]+/,
21132395 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
21142396 };
2115−
2116−Prism.languages.dart = Prism.languages.extend('clike', {
2117− 'string': [
2118− {
2119− pattern: /r?("""|''')[\s\S]*?\1/,
2120− greedy: true
2121− },
2122− {
2123− pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
2124− greedy: true
2125− }
2126− ],
2127− 'keyword': [
2128− /\b(?:async|sync|yield)\*/,
2129− /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/
2130− ],
2131− 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
2132−});
2133−
2134−Prism.languages.insertBefore('dart','function',{
2135− 'metadata': {
2136− pattern: /@\w+/,
2137− alias: 'symbol'
2138− }
2139−});