Skip to content

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

feat: enhance DOCX header and footer processing by adding deduplication for inline equations and hyperlinks

myhloli9137f8459157
diff --git a/mineru/model/docx/docx_converter.py b/mineru/model/docx/docx_converter.py
index 4429023a..01661423 100644
--- a/mineru/model/docx/docx_converter.py
+++ b/mineru/model/docx/docx_converter.py
@@ -1188,10 +1188,14 @@ class DocxConverter:
"""
处理页眉和页脚,按照分节顺序添加到 pages 列表中,过滤掉空字符串和纯数字内容
分为整个文档是否启用奇偶页不同和每一节是否启用首页不同两种情况,
- 支持行内公式和超链接
+ 支持行内公式和超链接,并根据类型去重
"""
is_odd_even_different = docx_obj.settings.odd_and_even_pages_header_footer
for sec_idx, section in enumerate(docx_obj.sections):
+ # 用于去重的集合
+ added_headers = set()
+ added_footers = set()
+
hdrs = [section.header]
if is_odd_even_different:
hdrs.append(section.even_page_header)
@@ -1205,7 +1209,8 @@ class DocxConverter:
if content:
processed_parts.append(content)
text = " ".join(processed_parts)
- if text != "" and not text.isdigit():
+ if text != "" and not text.isdigit() and text not in added_headers:
+ added_headers.add(text)
try:
self.pages[sec_idx].append(
{
@@ -1229,7 +1234,8 @@ class DocxConverter:
if content:
processed_parts.append(content)
text = " ".join(processed_parts)
- if text != "" and not text.isdigit():
+ if text != "" and not text.isdigit() and text not in added_footers:
+ added_footers.add(text)
try:
self.pages[sec_idx].append(
{