docling-project / docling-project/docling
Broken nested lists and numbering
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
Docling fails to preserve nested lists from PDFs.
- All list items become flattened, losing hierarchy.
- Numbering is often incorrect.
- Ordered vs unordered sub-lists are misdetected.
### Steps to reproduce
1. Convert a PDF with nested lists using docling
2. Compare output with the source file
I used this pipeline on my MacBook Pro M1
```python
import os
from docling.datamodel.base_models import InputFormat
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.pipeline_options import EasyOcrOptions, PdfPipelineOptions
os.environ["DOCLING_NUM_THREADS"] = "8"
os.environ["DOCLING_DEVICE"] = "mps"
os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0"
pipeline_options = PdfPipelineOptions(
do_ocr=True,
ocr_options=EasyOcrOptions(force_full_page_ocr=True),
)
def process(file_path: str):
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=pipeline_options,
)
}
)
doc = converter.convert(source=file_path).document
# save converted formats
doc_output_dir = "./output"
doc.save_as_doctags(os.path.join(doc_output_dir, "docling.txt"))
doc.save_as_markdown(os.path.join(doc_output_dir, "docling.md"))
doc.save_as_yaml(os.path.join(doc_output_dir, "docling.yaml"))
doc.save_as_html(os.path.join(doc_output_dir, "docling.html"))
doc.save_as_json(os.path.join(doc_output_dir, "docling.json"))
if __name__ == "__main__":
src = "./nested_lists_example.pdf"
process(src)
```
Original PDF:
[nested_lists_example.pdf](https://github.com/user-attachments/files/22678764/nested_lists_example.pdf)
### Docling version
Docling version: 2.55.0
Docling Core version: 2.48.4
Docling IBM Models version: 3.9.1
Docling Parse version: 4.5.0
Python: cpython-313 (3.13.7)
Platform: macOS-15.7.1-arm64-arm-64bit-Mach-O
### Python version
Python 3.13.7
Contributor guide
Assessment
This issue has not been assessed yet.