Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: replace logging with loguru for improved logging functionality in OMML processing

myhlolib6fc07cf9e10
diff --git a/mineru/model/docx/tools/math/omml.py b/mineru/model/docx/tools/math/omml.py
index 886e03e2..454b00b0 100644
--- a/mineru/model/docx/tools/math/omml.py
+++ b/mineru/model/docx/tools/math/omml.py
@@ -4,10 +4,8 @@ Office Math Markup Language (OMML)
Adapted from https://github.com/xiilei/dwml/blob/master/dwml/omml.py
On 23/01/2025
"""
-
-import logging
-
import lxml.etree as ET
+from loguru import logger
from pylatexenc.latexencode import UnicodeToLatexEncoder
from .latex_dict import (
@@ -41,8 +39,6 @@ from .latex_dict import (
OMML_NS = "{http://schemas.openxmlformats.org/officeDocument/2006/math}"
-_log = logging.getLogger(__name__)
-
def load(stream):
tree = ET.parse(stream)
@@ -263,7 +259,7 @@ class oMath2Latex(Tag2Method):
pr = c_dict.get("fPr")
if pr is None:
# Handle missing fPr element gracefully
- _log.debug("Missing fPr element in fraction, using default formatting")
+ logger.debug("Missing fPr element in fraction, using default formatting")
latex_s = F_DEFAULT
return latex_s.format(
num=c_dict.get("num"),
@@ -290,7 +286,7 @@ class oMath2Latex(Tag2Method):
if FUNC.get(t):
latex_chars.append(FUNC[t])
else:
- _log.warning("Function not supported, will default to text: %s", t)
+ logger.warning("Function not supported, will default to text: %s", t)
if isinstance(t, str):
latex_chars.append(t)
elif isinstance(t, str):
diff --git a/pyproject.toml b/pyproject.toml
index ac7e75c8..fca99f87 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -41,7 +41,6 @@ dependencies = [
"magika>=0.6.2,<1.1.0",
"mineru-vl-utils>=0.1.19.1,<1",
"qwen-vl-utils>=0.0.14,<1",
- "defusedxml>=0.7.1,<1",
"python-docx>=1.2.0,<2",
"mammoth>=1.11.0,<2",
"pylatexenc>=2.10,<3"