File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
docling_core/types/legacy_doc Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments