Skip to content

Commit b116c46

Browse files
authored
fix: Fixes for legacy-doc handling (#115)
* Fixes for legacy-doc handling Signed-off-by: Christoph Auer <[email protected]> * Fixes for legacy-doc handling Signed-off-by: Christoph Auer <[email protected]> --------- Signed-off-by: Christoph Auer <[email protected]>
1 parent ee49c60 commit b116c46

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

docling_core/types/legacy_doc/document.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -550,17 +550,18 @@ def export_to_markdown( # noqa: C901
550550

551551
elif (
552552
isinstance(item, Table)
553-
and item.data
553+
and (item.data or item.text)
554554
and item_type in main_text_labels
555555
):
556556

557557
md_table = ""
558558
table = []
559-
for row in item.data:
560-
tmp = []
561-
for col in row:
562-
tmp.append(col.text)
563-
table.append(tmp)
559+
if item.data is not None:
560+
for row in item.data:
561+
tmp = []
562+
for col in row:
563+
tmp.append(col.text)
564+
table.append(tmp)
564565

565566
if len(table) > 1 and len(table[0]) > 0:
566567
try:
@@ -579,15 +580,19 @@ def export_to_markdown( # noqa: C901
579580
if item.text:
580581
markdown_text = item.text
581582
if not strict_text:
582-
markdown_text += "\n\n" + md_table
583+
markdown_text += (
584+
"\n\n" if len(markdown_text) > 0 else ""
585+
) + md_table
583586

584587
elif isinstance(item, Figure) and item_type in main_text_labels:
585588

586589
markdown_text = ""
587590
if item.text:
588591
markdown_text = item.text
589592
if not strict_text:
590-
markdown_text += f"\n{image_placeholder}"
593+
markdown_text += (
594+
"\n" if len(markdown_text) > 0 else ""
595+
) + image_placeholder
591596

592597
if markdown_text:
593598
md_texts.append(markdown_text)

0 commit comments

Comments
 (0)