Skip to content

Fix unindented paragraph absorbed into list item after nested block#177

Merged
dereuromark merged 3 commits intomasterfrom
fix/issue-176-unindented-paragraph-after-nested-block
Apr 13, 2026
Merged

Fix unindented paragraph absorbed into list item after nested block#177
dereuromark merged 3 commits intomasterfrom
fix/issue-176-unindented-paragraph-after-nested-block

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

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

1. Item 1
2. Item 2

Example


New list:

* New item 1
* New item 2

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 with brokeForParentContent = true so the outer parser handles it as a new block.

Regression test added in NestedBlocksInListsTest::testIssue176UnindentedParagraphAfterNestedCodeBlockEndsList. Full suite (2127 tests) and PHPStan pass.

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.
@dereuromark dereuromark added the bug Something isn't working label Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.51%. Comparing base (11f2b07) to head (c54dcc7).
⚠️ Report is 1 commits behind head on master.

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.
📢 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.

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.
@dereuromark dereuromark merged commit e1dd9cd into master Apr 13, 2026
4 checks passed
@dereuromark dereuromark deleted the fix/issue-176-unindented-paragraph-after-nested-block branch April 13, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Indentation of new paragraph as list item

1 participant