diff --git a/docling_core/experimental/doclang.py b/docling_core/experimental/doclang.py index 27b17085..9a9320f3 100644 --- a/docling_core/experimental/doclang.py +++ b/docling_core/experimental/doclang.py @@ -1515,6 +1515,11 @@ def _serialize_single_item( parts: list[str] = [] + if item.meta: + meta_res = doc_serializer.serialize_meta(item=item, **kwargs) + if meta_res.text: + parts.append(meta_res.text) + if params.add_location: # Use Doclang `` tokens instead of `` loc = _create_location_tokens_for_item(item=item, doc=doc, xres=params.xsize, yres=params.ysize) @@ -1524,11 +1529,6 @@ def _serialize_single_item( if selected_token: parts.append(selected_token) - if item.meta: - meta_res = doc_serializer.serialize_meta(item=item, **kwargs) - if meta_res.text: - parts.append(meta_res.text) - if ( (isinstance(item, CodeItem) and ContentType.TEXT_CODE in params.content_types) or (isinstance(item, FormulaItem) and ContentType.TEXT_FORMULA in params.content_types) diff --git a/test/data/doc/dummy_doc_with_meta.gt.dclg.xml b/test/data/doc/dummy_doc_with_meta.gt.dclg.xml index 4a4134d3..bf872d45 100644 --- a/test/data/doc/dummy_doc_with_meta.gt.dclg.xml +++ b/test/data/doc/dummy_doc_with_meta.gt.dclg.xml @@ -1,13 +1,13 @@ - <location value="43"/> - <location value="26"/> - <location value="415"/> - <location value="47"/> <meta> <summary>This is a title.</summary> <my_corp__foo>More stuff here.</my_corp__foo> </meta> + <location value="43"/> + <location value="26"/> + <location value="415"/> + <location value="47"/> DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis