Skip to content

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

feat: add error handling for chart HTML extraction to improve robustness

myhloli9b8b99cfbbc2
diff --git a/mineru/backend/utils/office_chart.py b/mineru/backend/utils/office_chart.py
index 0cc3d715..46082e14 100644
--- a/mineru/backend/utils/office_chart.py
+++ b/mineru/backend/utils/office_chart.py
@@ -663,6 +663,8 @@ def _first_non_none(*values):
def _collect_plot_elements(plot_area) -> list[tuple[str, Any]]:
plot_elements = []
for child in plot_area:
+ if not isinstance(child.tag, str):
+ continue
tag_name = etree.QName(child).localname
if tag_name in _PLOT_TAGS:
plot_elements.append((tag_name, child))
diff --git a/mineru/model/docx/docx_converter.py b/mineru/model/docx/docx_converter.py
index 7a5b3909..4124fa93 100644
--- a/mineru/model/docx/docx_converter.py
+++ b/mineru/model/docx/docx_converter.py
@@ -2599,7 +2599,11 @@ class DocxConverter:
except Exception as e:
logger.warning(f"Warning: chart workbook cannot be loaded: {e}")
- chart_html = extract_chart_html_from_ooxml(chart_xml, workbook_bytes)
+ try:
+ chart_html = extract_chart_html_from_ooxml(chart_xml, workbook_bytes)
+ except Exception as e:
+ logger.warning(f"Warning: chart HTML cannot be extracted: {e}")
+ continue
if chart_html:
chart_block["content"] = chart_html