diff --git a/src/python_docx_replace/paragraph.py b/src/python_docx_replace/paragraph.py index 3a63dd6..0b3f860 100644 --- a/src/python_docx_replace/paragraph.py +++ b/src/python_docx_replace/paragraph.py @@ -20,12 +20,12 @@ def get_all(doc) -> List[Any]: def _get_paragraphs(item: Any) -> Any: yield from item.paragraphs - # get paragraphs from tables + # get paragraphs from tables (including nested tables) for table in item.tables: for row in table.rows: for cell in row.cells: - for paragraph in cell.paragraphs: - yield paragraph + # Recursively get paragraphs from the cell (handles nested tables) + yield from Paragraph._get_paragraphs(cell) def __init__(self, p) -> None: self.p = p diff --git a/test/hello.docx b/test/hello.docx index b870cc0..fb94a96 100644 Binary files a/test/hello.docx and b/test/hello.docx differ