mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-27 04:24:45 +00:00
Log warning message instead of print
Signed-off-by: Rafael Teixeira de Lima <Rafael.td.lima@gmail.com>
This commit is contained in:
parent
e7fc1a40ed
commit
4949471e50
@ -5,6 +5,8 @@ Adapted from https://github.com/xiilei/dwml/blob/master/dwml/omml.py
|
|||||||
On 23/01/2025
|
On 23/01/2025
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import lxml.etree as ET
|
import lxml.etree as ET
|
||||||
from pylatexenc.latexencode import UnicodeToLatexEncoder
|
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}"
|
OMML_NS = "{http://schemas.openxmlformats.org/officeDocument/2006/math}"
|
||||||
|
|
||||||
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def load(stream):
|
def load(stream):
|
||||||
tree = ET.parse(stream)
|
tree = ET.parse(stream)
|
||||||
@ -281,7 +285,7 @@ class oMath2Latex(Tag2Method):
|
|||||||
if FUNC.get(t):
|
if FUNC.get(t):
|
||||||
latex_chars.append(FUNC[t])
|
latex_chars.append(FUNC[t])
|
||||||
else:
|
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):
|
if isinstance(t, str):
|
||||||
latex_chars.append(t)
|
latex_chars.append(t)
|
||||||
elif isinstance(t, str):
|
elif isinstance(t, str):
|
||||||
@ -384,8 +388,6 @@ class oMath2Latex(Tag2Method):
|
|||||||
|
|
||||||
out_latex_str = self.u.unicode_to_latex(s)
|
out_latex_str = self.u.unicode_to_latex(s)
|
||||||
|
|
||||||
# print(s, out_latex_str)
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
s.startswith("{") is False
|
s.startswith("{") is False
|
||||||
and out_latex_str.startswith("{")
|
and out_latex_str.startswith("{")
|
||||||
@ -394,19 +396,13 @@ class oMath2Latex(Tag2Method):
|
|||||||
):
|
):
|
||||||
out_latex_str = f" {out_latex_str[1:-1]} "
|
out_latex_str = f" {out_latex_str[1:-1]} "
|
||||||
|
|
||||||
# print(s, out_latex_str)
|
|
||||||
|
|
||||||
if "ensuremath" in out_latex_str:
|
if "ensuremath" in out_latex_str:
|
||||||
out_latex_str = out_latex_str.replace("\\ensuremath{", " ")
|
out_latex_str = out_latex_str.replace("\\ensuremath{", " ")
|
||||||
out_latex_str = out_latex_str.replace("}", " ")
|
out_latex_str = out_latex_str.replace("}", " ")
|
||||||
|
|
||||||
# print(s, out_latex_str)
|
|
||||||
|
|
||||||
if out_latex_str.strip().startswith("\\text"):
|
if out_latex_str.strip().startswith("\\text"):
|
||||||
out_latex_str = f" \\text{{{out_latex_str}}} "
|
out_latex_str = f" \\text{{{out_latex_str}}} "
|
||||||
|
|
||||||
# print(s, out_latex_str)
|
|
||||||
|
|
||||||
return out_latex_str
|
return out_latex_str
|
||||||
|
|
||||||
def do_r(self, elm):
|
def do_r(self, elm):
|
||||||
|
Loading…
Reference in New Issue
Block a user