Skip to content

Commit

Permalink
Fix test_backend_msword
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Teixeira de Lima <[email protected]>
  • Loading branch information
rateixei committed Jan 28, 2025
1 parent b3b7c38 commit 7996dcb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docling/backend/msword_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,16 @@ def handle_equations_in_text(self, element, text):
only_texts = []
texts_and_equations = []
for subt in element.iter():
if subt.tag.endswith("t") and "math" not in subt.tag:
tag_name = etree.QName(subt).localname
if tag_name == "t" and "math" not in subt.tag:
only_texts.append(subt.text)
texts_and_equations.append(subt.text)
if "oMath" in subt.tag and "oMathPara" not in subt.tag:
elif "oMath" in subt.tag and "oMathPara" not in subt.tag:
texts_and_equations.append(f"${str(oMath2Latex(subt))}$")

assert "".join(only_texts) == text
if "".join(only_texts) != text:
return text

return "".join(texts_and_equations)

def handle_text_elements(self, element, docx_obj, doc):
Expand Down

0 comments on commit 7996dcb

Please sign in to comment.