4444 DocSerializer ,
4545 create_ser_result ,
4646)
47- from docling_core .types .doc . base import CoordOrigin
48- from docling_core . types . doc . document import (
47+ from docling_core .types .doc import (
48+ CoordOrigin ,
4949 DocItem ,
50+ DocItemLabel ,
5051 DoclingDocument ,
5152 FormItem ,
5253 InlineGroup ,
5354 KeyValueItem ,
5455 ListGroup ,
5556 NodeItem ,
5657 PictureItem ,
58+ ProvenanceItem ,
5759 RefItem ,
5860 RichTableCell ,
5961 TableItem ,
6062 TextItem ,
6163)
62- from docling_core .types .doc .labels import DocItemLabel
6364
6465
6566def _bbox_to_polygon_coords (
@@ -78,7 +79,7 @@ def _bbox_to_polygon_for_item(
7879 doc : DoclingDocument , item : DocItem
7980) -> Optional [list [float ]]:
8081 """Compute a TOPLEFT-origin polygon for the first provenance of the item."""
81- if not item .prov :
82+ if not item .prov or not isinstance ( item . prov [ 0 ], ProvenanceItem ) :
8283 return None
8384
8485 prov = item .prov [0 ]
@@ -189,7 +190,7 @@ def serialize(
189190
190191 # Lists may be represented either as TextItem(ListItem) or via groups;
191192 # we treat any TextItem as a paragraph-like entry.
192- if item .prov :
193+ if item .prov and isinstance ( item . prov [ 0 ], ProvenanceItem ) :
193194 prov = item .prov [0 ]
194195 page_no = prov .page_no
195196 polygon = _bbox_to_polygon_for_item (doc , item )
@@ -241,7 +242,7 @@ def serialize(
241242 ) -> SerializationResult :
242243 assert isinstance (doc_serializer , AzureDocSerializer )
243244
244- if not item .prov :
245+ if not item .prov or not isinstance ( item . prov [ 0 ], ProvenanceItem ) :
245246 return create_ser_result ()
246247
247248 prov = item .prov [0 ]
@@ -322,7 +323,7 @@ def serialize(
322323 ) -> SerializationResult :
323324 assert isinstance (doc_serializer , AzureDocSerializer )
324325
325- if not item .prov :
326+ if not item .prov or not isinstance ( item . prov [ 0 ], ProvenanceItem ) :
326327 return create_ser_result ()
327328
328329 prov = item .prov [0 ]
@@ -340,7 +341,11 @@ def serialize(
340341 for foot_ref in item .footnotes :
341342 if isinstance (foot_ref , RefItem ):
342343 tgt = foot_ref .resolve (doc )
343- if isinstance (tgt , TextItem ) and tgt .prov :
344+ if (
345+ isinstance (tgt , TextItem )
346+ and tgt .prov
347+ and isinstance (tgt .prov [0 ], ProvenanceItem )
348+ ):
344349 f_poly = _bbox_to_polygon_for_item (doc , tgt )
345350 if f_poly is not None :
346351 foots .append (
0 commit comments