Skip to content

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

feat: update JSON output formatting to use 4-space indentation for improved readability

myhlolieb7a6390fd57
diff --git a/mineru/cli_old/common.py b/mineru/cli_old/common.py
index 82068ae7..b4d14792 100644
--- a/mineru/cli_old/common.py
+++ b/mineru/cli_old/common.py
@@ -278,13 +278,13 @@ def _process_output(
dump_dict["_version_name"] = __version__
md_writer.write_string(
f"{pdf_file_name}_middle.json",
- json.dumps(dump_dict, ensure_ascii=False, indent=1),
+ json.dumps(dump_dict, ensure_ascii=False, indent=4),
)
if f_dump_model_output:
md_writer.write_string(
f"{pdf_file_name}_model.json",
- json.dumps(model_output, ensure_ascii=False, indent=1),
+ json.dumps(model_output, ensure_ascii=False, indent=4),
)
logger.debug(f"local output dir is {local_md_dir}")
diff --git a/mineru/doclib/background/compaction.py b/mineru/doclib/background/compaction.py
index 39c939ed..048cd3f1 100644
--- a/mineru/doclib/background/compaction.py
+++ b/mineru/doclib/background/compaction.py
@@ -167,6 +167,6 @@ class Compaction:
json_path = parse_batch_json_path(self.data_dir, sha256, tier, page_range, max_done_at)
try:
with open(json_path, "w", encoding="utf-8") as f:
- json.dump({"schema_version": MIDDLE_JSON_SCHEMA_VERSION, "pages": json_pages}, f, ensure_ascii=False, indent=1)
+ json.dump({"schema_version": MIDDLE_JSON_SCHEMA_VERSION, "pages": json_pages}, f, ensure_ascii=False, indent=4)
except Exception:
pass
diff --git a/mineru/doclib/services/parse_svc.py b/mineru/doclib/services/parse_svc.py
index db4aead9..5668cf8c 100644
--- a/mineru/doclib/services/parse_svc.py
+++ b/mineru/doclib/services/parse_svc.py
@@ -777,7 +777,7 @@ class ParseService:
try:
os.makedirs(output_dir, exist_ok=True)
with open(json_path, "w", encoding="utf-8") as f:
- json.dump({"schema_version": MIDDLE_JSON_SCHEMA_VERSION, "pages": new_pages}, f, ensure_ascii=False, indent=1)
+ json.dump({"schema_version": MIDDLE_JSON_SCHEMA_VERSION, "pages": new_pages}, f, ensure_ascii=False, indent=4)
except Exception as exc:
await self._fail_task(task["id"], "parse_json_write_failed", str(exc)[:500])
return False
diff --git a/mineru/parser/base.py b/mineru/parser/base.py
index 774e2621..f333d517 100644
--- a/mineru/parser/base.py
+++ b/mineru/parser/base.py
@@ -66,7 +66,7 @@ class ParseResult:
return ParseResult.from_dict(data)
def to_json(self) -> str:
- return json.dumps(self.to_dict(), ensure_ascii=False, indent=1)
+ return json.dumps(self.to_dict(), ensure_ascii=False, indent=4)
def markdown(self, *, add_markers: bool = False) -> str:
return render_markdown(self.pages, add_markers=add_markers)
@@ -83,17 +83,17 @@ class ParseResult:
writer.write_string(
"content_list.json",
- json.dumps(self.content_list(), ensure_ascii=False, indent=1),
+ json.dumps(self.content_list(), ensure_ascii=False, indent=4),
)
writer.write_string(
"structured_content.json",
- json.dumps(self.structured_content(), ensure_ascii=False, indent=1),
+ json.dumps(self.structured_content(), ensure_ascii=False, indent=4),
)
if self._model_output is not None:
writer.write_string(
"model_output.json",
- json.dumps(self._model_output, ensure_ascii=False, indent=1),
+ json.dumps(self._model_output, ensure_ascii=False, indent=4),
)
for img_path, img_bytes in self.images().items():