Skip to content

Commit

Permalink
fix: fix loose item with line break at beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Dec 6, 2022
1 parent 6a44508 commit 19c1f1b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export class Tokenizer {
if (!list.loose) {
// Check if list should be loose
const spacers = list.items[i].tokens.filter(t => t.type === 'space');
const hasMultipleLineBreaks = spacers.length > 0 && spacers.every(t => /\n.*\n/.test(t.raw));
const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw));

list.loose = hasMultipleLineBreaks;
}
Expand Down
9 changes: 9 additions & 0 deletions test/specs/new/list_loose.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ul>
<li>
<p>item 1</p>
</li>
<li>
<p>item 2</p>
<p>still item 2</p>
</li>
</ul>
5 changes: 5 additions & 0 deletions test/specs/new/list_loose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- item 1
-
item 2

still item 2

0 comments on commit 19c1f1b

Please sign in to comment.