Skip to content

fix(markdown_parser): break paragraph at sibling list marker without tab#10376

Merged
dyc3 merged 3 commits into
biomejs:mainfrom
jfmcdowell:fix/markdown-ordered-sublist-post-marker-wide-space
May 17, 2026
Merged

fix(markdown_parser): break paragraph at sibling list marker without tab#10376
dyc3 merged 3 commits into
biomejs:mainfrom
jfmcdowell:fix/markdown-ordered-sublist-post-marker-wide-space

Conversation

@jfmcdowell

@jfmcdowell jfmcdowell commented May 15, 2026

Copy link
Copy Markdown
Contributor

Note

I used Codex to help plan, implement, and validate this fix.

Summary

Fixes #10374.

Break markdown list paragraphs when a sibling or parent list marker appears at the current item marker indent. The previous check only handled the tab-indented case, so a nested ordered sibling with wider post-marker spacing was parsed as paragraph text.

Test Plan

  • Added parser snapshot fixtures for the issue reproducer and delimiter-crossing regression.
  • just test-crate biome_markdown_parser
  • just test-crate biome_markdown_formatter
  • just test-markdown-conformance

Docs

N/A.

@changeset-bot

changeset-bot Bot commented May 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d92cb3d

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 May 15, 2026
@codspeed-hq

codspeed-hq Bot commented May 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 228 skipped benchmarks1


Comparing jfmcdowell:fix/markdown-ordered-sublist-post-marker-wide-space (d92cb3d) with main (c8b5e2a)2

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.

  2. No successful run was found on main (13cd12b) during the generation of this report, so c8b5e2a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions github-actions Bot removed the A-Formatter Area: formatter label May 16, 2026
@jfmcdowell jfmcdowell force-pushed the fix/markdown-ordered-sublist-post-marker-wide-space branch from 10c7543 to 0a69940 Compare May 16, 2026 16:57
Inside a list item, a sibling ordered marker at column <= the item's
marker_indent must end the current paragraph (CommonMark §5.2).
break_for_list_interrupt_after_inline_newline only ran the marker
lookahead when the leading whitespace contained a tab, so a non-tab
sibling ordered marker was missed whenever the parent's post-marker
space widened required_indent past the sibling's column.

