Skip to content

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

fix: reset instance state in DocxConverter and handle empty pages in PptxConverter

myhloli131a57eb95fd
diff --git a/mineru/model/docx/docx_converter.py b/mineru/model/docx/docx_converter.py
index 73cc3e20..b9fe0bd8 100644
--- a/mineru/model/docx/docx_converter.py
+++ b/mineru/model/docx/docx_converter.py
@@ -323,6 +323,19 @@ class DocxConverter:
self,
file_stream: BinaryIO,
):
+ # 重置所有实例状态,确保同一实例多次调用 convert() 时不会残留上次的数据
+ self.pages = []
+ self.cur_page = []
+ self.pre_num_id = -1
+ self.pre_ilevel = -1
+ self.list_block_stack = []
+ self.list_counters = {}
+ self.index_block_stack = []
+ self.pre_index_ilevel = -1
+ self.heading_list_numids = set()
+ self.chart_list = []
+ self.processed_textbox_elements = []
+
# 读取文件字节,以便 mammoth 和 python-docx 各自使用独立读取流
file_bytes = file_stream.read()
# 保存一份字节副本用于后续需要重新打开 ZIP 的方法
diff --git a/mineru/model/docx/tools/math/latex_dict.py b/mineru/model/docx/tools/math/latex_dict.py
index e7043f20..4c010c1b 100644
--- a/mineru/model/docx/tools/math/latex_dict.py
+++ b/mineru/model/docx/tools/math/latex_dict.py
@@ -88,7 +88,7 @@ T = {
"\U0001d6fc": "\\alpha ",
"\U0001d6fd": "\\beta ",
"\U0001d6fe": "\\gamma ",
- "\U0001d6ff": "\\theta ",
+ "\U0001d6ff": "\\delta ",
"\U0001d700": "\\epsilon ",
"\U0001d701": "\\zeta ",
"\U0001d702": "\\eta ",
@@ -96,15 +96,15 @@ T = {
"\U0001d704": "\\iota ",
"\U0001d705": "\\kappa ",
"\U0001d706": "\\lambda ",
- "\U0001d707": "\\m ",
- "\U0001d708": "\\n ",
+ "\U0001d707": "\\mu ",
+ "\U0001d708": "\\nu ",
"\U0001d709": "\\xi ",
"\U0001d70a": "\\omicron ",
"\U0001d70b": "\\pi ",
"\U0001d70c": "\\rho ",
"\U0001d70d": "\\varsigma ",
"\U0001d70e": "\\sigma ",
- "\U0001d70f": "\\ta ",
+ "\U0001d70f": "\\tau ",
"\U0001d710": "\\upsilon ",
"\U0001d711": "\\phi ",
"\U0001d712": "\\chi ",
@@ -121,7 +121,7 @@ T = {
"\u2190": "\\leftarrow ",
"\u2191": "\\uparrow ",
"\u2192": "\\rightarrow ",
- "\u2193": "\\downright ",
+ "\u2193": "\\downarrow ",
"\u2194": "\\leftrightarrow ",
"\u2195": "\\updownarrow ",
"\u2196": "\\nwarrow ",
diff --git a/mineru/model/pptx/pptx_converter.py b/mineru/model/pptx/pptx_converter.py
index 6e3999e1..8175811e 100644
--- a/mineru/model/pptx/pptx_converter.py
+++ b/mineru/model/pptx/pptx_converter.py
@@ -30,12 +30,15 @@ class PptxConverter:
self,
file_stream: BinaryIO,
):
+ self.pages = []
+ self.cur_page = []
+ self.list_block_stack = []
self.file_stream = file_stream
self.pptx_obj = Presentation(self.file_stream)
self.pages.append(self.cur_page)
if self.pptx_obj:
self._walk_linear(self.pptx_obj)
- if self.pages[-1] == []:
+ if self.pages and self.pages[-1] == []:
self.pages.pop()
def _walk_linear(self, pptx_obj: presentation.Presentation):