Skip to content

Commit

Permalink
remark-parse: fix whitespace only lines in paragraphs
Browse files Browse the repository at this point in the history
In commonmark, paragraphs can be split by blank lines even if those
lines contain whitespace.

Currently, in remark, paragraphs will be split by blank lines only if
those lines contain fewer than four characters worth of whitespace,
because the code to detect following indented content checks for an
indentation but doesn't actually check for content.

This commit fixes this behaviour by making sure that there is content
following the indentation before absorbing the next paragraph.

Closes GH-348.
Reviewed-by: Christian Murphy <Christian.Murphy.42@gmail.com>
Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
Hamms authored and wooorm committed Aug 19, 2018
1 parent 00a90d5 commit 4e99404
Show file tree
Hide file tree
Showing 6 changed files with 611 additions and 327 deletions.
2 changes: 1 addition & 1 deletion packages/remark-parse/lib/tokenize/paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function paragraph(eat, value, silent) {
position++;
}

if (size >= TAB_SIZE) {
if (size >= TAB_SIZE && character !== C_NEWLINE) {
index = value.indexOf(C_NEWLINE, index + 1);
continue;
}
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/input/paragraphs-and-indentation.text
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This is a paragraph
This is a paragraph
and this is further text

This is a paragraph

and this is a new paragraph

This is a paragraph with some asterisks
***

Expand Down
Loading

0 comments on commit 4e99404

Please sign in to comment.