Reproducer (biomejs#10374):

    1.  first
    2.  second
        1.   third
        2.   fourth

Inner item `1.   third` has marker_indent=4, required_indent=9. The
next line at indent 4 is a sibling, but `indent < required_indent` and
no tab in the leading whitespace, so the break check returned false and
`2.   fourth` plus its leading 4 spaces were swallowed as
MD_TEXTUAL_LITERALs inside the first inner item's paragraph.

The non-tab path now runs a narrow token lookahead that only flags
non-1 ordered markers — parse_inline_item_list's
textual_looks_like_list_marker already terminates on bullets and on
`1.`/`1)`, so widening to all marker shapes regressed
synthetic/nested-lists by ~10% without buying additional correctness.
The tab path keeps the original token-aware lookahead (biomejs#10333).

Verified:
- cargo test -p biome_markdown_parser (all 256 tests pass)
- cargo test -p biome_markdown_formatter (all 839 tests pass)
- cargo bench synthetic/nested-lists: cached +5%, uncached noise
@jfmcdowell jfmcdowell force-pushed the fix/markdown-ordered-sublist-post-marker-wide-space branch from 0a69940 to 716cb1f Compare May 16, 2026 22:15
@jfmcdowell jfmcdowell marked this pull request as ready for review May 16, 2026 23:11
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6fc207bc-8efe-4f3f-a5b0-5bcbf8142723

📥 Commits

Reviewing files that changed from the base of the PR and between fc45916 and d92cb3d.

⛔ Files ignored due to path filters (1)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space_delimiter_cross.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space_delimiter_cross.md
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space_delimiter_cross.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_markdown_parser/src/syntax/mod.rs

Walkthrough

Detects non-1 ordered list markers after skipping indentation via a new helper, branches list-interrupt lookahead based on whether the next line’s leading whitespace contains a tab, and aligns the inline-emphasis prescan to treat textual ordered markers as interrupts. Adds two markdown fixtures exercising wide post-marker spacing and mixed delimiters.

Possibly related PRs

  • biomejs/biome#10349: Also refines ordered-marker paragraph/list interruption logic and non-1 ordered marker detection.
  • biomejs/biome#10228: Modifies inline scan/interrupt handling around at_block_interrupt_after_indent and indent-aware marker detection.
  • biomejs/biome#10333: Related edits to break_for_list_interrupt_after_inline_newline for tab/indent-sensitive sibling marker parsing.

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title precisely describes the main change: fixing paragraph breaks at sibling list markers without tabs in the markdown parser.
Description check ✅ Passed Description clearly relates to the changeset, explaining the fix for parsing nested ordered sublists with wider post-marker spacing and test coverage.
Linked Issues check ✅ Passed The PR directly addresses issue #10374 by updating list-interruption detection to handle non-tab-indented sibling markers, enabling proper nested ordered list parsing.
Out of Scope Changes check ✅ Passed All changes focus on fixing the list-marker interruption logic and adding relevant test fixtures; nothing appears unrelated to the linked issue.

✏️ 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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md (1)

1-4: ⚡ Quick win

Please add a delimiter-crossing fixture too.

This reproducer proves the list shape, but it will not catch the inline-prescan case above. A variant with an opener on the first line and its closer inside the nested 2. item would pin the paragraph boundary down nicely.

As per coding guidelines "All code changes MUST include tests: lint rules in crates/biome_<lang>_analyze/tests/specs/{group}/{rule}/, formatter snapshot tests with valid/invalid cases, parser tests for valid and error cases, and bug fix tests reproducing and validating the fix".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md`
around lines 1 - 4, Add a second test fixture that crosses a block delimiter:
create a variant of ordered_sublist_post_marker_wide_space.md where an opening
paragraph/inline delimiter starts on the first top-level item line and its
closing delimiter appears inside the nested "2." subitem (so the paragraph runs
across the list-item boundary), ensuring this captures the inline-prescan case;
name it clearly (e.g.,
ordered_sublist_post_marker_wide_space_delimiter_cross.md) and place it
alongside the existing fixture in the same tests directory so the parser test
suite validates the delimiter-crossing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/biome_markdown_parser/src/syntax/mod.rs`:
- Around line 1169-1173: The prescan path in inline_list_source_len() must
mirror parse_inline_item_list()’s new break logic: when indent <
required_indent, reuse the same predicate used there (i.e. call
at_block_interrupt_after_indent() or the exact checks used by
parse_inline_item_list() such as line_start_indent_contains_tab() followed by
line_starts_with_list_marker_after_indent() or
line_starts_with_nonone_ordered_marker_after_indent()) so the prescan stops on
non-`1` sibling markers the same way; update inline_list_source_len() to invoke
the same helper/predicate sequence (or directly call
at_block_interrupt_after_indent()) instead of only
at_block_interrupt()/textual_looks_like_list_marker() to prevent scanning past
the paragraph boundary and leaking delimiters.

---

Nitpick comments:
In
`@crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md`:
- Around line 1-4: Add a second test fixture that crosses a block delimiter:
create a variant of ordered_sublist_post_marker_wide_space.md where an opening
paragraph/inline delimiter starts on the first top-level item line and its
closing delimiter appears inside the nested "2." subitem (so the paragraph runs
across the list-item boundary), ensuring this captures the inline-prescan case;
name it clearly (e.g.,
ordered_sublist_post_marker_wide_space_delimiter_cross.md) and place it
alongside the existing fixture in the same tests directory so the parser test
suite validates the delimiter-crossing behavior.
🪄 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: 468fa92f-d8af-476f-834d-c7e14831f7a5

📥 Commits

Reviewing files that changed from the base of the PR and between c8b5e2a and 716cb1f.

⛔ Files ignored due to path filters (1)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md

Comment thread crates/biome_markdown_parser/src/syntax/mod.rs
textual_looks_like_list_marker matches only 1./1) for ordered, so
inline_list_source_len walked past sibling 2.-style markers folded
into MD_TEXTUAL_LITERAL and leaked emphasis delimiters from the next
list item. Mirror parse_inline_item_list's break (biomejs#10374) by adding
textual_starts_with_ordered_marker to at_block_interrupt_after_indent.

Refs biomejs#10376
@jfmcdowell jfmcdowell marked this pull request as draft May 17, 2026 00:21
@jfmcdowell jfmcdowell marked this pull request as ready for review May 17, 2026 00:50
@dyc3 dyc3 merged commit fcb1e48 into biomejs:main May 17, 2026
28 checks passed
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.

🐛 [md] Sub ordered list with post list marker space

2 participants