|
|
@@ -1,4 +1,4 @@
|
|
|
-/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+elixir+go+lua+nginx+php+python+rust */
|
|
|
+/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+elixir+go+lua+nginx+php+python+rust+typescript */
|
|
|
var _self = (typeof window !== 'undefined')
|
|
|
? window // if in browser
|
|
|
: (
|
|
|
@@ -328,6 +328,9 @@ var _ = _self.Prism = {
|
|
|
delNum = 3;
|
|
|
|
|
|
if (to <= len) {
|
|
|
+ if (strarr[i + 1].greedy) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
delNum = 2;
|
|
|
combStr = combStr.slice(0, len);
|
|
|
}
|
|
|
@@ -354,7 +357,7 @@ var _ = _self.Prism = {
|
|
|
args.push(before);
|
|
|
}
|
|
|
|
|
|
- var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match);
|
|
|
+ var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
|
|
|
|
|
|
args.push(wrapped);
|
|
|
|
|
|
@@ -395,12 +398,13 @@ var _ = _self.Prism = {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-var Token = _.Token = function(type, content, alias, matchedStr) {
|
|
|
+var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
|
|
|
this.type = type;
|
|
|
this.content = content;
|
|
|
this.alias = alias;
|
|
|
// Copy of the full string this token was created from
|
|
|
this.matchedStr = matchedStr || null;
|
|
|
+ this.greedy = !!greedy;
|
|
|
};
|
|
|
|
|
|
Token.stringify = function(o, language, parent) {
|
|
|
@@ -633,6 +637,7 @@ Prism.languages.insertBefore('javascript', 'keyword', {
|
|
|
Prism.languages.insertBefore('javascript', 'class-name', {
|
|
|
'template-string': {
|
|
|
pattern: /`(?:\\\\|\\?[^\\])*?`/,
|
|
|
+ greedy: true,
|
|
|
inside: {
|
|
|
'interpolation': {
|
|
|
pattern: /\$\{[^}]+\}/,
|
|
|
@@ -1218,3 +1223,7 @@ Prism.languages.rust = {
|
|
|
'punctuation': /[{}[\];(),:]|\.+|->/,
|
|
|
'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
|
|
|
};
|
|
|
+Prism.languages.typescript = Prism.languages.extend('javascript', {
|
|
|
+ '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/
|
|
|
+});
|
|
|
+
|