Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions docling/backend/msword_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,15 +1032,18 @@ def _handle_text_elements(
if (paragraph.text is None or len(paragraph.text.strip()) == 0) and len(
text
) > 0:
# Standalone equation
# Standalone equation(s) - create separate formula items for each equation
level = self._get_level()
t1 = doc.add_text(
label=DocItemLabel.FORMULA,
parent=self.parents[level - 1],
text=text.replace("<eq>", "").replace("</eq>", ""),
content_layer=self.content_layer,
)
elem_ref.append(t1.get_ref())
for eq in equations:
eq_text = eq.replace("<eq>", "").replace("</eq>", "").strip()
if eq_text:
t1 = doc.add_text(
label=DocItemLabel.FORMULA,
parent=self.parents[level - 1],
text=eq_text,
content_layer=self.content_layer,
)
elem_ref.append(t1.get_ref())
Comment on lines +1035 to +1046
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you are trying to solve another issue, different from the one you linked this PR to.
Could you please create a separate issue describing it?

else:
# Inline equation
level = self._get_level()
Expand Down Expand Up @@ -1458,8 +1461,13 @@ def _handle_tables(
provs_in_cell: list[RefItem] = []
rich_table_cell: bool = self._is_rich_table_cell(cell)

# Save parent state before processing rich cell content
# to prevent table cell content from affecting the document hierarchy
original_parents = self.parents.copy()
if rich_table_cell:
_, provs_in_cell = self._walk_linear(cell._element, doc)
# Restore parent state after processing rich cell content
self.parents = original_parents
_log.debug(f"Table cell {row_idx},{col_idx} rich? {rich_table_cell}")

if len(provs_in_cell) > 0:
Expand Down
Loading