History

Update Prism.js

Thibaut Courouble committed 9 years ago

Commit 01f9d511 parent 2db57fd1 file · +141 −48Browse files

Unified · Split

assets/javascripts/vendor/prism.js+141−48
@@ -20,6 +20,7 @@ var lang = /\blang(?:uage)?-(\w+)\b/i; · 19 unmodified lines
2020 var uniqueId = 0;
2121
2222 var _ = _self.Prism = {
23+ manual: _self.Prism && _self.Prism.manual,
2324 util: {
2425 encode: function (tokens) {
2526 if (tokens instanceof Token) {
@@ -204,6 +205,9 @@ var _ = _self.Prism = { · 178 unmodified lines
204205 _.hooks.run('before-sanity-check', env);
205206
206207 if (!env.code || !env.grammar) {
208+ if (env.code) {
209+ env.element.textContent = env.code;
210+ }
207211 _.hooks.run('complete', env);
208212 return;
209213 }
@@ -290,7 +294,7 @@ var _ = _self.Prism = { · 80 unmodified lines
290294 pattern = pattern.pattern || pattern;
291295
292296 // Don’t cache length as it changes during the loop
293− for (var i=0, pos = 0; i<strarr.length; pos += (strarr[i].matchedStr || strarr[i]).length, ++i) {
297+ for (var i=0, pos = 0; i<strarr.length; pos += strarr[i].length, ++i) {
294298
295299 var str = strarr[i];
296300
@@ -322,7 +326,7 @@ var _ = _self.Prism = { · 25 unmodified lines
322326 p = pos;
323327
324328 for (var len = strarr.length; k < len && p < to; ++k) {
325− p += (strarr[k].matchedStr || strarr[k]).length;
329+ p += strarr[k].length;
326330 // Move the index i to the element in strarr that is closest to from
327331 if (from >= p) {
328332 ++i;
@@ -410,7 +414,7 @@ var Token = _.Token = function(type, content, alias, matchedStr, greedy) { · 81 unmodified lines
410414 this.content = content;
411415 this.alias = alias;
412416 // Copy of the full string this token was created from
413− this.matchedStr = matchedStr || null;
417+ this.length = (matchedStr || "").length|0;
414418 this.greedy = !!greedy;
415419 };
416420
@@ -446,11 +450,9 @@ Token.stringify = function(o, language, parent) { · 29 unmodified lines
446450
447451 _.hooks.run('wrap', env);
448452
449− var attributes = '';
450−
451− for (var name in env.attributes) {
452− attributes += (attributes ? ' ' : '') + name + '="' + (env.attributes[name] || '') + '"';
453− }
453+ var attributes = Object.keys(env.attributes).map(function(name) {
454+ return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
455+ }).join(' ');
454456
455457 return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
456458
@@ -483,7 +485,7 @@ Token.stringify = function(o, language, parent) { · 26 unmodified lines
483485 // if (script) {
484486 // _.filename = script.src;
485487
486−// if (document.addEventListener && !script.hasAttribute('data-manual')) {
488+// if (document.addEventListener && !_.manual && !script.hasAttribute('data-manual')) {
487489 // if(document.readyState !== "loading") {
488490 // if (window.requestAnimationFrame) {
489491 // window.requestAnimationFrame(_.highlightAll);
@@ -513,7 +515,7 @@ if (typeof global !== 'undefined') { · 23 unmodified lines
513515 Prism.languages.markup = {
514516 'comment': /<!--[\w\W]*?-->/,
515517 'prolog': /<\?[\w\W]+?\?>/,
516− 'doctype': /<!DOCTYPE[\w\W]+?>/,
518+ 'doctype': /<!DOCTYPE[\w\W]+?>/i,
517519 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
518520 'tag': {
519521 pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
@@ -568,7 +570,10 @@ Prism.languages.css = { · 48 unmodified lines
568570 },
569571 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
570572 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
571− 'string': /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
573+ 'string': {
574+ pattern: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
575+ greedy: true
576+ },
572577 'property': /(\b|\B)[\w-]+(?=\s*:)/i,
573578 'important': /\B!important\b/i,
574579 'function': /[-a-z0-9]+(?=\()/i,
@@ -745,7 +750,7 @@ Prism.languages.coffeescript = Prism.languages.extend('javascript', { · 170 unmodified lines
745750 // Strings are multiline
746751 {
747752 pattern: /'(?:\\?[^\\])*?'/,
748− greedy: true,
753+ greedy: true
749754 },
750755
751756 {
@@ -847,12 +852,14 @@ delete Prism.languages.coffeescript['template-string']; · 95 unmodified lines
847852 'regex': [
848853 {
849854 pattern: /%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,
855+ greedy: true,
850856 inside: {
851857 'interpolation': interpolation
852858 }
853859 },
854860 {
855861 pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
862+ greedy: true,
856863 inside: {
857864 'interpolation': interpolation
858865 }
@@ -860,25 +867,29 @@ delete Prism.languages.coffeescript['template-string']; · 1 unmodified line
860867 {
861868 // Here we need to specifically allow interpolation
862869 pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
870+ greedy: true,
863871 inside: {
864872 'interpolation': interpolation
865873 }
866874 },
867875 {
868876 pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
877+ greedy: true,
869878 inside: {
870879 'interpolation': interpolation
871880 }
872881 },
873882 {
874883 pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
884+ greedy: true,
875885 inside: {
876886 'interpolation': interpolation
877887 }
878888 },
879889 {
880− pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
881− lookbehind: true
890+ pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
891+ lookbehind: true,
892+ greedy: true
882893 }
883894 ],
884895 'variable': /[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,
@@ -886,19 +897,21 @@ delete Prism.languages.coffeescript['template-string']; · 1 unmodified line
886897 });
887898
888899 Prism.languages.insertBefore('ruby', 'number', {
889− 'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
900+ 'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
890901 'constant': /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/
891902 });
892903
893904 Prism.languages.ruby.string = [
894905 {
895906 pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
907+ greedy: true,
896908 inside: {
897909 'interpolation': interpolation
898910 }
899911 },
900912 {
901913 pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
914+ greedy: true,
902915 inside: {
903916 'interpolation': interpolation
904917 }
@@ -906,24 +919,28 @@ delete Prism.languages.coffeescript['template-string']; · 1 unmodified line
906919 {
907920 // Here we need to specifically allow interpolation
908921 pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
922+ greedy: true,
909923 inside: {
910924 'interpolation': interpolation
911925 }
912926 },
913927 {
914928 pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
929+ greedy: true,
915930 inside: {
916931 'interpolation': interpolation
917932 }
918933 },
919934 {
920935 pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
936+ greedy: true,
921937 inside: {
922938 'interpolation': interpolation
923939 }
924940 },
925941 {
926942 pattern: /("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,
943+ greedy: true,
927944 inside: {
928945 'interpolation': interpolation
929946 }
@@ -944,12 +961,14 @@ Prism.languages.elixir = { · 14 unmodified lines
944961 {
945962 // ~s"""foo""", ~s'''foo''', ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo}, ~s<foo>
946963 pattern: /~[cCsSwW](?:("""|'''|[\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|#\{[^}]+\}|[^}])+\}|<(?:\\>|[^>])+>)[csa]?/,
964+ greedy: true,
947965 inside: {
948966 // See interpolation below
949967 }
950968 },
951969 {
952970 pattern: /("""|''')[\s\S]*?\1/,
971+ greedy: true,
953972 inside: {
954973 // See interpolation below
955974 }
@@ -957,6 +976,7 @@ Prism.languages.elixir = { · 1 unmodified line
957976 {
958977 // Multi-line strings are allowed
959978 pattern: /("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/,
979+ greedy: true,
960980 inside: {
961981 // See interpolation below
962982 }
@@ -1027,18 +1047,21 @@ Prism.languages.go = Prism.languages.extend('clike', { · 64 unmodified lines
10271047 'boolean': /\b(_|iota|nil|true|false)\b/,
10281048 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
10291049 'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
1030− 'string': /("|'|`)(\\?.|\r|\n)*?\1/
1050+ 'string': {
1051+ pattern: /("|'|`)(\\?.|\r|\n)*?\1/,
1052+ greedy: true
1053+ }
10311054 });
10321055 delete Prism.languages.go['class-name'];
10331056
10341057 Prism.languages.json = {
1035− 'property': /".*?"(?=\s*:)/ig,
1036− 'string': /"(?!:)(\\?[^"])*?"(?!:)/g,
1037− 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,
1038− 'punctuation': /[{}[\]);,]/g,
1039− 'operator': /:/g,
1040− 'boolean': /\b(true|false)\b/gi,
1041− 'null': /\bnull\b/gi,
1058+ 'property': /"(?:\\.|[^\\"])*"(?=\s*:)/ig,
1059+ 'string': /"(?!:)(?:\\.|[^\\"])*"(?!:)/g,
1060+ 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/g,
1061+ 'punctuation': /[{}[\]);,]/g,
1062+ 'operator': /:/g,
1063+ 'boolean': /\b(true|false)\b/gi,
1064+ 'null': /\bnull\b/gi
10421065 };
10431066
10441067 Prism.languages.jsonp = Prism.languages.json;
@@ -1151,92 +1174,143 @@ Prism.languages.perl = { · 106 unmodified lines
11511174 // TODO Could be nice to handle Heredoc too.
11521175 'string': [
11531176 // q/.../
1154− /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
1177+ {
1178+ pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
1179+ greedy: true
1180+ },
11551181
11561182 // q a...a
1157− /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\1/,
1183+ {
1184+ pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\1/,
1185+ greedy: true
1186+ },
11581187
11591188 // q(...)
1160− /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
1189+ {
1190+ pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
1191+ greedy: true
1192+ },
11611193
11621194 // q{...}
1163− /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
1195+ {
1196+ pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
1197+ greedy: true
1198+ },
11641199
11651200 // q[...]
1166− /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
1201+ {
1202+ pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
1203+ greedy: true
1204+ },
11671205
11681206 // q<...>
1169− /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
1207+ {
1208+ pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
1209+ greedy: true
1210+ },
11701211
11711212 // "...", `...`
1172− /("|`)(?:[^\\]|\\[\s\S])*?\1/,
1213+ {
1214+ pattern: /("|`)(?:[^\\]|\\[\s\S])*?\1/,
1215+ greedy: true
1216+ },
11731217
11741218 // '...'
11751219 // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
1176− /'(?:[^'\\\r\n]|\\.)*'/
1220+ {
1221+ pattern: /'(?:[^'\\\r\n]|\\.)*'/,
1222+ greedy: true
1223+ }
11771224 ],
11781225 'regex': [
11791226 // m/.../
1180− /\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[msixpodualngc]*/,
1227+ {
1228+ pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[msixpodualngc]*/,
1229+ greedy: true
1230+ },
11811231
11821232 // m a...a
1183− /\b(?:m|qr)\s+([a-zA-Z0-9])(?:[^\\]|\\.)*?\1[msixpodualngc]*/,
1233+ {
1234+ pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:[^\\]|\\.)*?\1[msixpodualngc]*/,
1235+ greedy: true
1236+ },
11841237
11851238 // m(...)
1186− /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
1239+ {
1240+ pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
1241+ greedy: true
1242+ },
11871243
11881244 // m{...}
1189− /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
1245+ {
1246+ pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
1247+ greedy: true
1248+ },
11901249
11911250 // m[...]
1192− /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
1251+ {
1252+ pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
1253+ greedy: true
1254+ },
11931255
11941256 // m<...>
1195− /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
1257+ {
1258+ pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
1259+ greedy: true
1260+ },
11961261
11971262 // The lookbehinds prevent -s from breaking
11981263 // FIXME We don't handle change of separator like s(...)[...]
11991264 // s/.../.../
12001265 {
12011266 pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
1202− lookbehind: true
1267+ lookbehind: true,
1268+ greedy: true
12031269 },
12041270
12051271 // s a...a...a
12061272 {
12071273 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
1208− lookbehind: true
1274+ lookbehind: true,
1275+ greedy: true
12091276 },
12101277
12111278 // s(...)(...)
12121279 {
12131280 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
1214− lookbehind: true
1281+ lookbehind: true,
1282+ greedy: true
12151283 },
12161284
12171285 // s{...}{...}
12181286 {
12191287 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
1220− lookbehind: true
1288+ lookbehind: true,
1289+ greedy: true
12211290 },
12221291
12231292 // s[...][...]
12241293 {
12251294 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
1226− lookbehind: true
1295+ lookbehind: true,
1296+ greedy: true
12271297 },
12281298
12291299 // s<...><...>
12301300 {
12311301 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
1232− lookbehind: true
1302+ lookbehind: true,
1303+ greedy: true
12331304 },
12341305
12351306 // /.../
12361307 // The look-ahead tries to prevent two divisions on
12371308 // the same line from being highlighted as regex.
12381309 // This does not support multi-line regex.
1239− /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/
1310+ {
1311+ pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,
1312+ greedy: true
1313+ }
12401314 ],
12411315
12421316 // FIXME Not sure about the handling of ::, ', and #
@@ -1342,6 +1416,7 @@ if (Prism.languages.markup) { · 99 unmodified lines
13421416
13431417 env.tokenStack = [];
13441418
1419+ env.backupCode = env.code;
13451420 env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/ig, function(match) {
13461421 env.tokenStack.push(match);
13471422
@@ -1349,6 +1424,14 @@ if (Prism.languages.markup) { · 1 unmodified line
13491424 });
13501425 });
13511426
1427+ // Restore env.code for other plugins (e.g. line-numbers)
1428+ Prism.hooks.add('before-insert', function(env) {
1429+ if (env.language === 'php') {
1430+ env.code = env.backupCode;
1431+ delete env.backupCode;
1432+ }
1433+ });
1434+
13521435 // Re-insert the tokens after highlighting
13531436 Prism.hooks.add('after-highlight', function(env) {
13541437 if (env.language !== 'php') {
@@ -1411,7 +1494,7 @@ Prism.languages.python= { · 56 unmodified lines
14111494 (function(Prism) {
14121495 Prism.languages.crystal = Prism.languages.extend('ruby', {
14131496 keyword: [
1414− /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|ifdef|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|self|sizeof|struct|super|then|type|typeof|union|unless|until|when|while|with|yield|__DIR__|__FILE__|__LINE__)\b/,
1497+ /\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/,
14151498 {
14161499 pattern: /(\.\s*)(?:is_a|responds_to)\?/,
14171500 lookbehind: true
@@ -1481,13 +1564,20 @@ Prism.languages.rust = { · 63 unmodified lines
14811564 }
14821565 ],
14831566 'string': [
1484− /b?r(#*)"(?:\\?.)*?"\1/,
1485− /b?("|')(?:\\?.)*?\1/
1567+ {
1568+ pattern: /b?r(#*)"(?:\\?.)*?"\1/,
1569+ greedy: true
1570+ },
1571+ {
1572+ pattern: /b?("|')(?:\\?.)*?\1/,
1573+ greedy: true
1574+ }
14861575 ],
14871576 '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/,
14881577
14891578 'attribute': {
14901579 pattern: /#!?\[.+?\]/,
1580+ greedy: true,
14911581 alias: 'attr-name'
14921582 },
14931583
@@ -1597,6 +1687,7 @@ Prism.languages.sql= { · 103 unmodified lines
15971687 },
15981688 'string' : {
15991689 pattern: /(^|[^@\\])("|')(?:\\?[\s\S])*?\2/,
1690+ greedy: true,
16001691 lookbehind: true
16011692 },
16021693 'variable': /@[\w.$]+|@("|'|`)(?:\\?[\s\S])+?\1/,
@@ -1608,6 +1699,8 @@ Prism.languages.sql= { · 5 unmodified lines
16081699 'punctuation': /[;[\]()`,.]/
16091700 };
16101701 Prism.languages.typescript = Prism.languages.extend('javascript', {
1611− 'keyword': /\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield|module|declare|constructor|string|Function|any|number|boolean|Array|enum)\b/
1702+ // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
1703+ '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|enum|symbol|namespace|abstract|require|type)\b/
16121704 });
16131705
1706+Prism.languages.ts = Prism.languages.typescript;