Nest sublists in list items under blocksInterruptParagraphs#209
Merged
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
blocksInterruptParagraphstreated a sublist inconsistently across nesting levels. At the top level a list already interrupts a paragraph under this option, but inside a list itemallowsImmediateNestedBlock()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.Under
blocksInterruptParagraphsthis used to fold- a/- binto the item as literal text; onlynestedListsWithoutBlankLinewould 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:- xstays literal, via the same lone-marker lookahead that keepsx = 5/- 3as prose at the top level.1./1)ordered (the CommonMark guard that keeps2. applesor(1) noteas prose). A2.or(1)sublist stays literal under interruption alone, the same as at top level.This makes
nestedListsWithoutBlankLinea clear narrower subset: it still nests a lone sublist marker without lookahead, which interruption's lookahead folds in. The deprecated broadnestedBlocksInListsis unchanged.Notes
The recognized-marker set is intentionally restricted to match top-level interruption, not the canonical
parseListItemMarkercoverage. 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.