Skip to content

Commit

Permalink
Add before-highlightall hook
Browse files Browse the repository at this point in the history
Needed for unescaped markup plugin, as discussed in #887.
Alternatively, we could reinstate @zeitgeist87’s PR about making the selector a config option.
Thoughts?
  • Loading branch information
LeaVerou committed Feb 13, 2016
1 parent c1e75bd commit 70a8602
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 70a8602

Please sign in to comment.