From cfa3d4ce4d58f5a777926c7e45e25b6d902199be Mon Sep 17 00:00:00 2001 From: Sarath Francis Date: Tue, 30 Jun 2026 22:54:16 -0400 Subject: [PATCH] fix: treat a line of only tabs as a blank line between paragraphs A line containing only tabs (or tabs mixed with spaces) is a blank line per CommonMark, so it should break a paragraph. The paragraph rule only checked for a spaces-only line ( +\n) in its continuation lookahead, so a tab-only line was swallowed as a lazy continuation and the surrounding text was merged into one paragraph. Widened it to [ \t]+\n to match tabs too. --- src/rules.ts | 2 +- test/specs/new/blank_line_with_tabs.html | 4 ++++ test/specs/new/blank_line_with_tabs.md | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/blank_line_with_tabs.html create mode 100644 test/specs/new/blank_line_with_tabs.md diff --git a/src/rules.ts b/src/rules.ts index c9bc07c5d6..997f9be52a 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -128,7 +128,7 @@ const lheadingGfm = edit(lheadingCore) .replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt .replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/) // table can interrupt .getRegex(); -const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/; +const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/; const blockText = /^[^\n]+/; const _blockLabel = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/; const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/) diff --git a/test/specs/new/blank_line_with_tabs.html b/test/specs/new/blank_line_with_tabs.html new file mode 100644 index 0000000000..83dc66c022 --- /dev/null +++ b/test/specs/new/blank_line_with_tabs.html @@ -0,0 +1,4 @@ +

foo

+

bar

+

baz

+

qux

diff --git a/test/specs/new/blank_line_with_tabs.md b/test/specs/new/blank_line_with_tabs.md new file mode 100644 index 0000000000..a79bd0f899 --- /dev/null +++ b/test/specs/new/blank_line_with_tabs.md @@ -0,0 +1,10 @@ +--- +gfm: false +--- +foo + +bar + +baz + +qux