Skip to content

Commit

Permalink
Merge pull request #890 from PrismJS/LeaVerou-patch-1
Browse files Browse the repository at this point in the history
Add before-highlightall hook
  • Loading branch information
LeaVerou committed Feb 14, 2016
2 parents eb2a8d8 + 70a8602 commit 49a3324
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,17 @@ var _ = _self.Prism = {
plugins: {},

highlightAll: function(async, callback) {
var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
var env = {
callback: callback,
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
};

_.hooks.run("before-highlightall", env);

var elements = document.querySelectorAll(env.selector);

for (var i=0, element; element = elements[i++];) {
_.highlightElement(element, async === true, callback);
_.highlightElement(element, async === true, env.callback);
}
},

Expand Down

0 comments on commit 49a3324

Please sign in to comment.