Repository navigation
fix(docx,iwork): put a sub-list under the list item above it - #4863
Conversation
Signed-off-by: Lubaba Khalid <[email protected]>
|
✅ DCO Check Passed Thanks @LubabaKhalid, all your commits are properly signed off. 🎉 |
|
@dolfim-ibm @DanielNg0729 could you please review this PR when you have time? Thank you! |
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWhen test data is updated, we require two reviewers
|
AI triage (advisory)Checked commit The PR fixes both the DOCX and iWork backends so that a nested list group is added under the last list item of the enclosing group, not directly under the enclosing list group. This matches the behavior of the HTML, Markdown, PowerPoint, and ODF backends and passes Topic labels added: CI safety: no concern found. A maintainer must still approve CI. 1 related pull request(s) in the same code
Reference data changes
Assessment: expected. All 10 changed reference files are DOCX list documents. The The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at c9f44148f4. It read the code and did not run it.
The fix correctly moves nested list groups from being children of a ListGroup to being children of the last ListItem above them, matching the HTML/Markdown/PPTX/ODP backends. The _sub_list_parent helper is sound: when the enclosing group has no items yet it falls back to the group itself, and multi-level jumps are handled correctly because each newly appended group has no children when _sub_list_parent is called for the next level. Reference data changes are symmetric (same line counts added and removed), confirming no text was lost. The reviewer should verify that the _can_reuse_list_group cache check still works correctly now that last_list_group_parent can be a ListItem — it does, because _sub_list_parent returns the same ListItem on every resume of the same sub-list.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The Word and iWork backends add a nested list as a child of the enclosing list group. The HTML, Markdown, PowerPoint and OpenDocument backends add it as a child of the list item above it. The group-child shape:
ListGroupholds only list items (DoclingDocument._validate_rules()reportsListGroup ... contains non-ListItem ...);export_to_html()write a<ul>or<ol>directly inside a<ul>or<ol>, which is not valid HTML.This change adds a nested list group under the last list item of the enclosing group:
_sub_list_parent()is used at the three places that open a nested list group: thew:ilvlpath, the indentation path and a new list sequence._ListStackdoes the same.When the enclosing group has no list item yet, the group stays the parent, as before.
Issue resolved by this Pull Request:
Resolves #4854
Checklist:
Review evidence:
Measured over the 36 DOCX test sources in
tests/data/docx/sources:main<ul>/<ol>directly after</li>inexport_to_html()_validate_rules()with "contains non-ListItem"Reference data: the
.itxtand.jsonfiles of 5 DOCX documents change:docx_lists,docx_list_blank_spacer,docx_list_east_asian_num_fmt,unit_test_formattingandunit_test_headers_numbered. Each nested list moves one level down, under the list item above it. The item numbers, texts and markers do not change. No.mdfile changes.Tests:
test_sub_list_belongs_to_the_item_above_itis a new test. It builds an iWork '09 Pages document with three list levels. It fails onmain.Checks:
uv run pytest tests/test_backend_msword.py tests/test_backend_msword_lists.py tests/test_backend_msword_outline.py tests/test_backend_msword_spacer.py tests/test_backend_iwork_pages.py tests/test_backend_iwork_keynote.py: 402 passed, 1 skippeduv run prek run --files <changed files>: all hooks passed