Repository: DS4SD/docling
Issue category: Bug Report

Missing Text Inside Tables When Converting from DOCX to Markdown
### Bug
I've encountered an issue with Docling version 2.4.2 while converting a DOCX file to Markdown. It seems that the conversion process is missing text inside tables.

**Command Used:**
```sh
docling example.docx --from docx --to md --table-mode accurate
```

### Steps to reproduce

1. Use the attached example DOCX file.
2. Run the above command to convert the DOCX file to Markdown.
3. Open the resulting Markdown file and check the tables.

**Expected Behavior:**
The text inside the tables should be accurately converted and included in the Markdown output.

**Actual Behavior:**
The text inside the tables is missing in the Markdown output.

**Attachments:**
- [example.docx](https://github.com/user-attachments/files/17692190/example.docx)

I appreciate your assistance in resolving this issue.
Thank you!


### Docling version
Docling version: 2.4.2
Docling Core version: 2.3.1
Docling IBM Models version: 2.0.3
Docling Parse version: 2.0.3
...

### Python version
Python 3.12.7
...


Functions to edit:
docling/backend/msword_backend.py:MsWordDocumentBackend.handle_tables

Patch:
diff --git a/docling/backend/msword_backend.py b/docling/backend/msword_backend.py
index 08529ea0..eb7b75cb 100644
--- a/docling/backend/msword_backend.py
+++ b/docling/backend/msword_backend.py
@@ -130,7 +130,6 @@ def get_level(self) -> int:
     def walk_linear(self, body, docx_obj, doc) -> DoclingDocument:
         for element in body:
             tag_name = etree.QName(element).localname
-
             # Check for Inline Images (drawings or blip elements)
             found_drawing = etree.ElementBase.xpath(
                 element, ".//w:drawing", namespaces=self.xml_namespaces
@@ -201,7 +200,6 @@ def get_label_and_level(self, paragraph):
             label_str = ""
             label_level = 0
             if parts[0] == "Heading":
-                # print("{} - {}".format(parts[0], parts[1]))
                 label_str = parts[0]
                 label_level = self.str_to_int(parts[1], default=None)
             if parts[1] == "Heading":
@@ -217,19 +215,16 @@ def handle_text_elements(self, element, docx_obj, doc):
         if paragraph.text is None:
             # _log.warn(f"paragraph has text==None")
             return
-
         text = paragraph.text.strip()
         # if len(text)==0 # keep empty paragraphs, they seperate adjacent lists!
 
         # Common styles for bullet and numbered lists.
         # "List Bullet", "List Number", "List Paragraph"
-        # TODO: reliably identify wether list is a numbered list or not
+        # Identify wether list is a numbered list or not
         # is_numbered = "List Bullet" not in paragraph.style.name
         is_numbered = False
-
         p_style_name, p_level = self.get_label_and_level(paragraph)
         numid, ilevel = self.get_numId_and_ilvl(paragraph)
-        # print("numid: {}, ilevel: {}, text: {}".format(numid, ilevel, text))
 
         if numid == 0:
             numid = None
@@ -450,8 +445,13 @@ def get_rowspan(cell):
         for row in table.rows:
             # Calculate the max number of columns
             num_cols = max(num_cols, sum(get_colspan(cell) for cell in row.cells))
-            # if row.cells:
-            #     num_cols = max(num_cols, len(row.cells))
+
+        if num_rows == 1 and num_cols == 1:
+            cell_element = table.rows[0].cells[0]
+            # In case we have a table of only 1 cell, we consider it furniture
+            # And proceed processing the content of the cell as though it's in the document body
+            self.walk_linear(cell_element._element, docx_obj, doc)
+            return
 
         # Initialize the table grid
         table_grid = [[None for _ in range(num_cols)] for _ in range(num_rows)]

Test patch: diff --git a/tests/data/docx/tablecell.docx b/tests/data/docx/tablecell.docx
new file mode 100644
index 00000000..6fa7f017
Binary files /dev/null and b/tests/data/docx/tablecell.docx differ