Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docling_core/transforms/serializer/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def _serialize_image_part(
doc: DoclingDocument,
image_mode: ImageRefMode,
image_placeholder: str,
image_join_text: str = "\n",
**kwargs: Any,
) -> SerializationResult:
error_response = (
Expand Down Expand Up @@ -457,6 +458,12 @@ def _serialize_image_part(
text_res = image_placeholder
else:
text_res = f"![Image]({str(item.image.uri)})"
elif image_mode == ImageRefMode.INLINE:
total_text = []
for item, level in doc.iterate_items(root=item, traverse_pictures=True):
if isinstance(item, TextItem):
total_text.append(item.text)
text_res = image_join_text.join(total_text) if total_text else image_placeholder
else:
text_res = image_placeholder

Expand Down
1 change: 1 addition & 0 deletions docling_core/types/doc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ImageRefMode(str, Enum):
PLACEHOLDER = "placeholder" # just a place-holder
EMBEDDED = "embedded" # embed the image as a base64
REFERENCED = "referenced" # reference the image via uri
INLINE = "inline" # inline the image OCR content directly in the document


class CoordOrigin(str, Enum):
Expand Down