08-27-周三_17-09-29
This commit is contained in:
13
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.css
generated
vendored
Normal file
13
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.css
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
pre.diff-highlight > code .token.deleted:not(.prefix),
|
||||
pre > code.diff-highlight .token.deleted:not(.prefix) {
|
||||
background-color: rgba(255, 0, 0, .1);
|
||||
color: inherit;
|
||||
display: block;
|
||||
}
|
||||
|
||||
pre.diff-highlight > code .token.inserted:not(.prefix),
|
||||
pre > code.diff-highlight .token.inserted:not(.prefix) {
|
||||
background-color: rgba(0, 255, 128, .1);
|
||||
color: inherit;
|
||||
display: block;
|
||||
}
|
83
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.js
generated
vendored
Normal file
83
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
(function () {
|
||||
|
||||
if (typeof Prism === 'undefined' || !Prism.languages['diff']) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var LANGUAGE_REGEX = /diff-([\w-]+)/i;
|
||||
var HTML_TAG = /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/gi;
|
||||
//this will match a line plus the line break while ignoring the line breaks HTML tags may contain.
|
||||
var HTML_LINE = RegExp(/(?:__|[^\r\n<])*(?:\r\n?|\n|(?:__|[^\r\n<])(?![^\r\n]))/.source.replace(/__/g, function () { return HTML_TAG.source; }), 'gi');
|
||||
|
||||
var PREFIXES = Prism.languages.diff.PREFIXES;
|
||||
|
||||
|
||||
Prism.hooks.add('before-sanity-check', function (env) {
|
||||
var lang = env.language;
|
||||
if (LANGUAGE_REGEX.test(lang) && !env.grammar) {
|
||||
env.grammar = Prism.languages[lang] = Prism.languages['diff'];
|
||||
}
|
||||
});
|
||||
Prism.hooks.add('before-tokenize', function (env) {
|
||||
var lang = env.language;
|
||||
if (LANGUAGE_REGEX.test(lang) && !Prism.languages[lang]) {
|
||||
Prism.languages[lang] = Prism.languages['diff'];
|
||||
}
|
||||
});
|
||||
|
||||
Prism.hooks.add('wrap', function (env) {
|
||||
var diffLanguage, diffGrammar;
|
||||
|
||||
if (env.language !== 'diff') {
|
||||
var langMatch = LANGUAGE_REGEX.exec(env.language);
|
||||
if (!langMatch) {
|
||||
return; // not a language specific diff
|
||||
}
|
||||
|
||||
diffLanguage = langMatch[1];
|
||||
diffGrammar = Prism.languages[diffLanguage];
|
||||
}
|
||||
|
||||
// one of the diff tokens without any nested tokens
|
||||
if (env.type in PREFIXES) {
|
||||
/** @type {string} */
|
||||
var content = env.content.replace(HTML_TAG, ''); // remove all HTML tags
|
||||
|
||||
/** @type {string} */
|
||||
var decoded = content.replace(/</g, '<').replace(/&/g, '&');
|
||||
|
||||
// remove any one-character prefix
|
||||
var code = decoded.replace(/(^|[\r\n])./g, '$1');
|
||||
|
||||
// highlight, if possible
|
||||
var highlighted;
|
||||
if (diffGrammar) {
|
||||
highlighted = Prism.highlight(code, diffGrammar, diffLanguage);
|
||||
} else {
|
||||
highlighted = Prism.util.encode(code);
|
||||
}
|
||||
|
||||
// get the HTML source of the prefix token
|
||||
var prefixToken = new Prism.Token('prefix', PREFIXES[env.type], [/\w+/.exec(env.type)[0]]);
|
||||
var prefix = Prism.Token.stringify(prefixToken, env.language);
|
||||
|
||||
// add prefix
|
||||
var lines = [], m;
|
||||
HTML_LINE.lastIndex = 0;
|
||||
while (m = HTML_LINE.exec(highlighted)) {
|
||||
lines.push(prefix + m[0]);
|
||||
}
|
||||
if (/(?:^|[\r\n]).$/.test(decoded)) {
|
||||
// because both "+a\n+" and "+a\n" will map to "a\n" after the line prefixes are removed
|
||||
lines.push(prefix);
|
||||
}
|
||||
env.content = lines.join('');
|
||||
|
||||
if (diffGrammar) {
|
||||
env.classes.push('language-' + diffLanguage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
1
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.min.js
generated
vendored
Normal file
1
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(){if("undefined"!=typeof Prism&&Prism.languages.diff){var o=/diff-([\w-]+)/i,m=/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/gi,c=RegExp("(?:__|[^\r\n<])*(?:\r\n?|\n|(?:__|[^\r\n<])(?![^\r\n]))".replace(/__/g,function(){return m.source}),"gi"),d=Prism.languages.diff.PREFIXES;Prism.hooks.add("before-sanity-check",function(e){var a=e.language;o.test(a)&&!e.grammar&&(e.grammar=Prism.languages[a]=Prism.languages.diff)}),Prism.hooks.add("before-tokenize",function(e){var a=e.language;o.test(a)&&!Prism.languages[a]&&(Prism.languages[a]=Prism.languages.diff)}),Prism.hooks.add("wrap",function(e){var a,s;if("diff"!==e.language){var n=o.exec(e.language);if(!n)return;a=n[1],s=Prism.languages[a]}if(e.type in d){var r,i=e.content.replace(m,"").replace(/</g,"<").replace(/&/g,"&"),g=i.replace(/(^|[\r\n])./g,"$1");r=s?Prism.highlight(g,s,a):Prism.util.encode(g);var f,t=new Prism.Token("prefix",d[e.type],[/\w+/.exec(e.type)[0]]),u=Prism.Token.stringify(t,e.language),l=[];for(c.lastIndex=0;f=c.exec(r);)l.push(u+f[0]);/(?:^|[\r\n]).$/.test(i)&&l.push(u),e.content=l.join(""),s&&e.classes.push("language-"+a)}})}}();
|
Reference in New Issue
Block a user