Bug
ReadingOrderModel._merge_elements removes a trailing soft hyphen (\u00ad) before joining a cross-element continuation, but a hard hyphen (-) always follows the regular space-joining path. A split word such as algo- + rithms is therefore emitted as algo- rithms.
Steps to reproduce
The affected code path is deterministic with two TextElement instances carrying the same label:
- Create a list item whose text is
algo-.
- Merge a following
LIST_ITEM element whose text is rithms.
ReadingOrderModel._merge_elements(...) produces algo- rithms instead of algorithms.
Soft hyphens already produce algorithms, which makes the hard-hyphen behavior inconsistent.
Expected behavior
When the first element ends in - and the first non-whitespace character of the continuation is lowercase, treat the pair as a hyphenated line wrap: remove the hyphen and join without a space. Preserve the existing behavior for uppercase continuations, where a hard hyphen may be meaningful punctuation.
Docling version
main at 873f990 (package version 2.115.0).
Python version
Python 3.13.12.
Relationship to #3881
This is the downstream half of #3881. A companion change in docling-ibm-models makes eligible LIST_ITEM pairs reach the merge mapping; this change ensures the final document text is correctly dehyphenated once that mapping is present.
Bug
ReadingOrderModel._merge_elementsremoves a trailing soft hyphen (\u00ad) before joining a cross-element continuation, but a hard hyphen (-) always follows the regular space-joining path. A split word such asalgo-+rithmsis therefore emitted asalgo- rithms.Steps to reproduce
The affected code path is deterministic with two
TextElementinstances carrying the same label:algo-.LIST_ITEMelement whose text isrithms.ReadingOrderModel._merge_elements(...)producesalgo- rithmsinstead ofalgorithms.Soft hyphens already produce
algorithms, which makes the hard-hyphen behavior inconsistent.Expected behavior
When the first element ends in
-and the first non-whitespace character of the continuation is lowercase, treat the pair as a hyphenated line wrap: remove the hyphen and join without a space. Preserve the existing behavior for uppercase continuations, where a hard hyphen may be meaningful punctuation.Docling version
mainat873f990(package version2.115.0).Python version
Python
3.13.12.Relationship to #3881
This is the downstream half of #3881. A companion change in
docling-ibm-modelsmakes eligibleLIST_ITEMpairs reach the merge mapping; this change ensures the final document text is correctly dehyphenated once that mapping is present.