From 4949471e5029c17db3d92c2c36164dd3f3f80836 Mon Sep 17 00:00:00 2001 From: Rafael Teixeira de Lima Date: Tue, 8 Apr 2025 15:41:16 +0200 Subject: [PATCH] Log warning message instead of print Signed-off-by: Rafael Teixeira de Lima --- docling/backend/docx/latex/omml.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/docling/backend/docx/latex/omml.py b/docling/backend/docx/latex/omml.py index 52dade6f..b2d5f900 100644 --- a/docling/backend/docx/latex/omml.py +++ b/docling/backend/docx/latex/omml.py @@ -5,6 +5,8 @@ Adapted from https://github.com/xiilei/dwml/blob/master/dwml/omml.py On 23/01/2025 """ +import logging + import lxml.etree as ET from pylatexenc.latexencode import UnicodeToLatexEncoder @@ -39,6 +41,8 @@ from docling.backend.docx.latex.latex_dict import ( OMML_NS = "{http://schemas.openxmlformats.org/officeDocument/2006/math}" +_log = logging.getLogger(__name__) + def load(stream): tree = ET.parse(stream) @@ -281,7 +285,7 @@ class oMath2Latex(Tag2Method): if FUNC.get(t): latex_chars.append(FUNC[t]) else: - print(f"Function not supported, will default to text: {t}") + _log.warning("Function not supported, will default to text: %s", t) if isinstance(t, str): latex_chars.append(t) elif isinstance(t, str): @@ -384,8 +388,6 @@ class oMath2Latex(Tag2Method): out_latex_str = self.u.unicode_to_latex(s) - # print(s, out_latex_str) - if ( s.startswith("{") is False and out_latex_str.startswith("{") @@ -394,19 +396,13 @@ class oMath2Latex(Tag2Method): ): out_latex_str = f" {out_latex_str[1:-1]} " - # print(s, out_latex_str) - if "ensuremath" in out_latex_str: out_latex_str = out_latex_str.replace("\\ensuremath{", " ") out_latex_str = out_latex_str.replace("}", " ") - # print(s, out_latex_str) - if out_latex_str.strip().startswith("\\text"): out_latex_str = f" \\text{{{out_latex_str}}} " - # print(s, out_latex_str) - return out_latex_str def do_r(self, elm):