From 70a8602fdf776da66a5425dbd89f219c87f852f2 Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Sat, 13 Feb 2016 15:21:28 -0500 Subject: [PATCH] Add before-highlightall hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Needed for unescaped markup plugin, as discussed in #887. Alternatively, we could reinstate @zeitgeist87’s PR about making the selector a config option. Thoughts? --- components/prism-core.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/prism-core.js b/components/prism-core.js index 4a55caad7a..9fcfff658d 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -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); } },