Skip to content

Commit

Permalink
fix(paragraphs): fix empty lines generating empty paragraphs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tivie committed Jan 30, 2017
1 parent e18be38 commit 54bf744
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/subParsers/paragraphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
Expand Down
Empty file.
13 changes: 13 additions & 0 deletions test/cases/strip-references.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 54bf744

Please sign in to comment.