diff --git a/src/rules.ts b/src/rules.ts index cc2e62bccf..62e04ee512 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -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(); /** diff --git a/test/specs/new/empty_list_after_blockquote.html b/test/specs/new/empty_list_after_blockquote.html new file mode 100644 index 0000000000..0ea2962633 --- /dev/null +++ b/test/specs/new/empty_list_after_blockquote.html @@ -0,0 +1,13 @@ +
++foo
+
++foo +bar
+