diff --git a/plugins/normalize-whitespace/index.html b/plugins/normalize-whitespace/index.html
index 7942b55edb..a9c3d309a3 100644
--- a/plugins/normalize-whitespace/index.html
+++ b/plugins/normalize-whitespace/index.html
@@ -42,6 +42,9 @@
How to use
By default the plugin trims all leading and trailing whitespace of every code block.
It also removes extra indents and trailing whitespace on every line.
+ The plugin can be disabled for a particular code block by adding the class no-whitespace-normalization
to
+ either the <pre>
or <code>
tag.
+
The default settings can be overridden with the setDefaults()
method
like so:
diff --git a/plugins/normalize-whitespace/prism-normalize-whitespace.js b/plugins/normalize-whitespace/prism-normalize-whitespace.js
index db02fce5e8..d44f98caed 100644
--- a/plugins/normalize-whitespace/prism-normalize-whitespace.js
+++ b/plugins/normalize-whitespace/prism-normalize-whitespace.js
@@ -128,8 +128,10 @@ Prism.plugins.NormalizeWhitespace = new NormalizeWhitespace({
Prism.hooks.add('before-highlight', function (env) {
var pre = env.element.parentNode;
+ var clsReg = /\bno-whitespace-normalization\b/;
if (!env.code || !pre || pre.nodeName.toLowerCase() !== 'pre' ||
- (env.settings && env.settings['whitespace-normalization'] === false))
+ (env.settings && env.settings['whitespace-normalization'] === false) ||
+ clsReg.test(pre.className) || clsReg.test(env.element.className))
return;
var children = pre.childNodes,
diff --git a/plugins/normalize-whitespace/prism-normalize-whitespace.min.js b/plugins/normalize-whitespace/prism-normalize-whitespace.min.js
index 53a4b4af90..0e00cf9d7e 100644
--- a/plugins/normalize-whitespace/prism-normalize-whitespace.min.js
+++ b/plugins/normalize-whitespace/prism-normalize-whitespace.min.js
@@ -1 +1 @@
-!function(){function e(e){this.defaults=r({},e)}function n(e){return e.replace(/-(\w)/g,function(e,n){return n.toUpperCase()})}function t(e){for(var n=0,t=0;tn&&(o[l]="\n"+o[l],a=s)}r[i]=o.join("")}return r.join("\n")}},Prism.plugins.NormalizeWhitespace=new e({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0}),Prism.hooks.add("before-highlight",function(e){var n=e.element.parentNode;if(e.code&&n&&"pre"===n.nodeName.toLowerCase()&&(!e.settings||e.settings["whitespace-normalization"]!==!1)){for(var t=n.childNodes,r="",i="",o=!1,a=Prism.plugins.NormalizeWhitespace,l=0;ln&&(o[s]="\n"+o[s],a=l)}r[i]=o.join("")}return r.join("\n")}},Prism.plugins.NormalizeWhitespace=new e({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0}),Prism.hooks.add("before-highlight",function(e){var n=e.element.parentNode,t=/\bno-whitespace-normalization\b/;if(!(!e.code||!n||"pre"!==n.nodeName.toLowerCase()||e.settings&&e.settings["whitespace-normalization"]===!1||t.test(n.className)||t.test(e.element.className))){for(var r=n.childNodes,i="",o="",a=!1,s=Prism.plugins.NormalizeWhitespace,l=0;l