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
feat: change default json indent of doclib to 2
jinzhenje6f5e74c17cb
diff --git a/mineru/doclib/background/compaction.py b/mineru/doclib/background/compaction.pyindex 73d4132a..3b153b44 100644--- a/mineru/doclib/background/compaction.py+++ b/mineru/doclib/background/compaction.py@@ -238,7 +238,7 @@ class Compaction:payload: dict[str, Any] = {"schema_version": MIDDLE_JSON_SCHEMA_VERSION, "pages": json_pages}payload.update(envelope)with open(temp_path, "w", encoding="utf-8") as f:- json.dump(payload, f, ensure_ascii=False, indent=4)+ json.dump(payload, f, ensure_ascii=False, indent=2)prepared.append((temp_path, final_path))for temp_path, final_path in prepared:os.replace(temp_path, final_path)diff --git a/mineru/doclib/services/parse_svc.py b/mineru/doclib/services/parse_svc.pyindex 7ad89cae..6906c045 100644--- a/mineru/doclib/services/parse_svc.py+++ b/mineru/doclib/services/parse_svc.py@@ -1052,7 +1052,7 @@ class ParseService:os.makedirs(output_dir, exist_ok=True)_write_cached_image_sidecars(parse_image_sidecar_dir(self.data_dir, sha256, tier), result.images())with open(json_path, "w", encoding="utf-8") as f:- json.dump(export_payload, f, ensure_ascii=False, indent=4)+ json.dump(export_payload, f, ensure_ascii=False, indent=2)except Exception as exc:logger.error("Parse post-write finalization failed for task_id=%s path=%s tier=%s page_range=%s: %s",diff --git a/mineru/parser/base.py b/mineru/parser/base.pyindex ac8c40ea..c75c7685 100644--- a/mineru/parser/base.py+++ b/mineru/parser/base.py@@ -185,7 +185,7 @@ class ParseResult:def to_dict(self, *, skip_defaults: bool = True) -> dict[str, Any]:payload: dict[str, Any] = {"schema_version": MIDDLE_JSON_SCHEMA_VERSION}- payload.update(self.middle_json.to_dict(skip_defaults=skip_defaults))+ payload.update(self.middle_json.to_dict(skip_defaults=skip_defaults, exclude_block_fields={"image_base64"}))if self._retained_page_indices is not None:payload[_PDF_RETAINED_PAGE_INDICES_KEY] = list(self._retained_page_indices)if self._broken_page_indices:@@ -200,7 +200,7 @@ class ParseResult:return ParseResult.from_dict(data)def to_json(self) -> str:- return json.dumps(self.to_dict(), ensure_ascii=False, indent=4)+ return json.dumps(self.to_dict(), ensure_ascii=False, indent=2)def markdown(self,@@ -228,7 +228,7 @@ class ParseResult:writer.write_string("structured_content.json",- json.dumps(self.structured_content(), ensure_ascii=False, indent=4),+ json.dumps(self.structured_content(), ensure_ascii=False, indent=2),)if self._model_output is not None:@@ -239,7 +239,7 @@ class ParseResult:)writer.write_string("model_output.json",- json.dumps(model_output, ensure_ascii=False, indent=4),+ json.dumps(model_output, ensure_ascii=False, indent=2),)for img_path, img_bytes in self.images().items():