diff --git a/plugins/remove-initial-line-feed/index.html b/plugins/remove-initial-line-feed/index.html index 2af0b6697a..d981fbb770 100644 --- a/plugins/remove-initial-line-feed/index.html +++ b/plugins/remove-initial-line-feed/index.html @@ -26,7 +26,8 @@
Obviously, this is supposed to work only for code blocks (<pre><code>
) and not for inline code.
Add class remove-initial-line-feed to your desired <pre>
.
With this plugin included, any initial line feed will be removed by default.
+To bypass this behaviour, you may add the class keep-initial-line-feed to your desired <pre>
.
+
<div></div>
diff --git a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js
index c4d3d0ecae..0b24fb5cc2 100644
--- a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js
+++ b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js
@@ -1,11 +1,11 @@
Prism.hooks.add('before-highlight', function(env) {
if (env.code) {
var pre = env.element.parentNode;
- var clsReg = /\s*\bremove-initial-line-feed\b\s*/;
+ var clsReg = /\s*\bkeep-initial-line-feed\b\s*/;
if (
pre && pre.nodeName.toLowerCase() === 'pre' &&
- // Apply only if the or the have the class
- (clsReg.test(pre.className) || clsReg.test(env.element.className))
+ // Apply only if nor the or the have the class
+ (!clsReg.test(pre.className) && !clsReg.test(env.element.className))
) {
env.code = env.code.replace(/^(?:\r?\n|\r)/, '');
}
diff --git a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
index 083381afdc..a8930b631e 100644
--- a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
+++ b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
@@ -1 +1 @@
-Prism.hooks.add("before-highlight",function(e){if(e.code){var o=e.element.parentNode,a=/\s*\bremove-initial-line-feed\b\s*/;o&&"pre"===o.nodeName.toLowerCase()&&(a.test(o.className)||a.test(e.element.className))&&(e.code=e.code.replace(/^(?:\r?\n|\r)/,""))}});
\ No newline at end of file
+Prism.hooks.add("before-highlight",function(e){if(e.code){var a=e.element.parentNode,o=/\s*\bkeep-initial-line-feed\b\s*/;!a||"pre"!==a.nodeName.toLowerCase()||o.test(a.className)||o.test(e.element.className)||(e.code=e.code.replace(/^(?:\r?\n|\r)/,""))}});
\ No newline at end of file