Fix unindented paragraph absorbed into list item after nested block#177
Merged
dereuromark merged 3 commits intomasterfrom Apr 13, 2026
Merged
Conversation
When a list item contained a nested block (e.g. an indented code block) followed by a blank line and an unindented paragraph, the paragraph was being collected as lazy continuation of the list item instead of ending the list. After a blank line inside nested content collection, content dropping back to base indent must break out so the parent parser handles it as a new block.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #177 +/- ##
============================================
- Coverage 93.61% 93.51% -0.10%
- Complexity 3241 3242 +1
============================================
Files 93 93
Lines 8203 8207 +4
============================================
- Hits 7679 7675 -4
- Misses 524 532 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PhpCollective enables both PSR12 and Universal.WhiteSpace.AnonClassKeywordSpacing
which disagree on whether a space must appear between 'class' and '(' in
anonymous classes. Exclude the PSR12 sub-rule so CI (which enforces Universal)
matches local runs.
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.
Summary
Fixes #176.
When a list item contains a nested block (e.g. an indented code block) followed by a blank line and an unindented paragraph, djot-php incorrectly collected the paragraph as lazy continuation of the list item, nesting it under the last
<li>instead of closing the list.Example
Example
Before:
New list:and the bullet list rendered inside the last<li>.After: matches djot.js —
</ol>closes, then<p>New list:</p>, then<ul>.Fix
In
BlockParser::tryParseList(), the sub-content collection loop treated any line at base indent that wasn't a block starter or matching list marker as lazy continuation. After a blank line (sawBlankLine), dropping back to base indent now breaks out withbrokeForParentContent = trueso the outer parser handles it as a new block.Regression test added in
NestedBlocksInListsTest::testIssue176UnindentedParagraphAfterNestedCodeBlockEndsList. Full suite (2127 tests) and PHPStan pass.