|
|
|
@ -17,10 +17,10 @@ var _self = (typeof window !== 'undefined')
|
|
|
|
|
var Prism = (function (_self){
|
|
|
|
|
|
|
|
|
|
// Private helper vars
|
|
|
|
|
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
|
|
|
|
|
var uniqueId = 0;
|
|
|
|
|
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
|
|
|
|
|
var uniqueId = 0;
|
|
|
|
|
|
|
|
|
|
var _ = {
|
|
|
|
|
var _ = {
|
|
|
|
|
manual: _self.Prism && _self.Prism.manual,
|
|
|
|
|
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
|
|
|
|
|
util: {
|
|
|
|
@ -448,20 +448,20 @@ var _ = {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Token: Token
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_self.Prism = _;
|
|
|
|
|
_self.Prism = _;
|
|
|
|
|
|
|
|
|
|
function Token(type, content, alias, matchedStr, greedy) {
|
|
|
|
|
function Token(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.length = (matchedStr || "").length|0;
|
|
|
|
|
this.greedy = !!greedy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Token.stringify = function(o, language) {
|
|
|
|
|
Token.stringify = function(o, language) {
|
|
|
|
|
if (typeof o == 'string') {
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
@ -493,9 +493,9 @@ Token.stringify = function(o, language) {
|
|
|
|
|
}).join(' ');
|
|
|
|
|
|
|
|
|
|
return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!_self.document) {
|
|
|
|
|
if (!_self.document) {
|
|
|
|
|
if (!_self.addEventListener) {
|
|
|
|
|
// in Node.js
|
|
|
|
|
return _;
|
|
|
|
@ -517,12 +517,12 @@ if (!_self.document) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Get current script and highlight
|
|
|
|
|
var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
|
|
|
|
|
var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
|
|
|
|
|
|
|
|
|
|
if (script) {
|
|
|
|
|
if (script) {
|
|
|
|
|
_.filename = script.src;
|
|
|
|
|
|
|
|
|
|
if (!_.manual && !script.hasAttribute('data-manual')) {
|
|
|
|
@ -537,9 +537,9 @@ if (script) {
|
|
|
|
|
document.addEventListener('DOMContentLoaded', _.highlightAll);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _;
|
|
|
|
|
return _;
|
|
|
|
|
|
|
|
|
|
})(_self);
|
|
|
|
|
|
|
|
|
@ -1094,13 +1094,13 @@ Prism.languages.insertBefore('cpp', 'string', {
|
|
|
|
|
(function(Prism) {
|
|
|
|
|
|
|
|
|
|
// Ignore comments starting with { to privilege string interpolation highlighting
|
|
|
|
|
var comment = /#(?!\{).+/,
|
|
|
|
|
var comment = /#(?!\{).+/,
|
|
|
|
|
interpolation = {
|
|
|
|
|
pattern: /#\{[^}]+\}/,
|
|
|
|
|
alias: 'variable'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Prism.languages.coffeescript = Prism.languages.extend('javascript', {
|
|
|
|
|
Prism.languages.coffeescript = Prism.languages.extend('javascript', {
|
|
|
|
|
'comment': comment,
|
|
|
|
|
'string': [
|
|
|
|
|
|
|
|
|
@ -1124,9 +1124,9 @@ Prism.languages.coffeescript = Prism.languages.extend('javascript', {
|
|
|
|
|
pattern: /@(?!\d)\w+/,
|
|
|
|
|
alias: 'variable'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Prism.languages.insertBefore('coffeescript', 'comment', {
|
|
|
|
|
Prism.languages.insertBefore('coffeescript', 'comment', {
|
|
|
|
|
'multiline-comment': {
|
|
|
|
|
pattern: /###[\s\S]+?###/,
|
|
|
|
|
alias: 'comment'
|
|
|
|
@ -1141,9 +1141,9 @@ Prism.languages.insertBefore('coffeescript', 'comment', {
|
|
|
|
|
'interpolation': interpolation
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Prism.languages.insertBefore('coffeescript', 'string', {
|
|
|
|
|
Prism.languages.insertBefore('coffeescript', 'string', {
|
|
|
|
|
'inline-javascript': {
|
|
|
|
|
pattern: /`(?:\\[\s\S]|[^\\`])*`/,
|
|
|
|
|
inside: {
|
|
|
|
@ -1172,16 +1172,16 @@ Prism.languages.insertBefore('coffeescript', 'string', {
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Prism.languages.insertBefore('coffeescript', 'keyword', {
|
|
|
|
|
Prism.languages.insertBefore('coffeescript', 'keyword', {
|
|
|
|
|
// Object property
|
|
|
|
|
'property': /(?!\d)\w+(?=\s*:(?!:))/
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
delete Prism.languages.coffeescript['template-string'];
|
|
|
|
|
delete Prism.languages.coffeescript['template-string'];
|
|
|
|
|
|
|
|
|
|
Prism.languages.coffee = Prism.languages.coffeescript;
|
|
|
|
|
Prism.languages.coffee = Prism.languages.coffeescript;
|
|
|
|
|
}(Prism));
|
|
|
|
|
/**
|
|
|
|
|
* Original by Samuel Flores
|
|
|
|
@ -2600,16 +2600,16 @@ Prism.languages.python['string-interpolation'].inside['interpolation'].inside.re
|
|
|
|
|
Prism.languages.py = Prism.languages.python;
|
|
|
|
|
(function(Prism) {
|
|
|
|
|
|
|
|
|
|
var javascript = Prism.util.clone(Prism.languages.javascript);
|
|
|
|
|
var javascript = Prism.util.clone(Prism.languages.javascript);
|
|
|
|
|
|
|
|
|
|
Prism.languages.jsx = Prism.languages.extend('markup', javascript);
|
|
|
|
|
Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
|
|
|
|
|
Prism.languages.jsx = Prism.languages.extend('markup', javascript);
|
|
|
|
|
Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
|
|
|
|
|
|
|
|
|
|
Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
|
|
|
|
|
Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
|
|
|
|
|
Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
|
|
|
|
|
Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
|
|
|
|
|
Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
|
|
|
|
|
Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
|
|
|
|
|
|
|
|
|
|
Prism.languages.insertBefore('inside', 'attr-name', {
|
|
|
|
|
Prism.languages.insertBefore('inside', 'attr-name', {
|
|
|
|
|
'spread': {
|
|
|
|
|
pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
|
|
|
|
|
inside: {
|
|
|
|
@ -2617,9 +2617,9 @@ Prism.languages.insertBefore('inside', 'attr-name', {
|
|
|
|
|
'attr-value': /\w+/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, Prism.languages.jsx.tag);
|
|
|
|
|
}, Prism.languages.jsx.tag);
|
|
|
|
|
|
|
|
|
|
Prism.languages.insertBefore('inside', 'attr-value',{
|
|
|
|
|
Prism.languages.insertBefore('inside', 'attr-value',{
|
|
|
|
|
'script': {
|
|
|
|
|
// Allow for two levels of nesting
|
|
|
|
|
pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
|
|
|
|
@ -2632,10 +2632,10 @@ Prism.languages.insertBefore('inside', 'attr-value',{
|
|
|
|
|
},
|
|
|
|
|
'alias': 'language-javascript'
|
|
|
|
|
}
|
|
|
|
|
}, Prism.languages.jsx.tag);
|
|
|
|
|
}, Prism.languages.jsx.tag);
|
|
|
|
|
|
|
|
|
|
// The following will handle plain text inside tags
|
|
|
|
|
var stringifyToken = function (token) {
|
|
|
|
|
var stringifyToken = function (token) {
|
|
|
|
|
if (!token) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
@ -2646,9 +2646,9 @@ var stringifyToken = function (token) {
|
|
|
|
|
return token.content;
|
|
|
|
|
}
|
|
|
|
|
return token.content.map(stringifyToken).join('');
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var walkTokens = function (tokens) {
|
|
|
|
|
var walkTokens = function (tokens) {
|
|
|
|
|
var openedTags = [];
|
|
|
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
|
|
|
var token = tokens[i];
|
|
|
|
@ -2714,14 +2714,14 @@ var walkTokens = function (tokens) {
|
|
|
|
|
walkTokens(token.content);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Prism.hooks.add('after-tokenize', function (env) {
|
|
|
|
|
Prism.hooks.add('after-tokenize', function (env) {
|
|
|
|
|
if (env.language !== 'jsx' && env.language !== 'tsx') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
walkTokens(env.tokens);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}(Prism));
|
|
|
|
|
|
|
|
|
|