Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,23 @@ const paragraph = edit(_paragraph)
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
.getRegex();

// inside a blockquote a bare list marker starts a sibling list, so it must
// not be lazily continued as paragraph text (unlike a top level paragraph,
// where an empty list cannot interrupt)
const blockquoteParagraph = edit(_paragraph)
.replace('hr', hr)
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
.replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
.replace('|table', '')
.replace('blockquote', ' {0,3}>')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)])(?:[ \\t]|\\n|$)') // a bare list marker also interrupts
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
.getRegex();

const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
.replace('paragraph', paragraph)
.replace('paragraph', blockquoteParagraph)
.getRegex();

/**
Expand Down
13 changes: 13 additions & 0 deletions test/specs/new/empty_list_after_blockquote.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<blockquote>
<p>foo</p>
</blockquote>
<ul>
<li></li>
</ul>
<blockquote>
<p>foo
bar</p>
</blockquote>
<ol>
<li></li>
</ol>
6 changes: 6 additions & 0 deletions test/specs/new/empty_list_after_blockquote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
> foo
-

> foo
> bar
1.