Commit b8d098e1d420715366302274c511ab4aeaeeb2fe

Golmote 2015-08-17T09:03:06

Remove the behaviour of Remove initial line feed plugin (remove by default, allow to keep with a CSS class)

diff --git a/plugins/remove-initial-line-feed/index.html b/plugins/remove-initial-line-feed/index.html
index 2af0b66..d981fbb 100644
--- a/plugins/remove-initial-line-feed/index.html
+++ b/plugins/remove-initial-line-feed/index.html
@@ -26,7 +26,8 @@
 	<h1>How to use</h1>
 
 	<p>Obviously, this is supposed to work only for code blocks (<code>&lt;pre>&lt;code></code>) and not for inline code.</p>
-	<p>Add class <strong>remove-initial-line-feed</strong> to your desired <code>&lt;pre></code>.</p>
+	<p>With this plugin included, any initial line feed will be removed by default.</p>
+	<p>To bypass this behaviour, you may add the class <strong>keep-initial-line-feed</strong> to your desired <code>&lt;pre></code>.</p>
 </section>
 
 <section>
@@ -38,7 +39,7 @@
 </code></pre>
 
 	<h2>With the class added</h2>
-	<pre class="language-markup remove-initial-line-feed"><code>
+	<pre class="language-markup keep-initial-line-feed"><code>
 &lt;div>&lt;/div>
 </code></pre>
 
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 c4d3d0e..0b24fb5 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 <pre> or the <code> have the class
-			(clsReg.test(pre.className) || clsReg.test(env.element.className))
+			// Apply only if nor the <pre> or the <code> 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 083381a..a8930b6 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