Skip to content

Fix nested blockquotes and code blocks in list items#84

Merged
dereuromark merged 1 commit intomasterfrom
fix-nested-blocks-in-lists
Feb 24, 2026
Merged

Fix nested blockquotes and code blocks in list items#84
dereuromark merged 1 commit intomasterfrom
fix-nested-blocks-in-lists

Conversation

@dereuromark
Copy link
Contributor

Summary

Fixes #83 - Blockquotes and code blocks in lists don't get rendered properly.

  • Detects when list item content starts with a block element marker and parses it as blocks instead of inline text
  • Calculates proper content indent based on list type (ordered lists use actual marker width, bullet/task lists use base marker width)
  • Adds comprehensive test coverage for nested blocks in lists

Changes

The parser was treating all multi-line list item content as paragraph text, which caused blockquotes (>) and code fences (```) to be escaped/misrendered instead of being parsed as proper block elements.

The fix modifies BlockParser::tryParseList() to:

  1. Check if the first line of list item content starts with a block element using isBlockElementStart()
  2. If so, pass content to parseBlocks() instead of treating it as inline paragraph text
  3. Calculate proper content indent based on marker width (fixes ordered list continuation lines)

Examples

Before:

<ul><li><p>&gt; This is a quote</p></li></ul>

After:

<ul><li><blockquote><p>This is a quote</p></blockquote></li></ul>

The parser was not properly recognizing blockquotes (>) and code blocks
(```) when they appeared directly inside list items without a preceding
blank line. This fix:

1. Detects when list item content starts with a block element marker
   (blockquote, code fence, div, etc.) and parses it as blocks instead
   of treating it as inline paragraph text.

2. Calculates proper content indent based on list type:
   - Ordered lists use actual marker width (e.g., "1. " = 3 chars)
   - Bullet and task lists use base marker width (2 chars)

This allows proper parsing of:
- `- > quote` (blockquote starting a bullet list item)
- `1. > quote` (blockquote in ordered list)
- List items with code fences on the first line
- Multi-line blockquotes with proper continuation

Co-Authored-By: Claude <noreply@anthropic.com>
@dereuromark
Copy link
Contributor Author

Note: The Coding Standards CI failure is due to pre-existing PHPStan errors in InlineParser.php (not modified by this PR). The master branch also fails CI with the same errors. All test jobs pass successfully.

@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.86%. Comparing base (1a6eafc) to head (2269205).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #84   +/-   ##
=========================================
  Coverage     93.85%   93.86%           
- Complexity     2130     2132    +2     
=========================================
  Files            77       77           
  Lines          5699     5705    +6     
=========================================
+ Hits           5349     5355    +6     
  Misses          350      350           

☔ 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 added the bug Something isn't working label Feb 24, 2026
@dereuromark dereuromark merged commit 8e489e4 into master Feb 24, 2026
5 of 6 checks passed
@dereuromark dereuromark deleted the fix-nested-blocks-in-lists branch February 24, 2026 13:40
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.

Blockquotes and code blocks in lists don't get rendered properly

1 participant