Locally add prismjs
This commit is contained in:
parent
35af792c6a
commit
6aa044cf9b
701 changed files with 35787 additions and 0 deletions
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;
|
||||
}
|
90
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.js
generated
vendored
Normal file
90
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.js
generated
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
(function () {
|
||||
|
||||
if (typeof Prism === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var LANGUAGE_REGEX = /^diff-([\w-]+)/i;
|
||||
var HTML_TAG = /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/g;
|
||||
//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 warningLogged = false;
|
||||
|
||||
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) {
|
||||
if (!warningLogged && !Prism.languages.diff && !Prism.plugins.autoloader) {
|
||||
warningLogged = true;
|
||||
console.warn("Prism's Diff Highlight plugin requires the Diff language definition (prism-diff.js)." +
|
||||
"Make sure the language definition is loaded or use Prism's Autoloader plugin.");
|
||||
}
|
||||
|
||||
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; var 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];
|
||||
}
|
||||
|
||||
var PREFIXES = Prism.languages.diff && Prism.languages.diff.PREFIXES;
|
||||
|
||||
// one of the diff tokens without any nested tokens
|
||||
if (PREFIXES && 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 = []; var 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.css
generated
vendored
Normal file
1
node_modules/prismjs/plugins/diff-highlight/prism-diff-highlight.min.css
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
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}
|
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){var e=/^diff-([\w-]+)/i,i=/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/g,a=RegExp("(?:__|[^\r\n<])*(?:\r\n?|\n|(?:__|[^\r\n<])(?![^\r\n]))".replace(/__/g,(function(){return i.source})),"gi"),s=!1;Prism.hooks.add("before-sanity-check",(function(i){var a=i.language;e.test(a)&&!i.grammar&&(i.grammar=Prism.languages[a]=Prism.languages.diff)})),Prism.hooks.add("before-tokenize",(function(i){s||Prism.languages.diff||Prism.plugins.autoloader||(s=!0,console.warn("Prism's Diff Highlight plugin requires the Diff language definition (prism-diff.js).Make sure the language definition is loaded or use Prism's Autoloader plugin."));var a=i.language;e.test(a)&&!Prism.languages[a]&&(Prism.languages[a]=Prism.languages.diff)})),Prism.hooks.add("wrap",(function(s){var r,n;if("diff"!==s.language){var g=e.exec(s.language);if(!g)return;r=g[1],n=Prism.languages[r]}var f=Prism.languages.diff&&Prism.languages.diff.PREFIXES;if(f&&s.type in f){var u,l=s.content.replace(i,"").replace(/</g,"<").replace(/&/g,"&"),t=l.replace(/(^|[\r\n])./g,"$1");u=n?Prism.highlight(t,n,r):Prism.util.encode(t);var o,m=new Prism.Token("prefix",f[s.type],[/\w+/.exec(s.type)[0]]),d=Prism.Token.stringify(m,s.language),c=[];for(a.lastIndex=0;o=a.exec(u);)c.push(d+o[0]);/(?:^|[\r\n]).$/.test(l)&&c.push(d),s.content=c.join(""),n&&s.classes.push("language-"+r)}}))}}();
|
Loading…
Add table
Add a link
Reference in a new issue