Skip to content

Commit ab78e0b

Browse files
authored
fix: fix page filtering issue (#247)
Signed-off-by: Panos Vagenas <[email protected]>
1 parent 26f639d commit ab78e0b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

docling_core/experimental/serializer/doctags.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,9 @@ def serialize(
394394
if parts:
395395
text_res = delim.join(
396396
[
397-
_wrap(text=p.text, wrap_tag=DocumentToken.LIST_ITEM.value)
397+
t
398398
for p in parts
399+
if (t := _wrap(text=p.text, wrap_tag=DocumentToken.LIST_ITEM.value))
399400
]
400401
)
401402
text_res = f"{text_res}{delim}"
@@ -480,7 +481,7 @@ def serialize_page(
480481
) -> SerializationResult:
481482
"""Serialize a page out of its parts."""
482483
delim = _get_delim(params=self.params)
483-
text_res = delim.join([p.text for p in parts])
484+
text_res = delim.join([p.text for p in parts if p.text])
484485
return create_ser_result(text=text_res, span_source=parts)
485486

486487
@override

docling_core/experimental/serializer/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ def serialize(
691691
)
692692

693693
# Join all parts without separators
694-
inline_html = " ".join([p.text for p in parts])
694+
inline_html = " ".join([p.text for p in parts if p.text])
695695

696696
# Wrap in span if needed
697697
if inline_html:

docling_core/experimental/serializer/markdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def serialize_page(
520520
self, *, parts: list[SerializationResult], **kwargs
521521
) -> SerializationResult:
522522
"""Serialize a page out of its parts."""
523-
text_res = "\n\n".join([p.text for p in parts])
523+
text_res = "\n\n".join([p.text for p in parts if p.text])
524524
return create_ser_result(text=text_res, span_source=parts)
525525

526526
@override

0 commit comments

Comments
 (0)