Repository navigation
fix(docx): close an open list before a heading - #4841
LindseyZ1205 wants to merge 1 commit into
Conversation
|
✅ DCO Check Passed Thanks @LindseyZ1205, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit Warning The AI analysis did not finish. Only the deterministic checks are shown. CI safety: not assessed. The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at a9c6440161. It read the code and did not run it.
I found no defect that should stop the merge. In _handle_text_elements, the change clears self.parents from level_at_new_list before _add_heading. I traced both cases in the test (heading level skipped after a list, and a list before the first heading) through _get_level and _add_heading. Both gave the old wrong parent before the change and the correct parent after it.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
you probably can re-use the work done here: #5309 |
|
Hi @LindseyZ1205, thank you for this pull request. It has a merge conflict with git fetch upstream
git rebase upstream/main
# resolve the conflicts, then:
git push --force-with-leaseWe can continue with the review and CI after that. |
A heading paragraph did not close an open list, and _add_heading clears the parents tail only for a lower heading level. So when a list came before the first heading, or a heading skipped a level after a list (for example Heading 1, a list, then Heading 3), the heading and the text under it became children of the ListGroup. This gave invalid HTML (<h4> inside <ul>) and put the section into the list chunk. Close the list before the heading with the same steps as before a table (docling-project#5309), which are now in _close_open_list(). Signed-off-by: LindseyZ1205 <[email protected]>
a9c6440 to
2b014e9
Compare
What: In a DOCX file, a heading that comes right after a list is added inside the list group, so the HTML export puts it in the
<ul>and the chunker merges it into the list's chunk.Why: the backend only closed an open list before a table or body text. The heading branch now closes it too, with the steps #5309 added for tables, moved into
_close_open_list().Issue resolved by this Pull Request:
Resolves #4840
Checklist:
Review evidence:
<ul><li>point one</li><li>point two</li><h4>Details</h4><p>Body of the details section.</p></ul>, and one chunk with the list, the heading and its body. After:<ul><li>point one</li><li>point two</li></ul>, and the chunks'- point one\n- point two'(['Overview']) and'Body of the details section.'(['Overview', 'Details']).test_heading_after_a_list_is_not_in_the_list(a heading that skips a level after a list, and a list before the first heading): fails without this change and passes with it.pytest tests/test_backend_msword*.pywithouttest_e2e_docx_conversions: 338 passed, 2 failed. The same 2 fail onmainwith my docling-core 2.100.0.ruffpasses, andtyreports the same as onmain.test_e2e_docx_conversions(its ground truth needs docling-core 2.106.0 or later) and the full test suite.