08-27-周三_17-09-29
This commit is contained in:
34
node_modules/prismjs/plugins/show-invisibles/prism-show-invisibles.css
generated
vendored
Normal file
34
node_modules/prismjs/plugins/show-invisibles/prism-show-invisibles.css
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
.token.tab:not(:empty),
|
||||
.token.cr,
|
||||
.token.lf,
|
||||
.token.space {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.token.tab:not(:empty):before,
|
||||
.token.cr:before,
|
||||
.token.lf:before,
|
||||
.token.space:before {
|
||||
color: #808080;
|
||||
opacity: 0.6;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.token.tab:not(:empty):before {
|
||||
content: '\21E5';
|
||||
}
|
||||
|
||||
.token.cr:before {
|
||||
content: '\240D';
|
||||
}
|
||||
|
||||
.token.crlf:before {
|
||||
content: '\240D\240A';
|
||||
}
|
||||
.token.lf:before {
|
||||
content: '\240A';
|
||||
}
|
||||
|
||||
.token.space:before {
|
||||
content: '\00B7';
|
||||
}
|
84
node_modules/prismjs/plugins/show-invisibles/prism-show-invisibles.js
generated
vendored
Normal file
84
node_modules/prismjs/plugins/show-invisibles/prism-show-invisibles.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
(function () {
|
||||
|
||||
if (
|
||||
typeof self !== 'undefined' && !self.Prism ||
|
||||
typeof global !== 'undefined' && !global.Prism
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var invisibles = {
|
||||
'tab': /\t/,
|
||||
'crlf': /\r\n/,
|
||||
'lf': /\n/,
|
||||
'cr': /\r/,
|
||||
'space': / /
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handles the recursive calling of `addInvisibles` for one token.
|
||||
*
|
||||
* @param {Object|Array} tokens The grammar or array which contains the token.
|
||||
* @param {string|number} name The name or index of the token in `tokens`.
|
||||
*/
|
||||
function handleToken(tokens, name) {
|
||||
var value = tokens[name];
|
||||
|
||||
var type = Prism.util.type(value);
|
||||
switch (type) {
|
||||
case 'RegExp':
|
||||
var inside = {};
|
||||
tokens[name] = {
|
||||
pattern: value,
|
||||
inside: inside
|
||||
};
|
||||
addInvisibles(inside);
|
||||
break;
|
||||
|
||||
case 'Array':
|
||||
for (var i = 0, l = value.length; i < l; i++) {
|
||||
handleToken(value, i);
|
||||
}
|
||||
break;
|
||||
|
||||
default: // 'Object'
|
||||
var inside = value.inside || (value.inside = {});
|
||||
addInvisibles(inside);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively adds patterns to match invisible characters to the given grammar (if not added already).
|
||||
*
|
||||
* @param {Object} grammar
|
||||
*/
|
||||
function addInvisibles(grammar) {
|
||||
if (!grammar || grammar['tab']) {
|
||||
return;
|
||||
}
|
||||
|
||||
// assign invisibles here to "mark" the grammar in case of self references
|
||||
for (var name in invisibles) {
|
||||
if (invisibles.hasOwnProperty(name)) {
|
||||
grammar[name] = invisibles[name];
|
||||
}
|
||||
}
|
||||
|
||||
for (var name in grammar) {
|
||||
if (grammar.hasOwnProperty(name) && !invisibles[name]) {
|
||||
if (name === 'rest') {
|
||||
addInvisibles(grammar['rest']);
|
||||
} else {
|
||||
handleToken(grammar, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Prism.hooks.add('before-highlight', function (env) {
|
||||
addInvisibles(env.grammar);
|
||||
});
|
||||
})();
|
1
node_modules/prismjs/plugins/show-invisibles/prism-show-invisibles.min.js
generated
vendored
Normal file
1
node_modules/prismjs/plugins/show-invisibles/prism-show-invisibles.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(){if(("undefined"==typeof self||self.Prism)&&("undefined"==typeof global||global.Prism)){var i={tab:/\t/,crlf:/\r\n/,lf:/\n/,cr:/\r/,space:/ /};Prism.hooks.add("before-highlight",function(r){s(r.grammar)})}function f(r,e){var i=r[e];switch(Prism.util.type(i)){case"RegExp":var a={};r[e]={pattern:i,inside:a},s(a);break;case"Array":for(var n=0,t=i.length;n<t;n++)f(i,n);break;default:s(a=i.inside||(i.inside={}))}}function s(r){if(r&&!r.tab){for(var e in i)i.hasOwnProperty(e)&&(r[e]=i[e]);for(var e in r)r.hasOwnProperty(e)&&!i[e]&&("rest"===e?s(r.rest):f(r,e))}}}();
|
Reference in New Issue
Block a user