Commit 7a2d153b9be3edd7b54be37cdf47b06276fa2861

RunDevelopment 2018-11-12T20:14:19

Revert "Show invisibles inside tokens" This reverts commit 2d622f17e4f6d746e8f4fa211c7f6b7ccb3f27b4.

diff --git a/plugins/show-invisibles/prism-show-invisibles.css b/plugins/show-invisibles/prism-show-invisibles.css
index 16583b3..c57be58 100644
--- a/plugins/show-invisibles/prism-show-invisibles.css
+++ b/plugins/show-invisibles/prism-show-invisibles.css
@@ -9,8 +9,8 @@
 .token.cr:before,
 .token.lf:before,
 .token.space:before {
-	color: #888;
-	opacity: 0.6;
+	color: inherit;
+	opacity: 0.4;
 	position: absolute;
 }
 
diff --git a/plugins/show-invisibles/prism-show-invisibles.js b/plugins/show-invisibles/prism-show-invisibles.js
index 3b67c77..f3d120a 100644
--- a/plugins/show-invisibles/prism-show-invisibles.js
+++ b/plugins/show-invisibles/prism-show-invisibles.js
@@ -1,80 +1,21 @@
-(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);
-	});
+(function(){
+
+if (
+	typeof self !== 'undefined' && !self.Prism ||
+	typeof global !== 'undefined' && !global.Prism
+) {
+	return;
+}
+
+Prism.hooks.add('before-highlight', function(env) {
+	var tokens = env.grammar;
+
+	if (!tokens) return;
+
+	tokens.tab = /\t/g;
+	tokens.crlf = /\r\n/g;
+	tokens.lf = /\n/g;
+	tokens.cr = /\r/g;
+	tokens.space = / /g;
+});
 })();
diff --git a/plugins/show-invisibles/prism-show-invisibles.min.js b/plugins/show-invisibles/prism-show-invisibles.min.js
index 32de8f2..9df7258 100644
--- a/plugins/show-invisibles/prism-show-invisibles.min.js
+++ b/plugins/show-invisibles/prism-show-invisibles.min.js
@@ -1 +1 @@
-!function(){function r(a,i){var n=a[i],t=Prism.util.type(n);switch(t){case"RegExp":var f={};a[i]={pattern:n,inside:f},e(f);break;case"Array":for(var s=0,o=n.length;o>s;s++)r(n,s);break;default:var f=n.inside||(n.inside={});e(f)}}function e(i){if(i&&!i.tab){for(var n in a)a.hasOwnProperty(n)&&(i[n]=a[n]);for(var n in i)i.hasOwnProperty(n)&&!a[n]&&("rest"===n?e(i.rest):r(i,n))}}if(("undefined"==typeof self||self.Prism)&&("undefined"==typeof global||global.Prism)){var a={tab:/\t/,crlf:/\r\n/,lf:/\n/,cr:/\r/,space:/ /};Prism.hooks.add("before-highlight",function(r){e(r.grammar)})}}();
\ No newline at end of file
+!function(){"undefined"!=typeof self&&!self.Prism||"undefined"!=typeof global&&!global.Prism||Prism.hooks.add("before-highlight",function(e){var f=e.grammar;f&&(f.tab=/\t/g,f.crlf=/\r\n/g,f.lf=/\n/g,f.cr=/\r/g,f.space=/ /g)})}();
\ No newline at end of file