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 e62ebca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion plugins/show-invisibles/prism-show-invisibles.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e62ebca

Please sign in to comment.