Commit c3cfb1fbb980511d1e33ef111e0fbdc3336e26b3

mAAdhaTTah 2016-01-30T14:46:38

Ensure show-invisibles compat with autoloader When using the autoloader, the language isn't loaded at the time the show-invisibles plugin attaches its extra tokens. This defers attaching the extra tokens to just before highlighting, so we ensure we're able to attach to the language grammar.

diff --git a/plugins/show-invisibles/prism-show-invisibles.js b/plugins/show-invisibles/prism-show-invisibles.js
index 5d9692b..3c460cc 100644
--- a/plugins/show-invisibles/prism-show-invisibles.js
+++ b/plugins/show-invisibles/prism-show-invisibles.js
@@ -7,13 +7,12 @@ if (
 	return;
 }
 
-for (var language in Prism.languages) {
-	var tokens = Prism.languages[language];
-	
-    tokens.tab = /\t/g;
-    tokens.crlf = /\r\n/g;
-    tokens.lf = /\n/g;
-	tokens.cr = /\r/g;
-}
+Prism.hooks.add('before-highlight', function(env) {
+	var tokens = env.grammar;
 
+	tokens.tab = /\t/g;
+	tokens.crlf = /\r\n/g;
+	tokens.lf = /\n/g;
+	tokens.cr = /\r/g;
+});
 })();