Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
fix: remove leading non-breaking spaces in LaTeX equations to prevent rendering issues
myhlolie91212fe040e
diff --git a/mineru/model/docx/docx_converter.py b/mineru/model/docx/docx_converter.pyindex 000b6c75..8d9f5e60 100644--- a/mineru/model/docx/docx_converter.py+++ b/mineru/model/docx/docx_converter.py@@ -626,6 +626,10 @@ class DocxConverter:elif 'oMath' in subt.tag and 'oMathPara' not in subt.tag:try:latex = str(oMath2Latex(subt)).strip()+ # 公式开头如果含有无法渲染的“~”符号(通常由文档中的NBSP产生),+ # 把它们移除,否则Markdown/LaTeX渲染会失败。+ if latex.startswith('~'):+ latex = latex.lstrip('~ ')if latex:items.append(self.equation_bookends.format(EQ=latex))except Exception as e:@@ -1151,6 +1155,8 @@ class DocxConverter:texts_and_equations.append(subt.text)elif "oMath" in subt.tag and "oMathPara" not in subt.tag:latex_equation = str(oMath2Latex(subt)).strip()+ if latex_equation.startswith('~'):+ latex_equation = latex_equation.lstrip('~ ')if len(latex_equation) > 0:only_equations.append(self.equation_bookends.format(EQ=latex_equation)diff --git a/mineru/model/docx/tools/math/omml.py b/mineru/model/docx/tools/math/omml.pyindex 8ea7d7b2..f95a5d24 100644--- a/mineru/model/docx/tools/math/omml.py+++ b/mineru/model/docx/tools/math/omml.py@@ -384,6 +384,12 @@ class oMath2Latex(Tag2Method):return bo + BLANK.join(res)def process_unicode(self, s):+ # treat non-breaking space as regular space to avoid LaTeX tilde (~)+ # NBSP frequently appears in formulas from Word and pylatexenc converts+ # it to "~" which later becomes "\~" and breaks rendering.+ if s == "\xa0":+ return " "+# Check T dictionary first for known math-mode symbols.# The T dictionary holds explicit math-mode LaTeX mappings and takes precedence# over pylatexenc, which uses text-mode mappings by default and therefore produces