Skip to content

Commit

Permalink
Check if tokens exists and return
Browse files Browse the repository at this point in the history
If the language was autoloaded, the grammar may not exist yet.
We need to check if it exists before we attempt to modify it.
  • Loading branch information
mAAdhaTTah committed Sep 27, 2017
1 parent e76cd72 commit f6f3ab5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/show-invisibles/prism-show-invisibles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ if (
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;
Expand Down

0 comments on commit f6f3ab5

Please sign in to comment.