Skip to content

fix(markdown_parser): restore leading-space stripping after hard line breaks#9934

Merged
ematipico merged 4 commits intobiomejs:mainfrom
jfmcdowell:fix/md-container-hard-break
Apr 13, 2026
Merged

fix(markdown_parser): restore leading-space stripping after hard line breaks#9934
ematipico merged 4 commits intobiomejs:mainfrom
jfmcdowell:fix/md-container-hard-break

Conversation

@jfmcdowell
Copy link
Copy Markdown
Contributor

@jfmcdowell jfmcdowell commented Apr 12, 2026

Note

This PR was created with AI assistance (Claude Code).

Summary

Follow-up to #9931. Fixes a regression from #9933 where hard breaks inside blockquotes stopped producing <br />, and continuation-line spaces after hard breaks were preserved in plain paragraphs.

For non-container paragraphs, the parser now strips CommonMark §6.7 continuation spaces before line-continuation handling. Container contexts are unchanged.

Test Plan

  • just test-crate biome_markdown_parser
  • just test-markdown-conformance
  • cargo test -p biome_markdown_formatter
  • just f

Docs

N/A

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 12, 2026

⚠️ No Changeset found

Latest commit: fee71e4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added A-Parser Area: parser A-Formatter Area: formatter L-Markdown Language: Markdown labels Apr 12, 2026
@jfmcdowell jfmcdowell changed the title fix(markdown_parser): restore §6.7 leading-space stripping after hard line breaks fix(markdown_parser): restore leading-space stripping after hard line breaks Apr 12, 2026
@jfmcdowell jfmcdowell force-pushed the fix/md-container-hard-break branch 2 times, most recently from 581af4f to fb85ead Compare April 12, 2026 18:31
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 12, 2026

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 228 skipped benchmarks1


Comparing jfmcdowell:fix/md-container-hard-break (fee71e4) with main (9956f1d)

Open in CodSpeed

Footnotes

  1. 228 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions github-actions bot removed the A-Formatter Area: formatter label Apr 12, 2026
@jfmcdowell jfmcdowell force-pushed the fix/md-container-hard-break branch from e703e33 to 29027e5 Compare April 12, 2026 19:09
@jfmcdowell jfmcdowell marked this pull request as ready for review April 12, 2026 19:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

Walkthrough

Refactors paragraph-continuation and hard-line-break handling in the Markdown parser. Introduces handle_line_continuation to centralise checks (quote-prefix, setext/thematic underlines, list interrupts, nested-list marker/indent, fence/textual-block interrupts) and adjusts quote-blank-line probing so prefix markers aren’t consumed. handle_inline_newline and parse_inline_item_list now delegate to the new helper. Adds unit tests and HTML/MD fixtures covering hard breaks in blockquotes, list items and nested quote-in-list scenarios.

Possibly related PRs

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main fix: restoring leading-space stripping after hard line breaks in the Markdown parser, which directly addresses the regression described in the PR objectives.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the regression from #9933, the specific fix applied, and how it restores CommonMark §6.7 continuation-space handling for non-container paragraphs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_markdown_parser/src/syntax/mod.rs`:
- Around line 865-877: is_quote_blank_line_from_current currently mutates parser
state by calling consume_quote_prefix_without_virtual and p.bump while probing,
which can desynchronize later quote continuation checks; change the probe to be
non-mutating by making it operate on a snapshot or lookahead of the parser
(e.g., clone p or use a cursor/snapshot API) instead of bumping the real parser,
keeping the original checks (has_quote_prefix, MD_TEXTUAL_LITERAL whitespace
checks, NEWLINE/EOF detection) but performing them against the cloned/temporary
parser so consume_quote_prefix_without_virtual and p.bump are not invoked on the
live p.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ba24faea-235c-4206-a8ea-46013b9bde9c

📥 Commits

Reviewing files that changed from the base of the PR and between 9956f1d and 29027e5.

⛔ Files ignored due to path filters (3)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_in_blockquote.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_in_list_item.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_nested_quote_in_list.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (8)
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/src/to_html.rs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_in_blockquote.html
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_in_blockquote.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_in_list_item.html
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_in_list_item.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_nested_quote_in_list.html
  • crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_nested_quote_in_list.md

Comment thread crates/biome_markdown_parser/src/syntax/mod.rs
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/fix-markdown-quote-blank-line-probe.md:
- Line 5: Update the changeset text to mention both fixes: in addition to
"quoted hard-line-break handling" describe that the parser also restores
stripping continuation-line spaces after hard breaks in ordinary (plain)
paragraphs; edit the sentence in
.changeset/fix-markdown-quote-blank-line-probe.md to explicitly include
"plain-paragraph fix" or similar wording so the release note accurately reflects
both user-facing changes (quoted content behavior and plain paragraph
continuation-line space stripping).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 058e40cf-97b1-47e2-b8e4-131927b97443

📥 Commits

Reviewing files that changed from the base of the PR and between 29027e5 and 63460aa.

📒 Files selected for processing (3)
  • .changeset/fix-markdown-quote-blank-line-probe.md
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/tests/spec_test.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_markdown_parser/tests/spec_test.rs

"@biomejs/biome": patch
---

Fixed the Markdown parser's quoted hard-line-break handling so blank-line checks no longer consume quote prefixes while probing. This preserves correct continuation parsing for quoted content after hard breaks.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Please mention the plain-paragraph fix too.

The parser change also restores stripping continuation-line spaces after hard breaks in ordinary paragraphs, but this note only mentions quoted content. Worth folding both behaviours in so the release note matches what actually shipped. As per coding guidelines, "Changeset descriptions should focus on user-facing changes only".

🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: Possible missing comma found.
Context: ...arkdown parser's quoted hard-line-break handling so blank-line checks no longer consume ...

(AI_HYDRA_LEO_MISSING_COMMA)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/fix-markdown-quote-blank-line-probe.md at line 5, Update the
changeset text to mention both fixes: in addition to "quoted hard-line-break
handling" describe that the parser also restores stripping continuation-line
spaces after hard breaks in ordinary (plain) paragraphs; edit the sentence in
.changeset/fix-markdown-quote-blank-line-probe.md to explicitly include
"plain-paragraph fix" or similar wording so the release note accurately reflects
both user-facing changes (quoted content behavior and plain paragraph
continuation-line space stripping).

Comment thread .changeset/fix-markdown-quote-blank-line-probe.md Outdated
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.

What's this for? Mistake maybe?

Comment thread crates/biome_markdown_parser/tests/md_test_suite/ok/hard_break_in_blockquote.html Outdated
Per maintainer feedback, these HTML reference files are not needed
for the hard break parser fix.
@ematipico ematipico merged commit 77ad4a4 into biomejs:main Apr 13, 2026
17 checks passed
@jfmcdowell jfmcdowell deleted the fix/md-container-hard-break branch April 13, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants