Skip to content

Commit

Permalink
Ensure show-invisibles compat with autoloader
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mAAdhaTTah committed Jan 30, 2016
1 parent bcdd272 commit c3cfb1f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions plugins/show-invisibles/prism-show-invisibles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
})();

0 comments on commit c3cfb1f

Please sign in to comment.