Repository navigation
Conversation
|
✅ DCO Check Passed Thanks @ankit2235, 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/
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ceberam
left a comment
There was a problem hiding this comment.
Thanks @ankit2235 for spotting the issue and suggesting this PR.
I think we first need to clarify the new contract for line, page, and column breaks, since I don't think \n is the right solution for all cases.
Please, check my comment and let me know what you think
#4585 (comment)
Signed-off-by: Ankit Kumar <ankitkumar19473@gmail.com>
014854b to
a3d7d30
Compare
AI triage (advisory)Checked commit The PR splits DOCX paragraphs at page and column breaks into separate text items under the same parent, and keeps CI safety: no concern found. A maintainer must still approve CI. 3 related pull request(s) in the same code
The |
Signed-off-by: Ankit Kumar <ankitkumar19473@gmail.com> # Conflicts: # docling/backend/msword_backend.py # tests/test_backend_msword.py
…reaks Signed-off-by: Ankit Kumar <ankitkumar19473@gmail.com>
Reworked as discussed in #4585: a page or column break no longer joins the text on either side; it splits the paragraph into separate text items. A line break (
<w:br/>) stays\ninside one item.Behavior
\nat the breakEach part keeps the formatting of its run, so a break inside one bold run gives two bold parts. Empty parts, for example from a break at the start or end of a paragraph, give no item.
Implementation
""._get_run_textmarks them with a form feed (_BREAK_MARK), which cannot occur in DOCX text because XML 1.0 does not allow it._get_paragraph_segmentssplits the runs at the marks before they are grouped by formatting, so a break at a formatting boundary is kept. The grouping loop moved unchanged from_get_paragraph_elementsto_group_paragraph_content._add_segment_text_itemsadds the items of each segment._add_body_text_itemstakes an optionalparent, so the text after a break in a list item goes inside that item._split_off_break_tailgives a title, heading or list item the part before its first break and returns the segments after it._handle_text_elementsstays under the complexity limit.Scope
This follows points 1–5 of the contract in #4585. Out of scope: a break inside a hyperlink (point 6), and paragraphs with equations or code, which keep their current behavior.
Tests
test_page_and_column_breaks_split_a_paragraphcovers line, page and column breaks, including a break inside one bold run.test_page_break_in_a_title_heading_or_list_itemcovers a page break in a title, a heading and a numbered list item.mainand pass with this change. The other Word tests, including the groundtruth comparisons, pass unchanged.Resolves #4585
Checklist: