diff --git a/docling/backend/md_backend.py b/docling/backend/md_backend.py index 669096e..eaf4753 100644 --- a/docling/backend/md_backend.py +++ b/docling/backend/md_backend.py @@ -368,6 +368,7 @@ class MarkdownDocumentBackend(DeclarativeDocumentBackend): # Start iterating from the root of the AST self.iterate_elements(parsed_ast, 0, doc, None) self.process_inline_text(None, doc) # handle last hanging inline text + self.close_table(doc=doc) # handle any last hanging table # if HTML blocks were detected, export to HTML and delegate to HTML backend if self._html_blocks > 0: diff --git a/tests/data/groundtruth/docling_v2/ending_with_table.md.md b/tests/data/groundtruth/docling_v2/ending_with_table.md.md new file mode 100644 index 0000000..9c179fe --- /dev/null +++ b/tests/data/groundtruth/docling_v2/ending_with_table.md.md @@ -0,0 +1,6 @@ +| Character | Name in German | Name in French | Name in Italian | +|----------------|------------------|------------------|-------------------| +| Scrooge McDuck | Dagobert Duck | Balthazar Picsou | Paperone | +| Huey | Tick | Riri | Qui | +| Dewey | Trick | Fifi | Quo | +| Louie | Track | Loulou | Qua | diff --git a/tests/data/md/ending_with_table.md b/tests/data/md/ending_with_table.md new file mode 100644 index 0000000..6c491d6 --- /dev/null +++ b/tests/data/md/ending_with_table.md @@ -0,0 +1,6 @@ +| Character | Name in German | Name in French | Name in Italian | +|---|---|---|---| +| Scrooge McDuck | Dagobert Duck | Balthazar Picsou | Paperone | +| Huey | Tick | Riri | Qui | +| Dewey | Trick | Fifi | Quo | +| Louie | Track | Loulou | Qua |