Skip to content

fix: treat a line of only tabs as a blank line between paragraphs#4007

Open
sarathfrancis90 wants to merge 1 commit into
markedjs:masterfrom
sarathfrancis90:blank-line-tab
Open

fix: treat a line of only tabs as a blank line between paragraphs#4007
sarathfrancis90 wants to merge 1 commit into
markedjs:masterfrom
sarathfrancis90:blank-line-tab

Conversation

@sarathfrancis90

Copy link
Copy Markdown
Contributor

Markdown flavor: CommonMark

A line that's only tabs (or tabs mixed with spaces) is a blank line in CommonMark, so it should separate paragraphs. Marked only treats a spaces-only line as blank, so when the blank line between two paragraphs happens to contain a tab, that line gets swallowed as a lazy continuation and the two paragraphs merge into one.

With a single tab on the middle line:

foo
	
bar

marked currently returns one paragraph (<p>foo\tbar</p>) instead of <p>foo</p>\n<p>bar</p>. A space-only middle line already works, which is what made this easy to miss.

The paragraph rule's continuation lookahead was checking for +\n (spaces only); I widened it to [ \t]+\n so a tab-only line counts as blank too. GFM and pedantic paragraphs build on the same base rule, so they pick up the fix as well. Added a spec test under test/specs/new.

Contributor

  • Test added (blank_line_with_tabs)
  • No new feature to document

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.
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@sarathfrancis90 is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

@UziTech UziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! 💯

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marked-website Ready Ready Preview, Comment Jul 1, 2026 5:07am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants