Skip to content

Nest sublists in list items under blocksInterruptParagraphs#209

Merged
dereuromark merged 1 commit into
masterfrom
feature/bip-nests-sublists-in-items
Jun 3, 2026
Merged

Nest sublists in list items under blocksInterruptParagraphs#209
dereuromark merged 1 commit into
masterfrom
feature/bip-nests-sublists-in-items

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Problem

blocksInterruptParagraphs treated a sublist inconsistently across nesting levels. At the top level a list already interrupts a paragraph under this option, but inside a list item allowsImmediateNestedBlock() explicitly excluded list markers (!$isListMarker), so a blockquote, heading, fence or table nested in an item while a sublist did not. A list is a block, so the two cases should behave the same.

- Item
  - a
  - b

Under blocksInterruptParagraphs this used to fold - a / - b into the item as literal text; only nestedListsWithoutBlankLine would nest it.

Change

The in-item path now delegates list markers to the same startsNewBlockSignificant() decision the top-level paragraph-interruption path uses. Behavior is now identical across nesting levels:

  • A real (multi-item) sublist nests inside a list item.
  • A lone single-item - x stays literal, via the same lone-marker lookahead that keeps x = 5 / - 3 as prose at the top level.
  • Recognized openers match the top level exactly: bullets and 1./1) ordered (the CommonMark guard that keeps 2. apples or (1) note as prose). A 2. or (1) sublist stays literal under interruption alone, the same as at top level.

This makes nestedListsWithoutBlankLine a clear narrower subset: it still nests a lone sublist marker without lookahead, which interruption's lookahead folds in. The deprecated broad nestedBlocksInLists is unchanged.

Notes

The recognized-marker set is intentionally restricted to match top-level interruption, not the canonical parseListItemMarker coverage. Broadening it would make in-item nesting more permissive than top-level interruption and reintroduce the very cross-level inconsistency this fixes; a regression test pins that parity.

Tests cover multi-item nesting, the lone-marker fold, the restricted marker set, and the subset relationship. Full suite green (2487 tests) including the official djot suite; phpstan and phpcs clean.

A list is a block, so under blocksInterruptParagraphs it should interrupt
the lead paragraph of a list item the same way it interrupts a top-level
paragraph. Previously allowsImmediateNestedBlock() excluded list markers
(`!$isListMarker`), so a blockquote, heading, fence or table nested inside
a list item but a sublist did not, which was inconsistent: at top level a
list already interrupts a paragraph under this option.

The in-item path now delegates list markers to the same
startsNewBlockSignificant() decision the top-level path uses, so behavior
is identical across nesting levels:

- A real (multi-item) sublist nests inside a list item.
- A lone single-item `- x` stays literal via the same lone-marker
  lookahead that keeps `x = 5\n- 3` prose at top level.
- The recognized openers match top level exactly: bullets and 1./1)
  ordered (the CommonMark guard that keeps `2. apples` or `(1) note`
  prose). A `2.` or `(1)` sublist stays literal under interruption alone,
  the same as at top level.

This makes nestedListsWithoutBlankLine a narrower subset: it still nests a
lone sublist marker without lookahead, which interruption folds in.
@dereuromark dereuromark added the enhancement New feature or request label Jun 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.87%. Comparing base (1a36893) to head (bfc5edc).

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #209   +/-   ##
=========================================
  Coverage     91.87%   91.87%           
+ Complexity     3489     3488    -1     
=========================================
  Files           104      104           
  Lines          9860     9860           
=========================================
  Hits           9059     9059           
  Misses          801      801           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit efee942 into master Jun 3, 2026
6 checks passed
@dereuromark dereuromark deleted the feature/bip-nests-sublists-in-items branch June 3, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant