From 42f34a8411c4c14ca2019d69e6b1771f663248f9 Mon Sep 17 00:00:00 2001 From: Osama Ansar <56025301+OsamaAnsar@users.noreply.github.com> Date: Mon, 26 Oct 2026 10:32:52 +0500 Subject: [PATCH] fix: do not continue a block quote paragraph from a whitespace-only line (#4134) --- src/rules.ts | 4 +++- test/specs/new/blockquote_whitespace_only_empty.html | 3 +++ test/specs/new/blockquote_whitespace_only_empty.md | 2 ++ test/specs/new/blockquote_whitespace_only_line.html | 8 ++++++++ test/specs/new/blockquote_whitespace_only_line.md | 7 +++++++ 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/blockquote_whitespace_only_empty.html create mode 100644 test/specs/new/blockquote_whitespace_only_empty.md create mode 100644 test/specs/new/blockquote_whitespace_only_line.html create mode 100644 test/specs/new/blockquote_whitespace_only_line.md diff --git a/src/rules.ts b/src/rules.ts index 02e12330..2693902d 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -190,7 +190,9 @@ const paragraph = createParagraph(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/); // paragraph, where an empty list cannot interrupt) const blockquoteParagraph = createParagraph(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/); -const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/) +// a line with only whitespace after the marker is blank, so it must not start a +// paragraph that lazily continues onto the next line +const blockquote = edit(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/) .replace('paragraph', blockquoteParagraph) .getRegex(); diff --git a/test/specs/new/blockquote_whitespace_only_empty.html b/test/specs/new/blockquote_whitespace_only_empty.html new file mode 100644 index 00000000..c630a798 --- /dev/null +++ b/test/specs/new/blockquote_whitespace_only_empty.html @@ -0,0 +1,3 @@ +
+
+

b

diff --git a/test/specs/new/blockquote_whitespace_only_empty.md b/test/specs/new/blockquote_whitespace_only_empty.md new file mode 100644 index 00000000..c5d1e53a --- /dev/null +++ b/test/specs/new/blockquote_whitespace_only_empty.md @@ -0,0 +1,2 @@ +> +b diff --git a/test/specs/new/blockquote_whitespace_only_line.html b/test/specs/new/blockquote_whitespace_only_line.html new file mode 100644 index 00000000..c88b315b --- /dev/null +++ b/test/specs/new/blockquote_whitespace_only_line.html @@ -0,0 +1,8 @@ +
+

a

+
+

b

+
+

c

+
+

d

diff --git a/test/specs/new/blockquote_whitespace_only_line.md b/test/specs/new/blockquote_whitespace_only_line.md new file mode 100644 index 00000000..fa3a72cb --- /dev/null +++ b/test/specs/new/blockquote_whitespace_only_line.md @@ -0,0 +1,7 @@ +> a +> +b + +> c +> +d