Skip to content

Conversation

@emreclsr
Copy link

Description

This commit fixes an issue where list items immediately following headings (especially numbered headings) were not being processed correctly in Word documents.

While working with Word document conversion, I encountered a similar issue to #2665 where list items after headings were missing from the output. This PR addresses the root cause of this problem.

Changes

  • Clear list history after headings to allow new lists to start
  • Reset level tracking when heading resets hierarchy
  • Reset level_at_new_list when a heading is added
  • Replace else block with explicit elif condition for new list sequences
    • Only continue existing list if parent is actually a ListGroup
    • Handle different numid or missing ListGroup parent by creating new list

Testing

Added test case test_list_items_after_numbered_heading to verify:

  • List items appear correctly after numbered headings
  • Heading has ListGroup as child
  • List group contains the expected list items
  • Document structure is properly maintained

All existing tests continue to pass. No groundtruth files were modified, indicating the fix addresses the bug without breaking existing functionality.

Related Issues

This fix may also resolve #2665 as it addresses the same underlying problem.

Checklist

  • Documentation has been updated, if necessary. (N/A - internal fix)
  • Examples have been added, if necessary. (N/A - bug fix)
  • Tests have been added, if necessary. Added test_list_items_after_numbered_heading

…2665)

This commit fixes an issue where list items immediately following
headings (especially numbered headings) were not being processed
correctly in Word documents.

Changes:
* Clear list history after headings to allow new lists to start
* Reset level tracking when heading resets hierarchy
* Reset level_at_new_list when a heading is added
* Replace else block with explicit elif condition for new list sequences
  - Only continue existing list if parent is actually a ListGroup
  - Handle different numid or missing ListGroup parent by creating new list

Added test case to verify list items appear after numbered headings.

Signed-off-by: Emre Çalışır <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

DCO Check Passed

Thanks @emreclsr, all your commits are properly signed off. 🎉

@dosubot
Copy link

dosubot bot commented Nov 25, 2025

Related Documentation

Checked 4 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@mergify
Copy link

mergify bot commented Nov 25, 2025

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 Require two reviewer for test updates

This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@ceberam ceberam added bug Something isn't working docx issue related to docx backend labels Nov 26, 2025
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Improves test coverage for the list-after-heading fix by adding a test
case for enumerated (numbered) lists following headings.

Changes:
* Extended list_after_num_headers.docx with numbered list test case
  - Added "Title 2" section with "Sub Title 1" heading
  - Added enumerated list items (1-3) directly after heading
* Updated test_list_items_after_numbered_heading to verify both:
  - Bullet lists after headings (existing test)
  - Enumerated lists after headings (new test)
* Updated groundtruth files (.md, .itxt, .json) to reflect new content

Signed-off-by: Emre Çalışır <[email protected]>
@emreclsr
Copy link
Author

Description

This PR improves test coverage for the list-after-heading fix by adding test cases for enumerated (numbered) lists following headings, achieving 100% code coverage for the related changes.

Changes

Test Data

  • Extended list_after_num_headers.docx with enumerated list test case
    • Added "Title 2" → "Sub Title 1" heading with numbered list items

Test Code

  • Enhanced test_list_items_after_numbered_heading to verify both:
    • Bullet lists after numbered headings (existing)
    • Enumerated lists after numbered headings (new)

Groundtruth Files

  • Updated .md, .itxt, and .json files to reflect new test content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working docx issue related to docx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants