docling-project / docling-project/docling
headers on left-hand-side not attached to paragraph block on right-hand-side
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
Default OCR works well BUT layout is wrong when headers are on the left but paragraph(s) on the right.
I think this is a bug, it is remotely possible this is a feature request in disguise (or even user error).
The test files provided are created by me, based on some real physical paperwork I was scanning and OCR'ing. EDIT also see comment https://github.com/docling-project/docling/issues/3643#issuecomment-4760454950 attachments.
The original was a 3-color scan, I've provided 3-color and mono samples.
[docling_bugreport_misplaced_headers_singlepage_red.html](https://github.com/user-attachments/files/29073676/docling_bugreport_misplaced_headers_singlepage_red.html)
[docling_bugreport_misplaced_headers_singlepage_black.html](https://github.com/user-attachments/files/29073678/docling_bugreport_misplaced_headers_singlepage_black.html)
[Docling bug report for headers not connected to paragraph content_3-color_red.pdf](https://github.com/user-attachments/files/29073688/Docling.bug.report.for.headers.not.connected.to.paragraph.content_3-color_red.pdf)
[Docling bug report for headers not connected to paragraph content_mono.pdf](https://github.com/user-attachments/files/29073702/Docling.bug.report.for.headers.not.connected.to.paragraph.content_mono.pdf)
This bug report is about the layout (although this may be an interesting one for bold/emphasized text?)
### Steps to reproduce
Download attachments and run:
docling --to html_split_page INPUT_FILENAME
demo uses `html_split_page` for easy reviewing of problem.
End up with:
```## BUG REPORT
## FOR HEADERS AND PARAGRAPHS
Docling bug report for headers not connected to paragraph content
## First Header
## Second Header
## Third Header
Just a regular paragraph, note header is to the left BUT right aligned. This paragraph is justified but to the right of the header. There should be a line below.
Term: Yet more text. Not a lot, just a few sentences. Really tempting to use Ipsum here.
AnotherTerm: I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.
AnotherOne: This is a long paragraph. Yep, I'm about to copy and paste here. I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.
LastOne: Yet more text. Not a lot, just a few sentences. Really tempting to use Ipsum here.
Just a couple of paragraphs here. A few sentences each, longer than I really can be bothered to type here. I'm really getting bored typing this. No, more, please!
This is a long paragraph. but shortened to get a single page demo.
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
Expecting
```
## BUG REPORT
## FOR HEADERS AND PARAGRAPHS
Docling bug report for headers not connected to paragraph content
## First Header
Just a regular paragraph, note header is to the left BUT right aligned. This paragraph is justified but to the right of the header. There should be a line below.
## Second Header
Term: Yet more text. Not a lot, just a few sentences. Really tempting to use Ipsum here.
AnotherTerm: I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.
AnotherOne: This is a long paragraph. Yep, I'm about to copy and paste here. I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.I'm getting lazy. I may just copy and paste the rest to save me some time. I can't keep typing rubbish for ever.
LastOne: Yet more text. Not a lot, just a few sentences. Really tempting to use Ipsum here.
## Third Header
Just a couple of paragraphs here. A few sentences each, longer than I really can be bothered to type here. I'm really getting bored typing this. No, more, please!
This is a long paragraph. but shortened to get a single page demo.
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
### Docling version
Docling version: 2.102.1
Docling Core version: 2.82.0
Docling IBM Models version: 3.13.3
Docling Parse version: 6.2.0
Python: cpython-312 (3.12.5)
Platform: Windows-11-10.0.22631-SP0
### Python version
Python 3.12.5
Contributor guide
Research direction
Download the attached HTML and PDF samples, then run `docling --to html_split_page INPUT_FILENAME` to reproduce the misplaced header structure. Compare the generated output with the expected grouping in the issue; done means headers on the left are attached to the paragraph content on the right without disrupting other sections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100