Fix test_backend_msword

Signed-off-by: Rafael Teixeira de Lima <Rafael.td.lima@gmail.com>
This commit is contained in:
Rafael Teixeira de Lima 2025-01-28 13:59:17 +01:00
parent b3b7c387ca
commit 7996dcbf3e

View File

@ -227,13 +227,16 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
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):