docling-project / docling-project/docling-core
Export to markdown not respecting page_no
- Dominant language
- HTML
- Stars
- 282
- Forks
- 214
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 21
Description
Hi, I was upgrading our export to markdown to use the new `MarkdownDocSerializer` and noticed that it got a bit slow
I debug a bit and I think that in the `iterate_items` we could include the `page_no`. This makes it way faster for me as I only want to export certain pages.
Happy to raise a PR just not sure because the iterate items is expecting a `page_no` and we have a set there. Maybe we want to change the iterate to also support a set? or then the set might not make much sense and we could just store the `page_no`
```
class DocSerializer(BaseModel, BaseDocSerializer):
def _serialize_body(self) -> SerializationResult:
"""Serialize the document body."""
# find page ranges if available; otherwise regard whole doc as a single page
last_page: Optional[int] = None
starts: list[int] = []
for ix, (item, _) in enumerate(
self.doc.iterate_items(
with_groups=True,
traverse_pictures=True,
included_content_layers=self.params.layers,
page_no # we could add it ?
)
):
```
Contributor guide
Assessment
This issue has not been assessed yet.