Преглед на файлове

fix(paragraphs): fix empty lines generating empty paragraphs

Empty lines should not be parsed as paragraphs. This was happening
in determined circumstances.
For instance, when stripping reference style links, `\n\n` was left being,
creating an undesired empty paragraph. This commit fixes the issue.

Closes #334
Estevao Soares dos Santos преди 8 години
родител
ревизия
54bf74472a
променени са 7 файла, в които са добавени 21 реда и са изтрити 2 реда
  1. 4 1
      dist/showdown.js
  2. 0 0
      dist/showdown.js.map
  3. 0 0
      dist/showdown.min.js
  4. 0 0
      dist/showdown.min.js.map
  5. 4 1
      src/subParsers/paragraphs.js
  6. 0 0
      test/cases/strip-references.html
  7. 13 0
      test/cases/strip-references.md

+ 4 - 1
dist/showdown.js

@@ -2351,7 +2351,10 @@ showdown.subParser('paragraphs', function (text, options, globals) {
     // if this is an HTML marker, copy it
     if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
       grafsOut.push(str);
-    } else {
+
+    // test for presence of characters to prevent empty lines being parsed
+    // as paragraphs (resulting in undesired extra empty paragraphs)
+    } else if (str.search(/\S/) >= 0) {
       str = showdown.subParser('spanGamut')(str, options, globals);
       str = str.replace(/^([ \t]*)/g, '<p>');
       str += '</p>';

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.js.map


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.min.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.min.js.map


+ 4 - 1
src/subParsers/paragraphs.js

@@ -18,7 +18,10 @@ showdown.subParser('paragraphs', function (text, options, globals) {
     // if this is an HTML marker, copy it
     if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
       grafsOut.push(str);
-    } else {
+
+    // test for presence of characters to prevent empty lines being parsed
+    // as paragraphs (resulting in undesired extra empty paragraphs)
+    } else if (str.search(/\S/) >= 0) {
       str = showdown.subParser('spanGamut')(str, options, globals);
       str = str.replace(/^([ \t]*)/g, '<p>');
       str += '</p>';

+ 0 - 0
test/cases/strip-references.html


+ 13 - 0
test/cases/strip-references.md

@@ -0,0 +1,13 @@
+[1]: http://www.google.co.uk
+
+[http://www.google.co.uk]: http://www.google.co.uk
+
+
+
+
+
+[1]: http://dsurl.stuff/something.jpg
+
+[1]:http://www.google.co.uk
+
+ [1]:http://www.google.co.uk

Някои файлове не бяха показани, защото твърде много файлове са промени