Skip to content

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

feat: refactor finalize_middle_json to support server-side post-processing and enhance title leveling

myhloli4bae02c2951f
diff --git a/mineru/backend/hybrid/hybrid_analyze.py b/mineru/backend/hybrid/hybrid_analyze.py
index 0c84c455..da70bbbd 100644
--- a/mineru/backend/hybrid/hybrid_analyze.py
+++ b/mineru/backend/hybrid/hybrid_analyze.py
@@ -989,7 +989,8 @@ async def aio_doc_analyze(
)
if client_side_output_generation:
- apply_server_side_postprocess(
+ await asyncio.to_thread(
+ apply_server_side_postprocess,
middle_json["pdf_info"],
hybrid_pipeline_model,
_ocr_enable,
diff --git a/mineru/cli/client.py b/mineru/cli/client.py
index d90727d3..0af1f7d6 100644
--- a/mineru/cli/client.py
+++ b/mineru/cli/client.py
@@ -820,7 +820,11 @@ async def run_planned_task(
parse_method,
is_office=document.suffix in office_suffixes,
)
- regenerate_client_side_outputs(parse_dir, document.stem)
+ await asyncio.to_thread(
+ regenerate_client_side_outputs,
+ parse_dir,
+ document.stem,
+ )
completed_tasks, completed_pages = await mark_task_completed(
progress,
planned_task.total_pages,
diff --git a/mineru/cli/gradio_app.py b/mineru/cli/gradio_app.py
index b3ff0c54..509a3095 100644
--- a/mineru/cli/gradio_app.py
+++ b/mineru/cli/gradio_app.py
@@ -1073,8 +1073,9 @@ async def _run_to_markdown_job(
parse_method,
allow_office_fallback=True,
)
+ emit_status(STATUS_PROCESSING_OUTPUT)
if use_client_side_output_generation:
- regenerate_client_side_outputs(local_md_dir, file_name)
+ await asyncio.to_thread(regenerate_client_side_outputs, local_md_dir, file_name)
preview_pdf_path = maybe_generate_local_preview(
extract_root=extract_root,
@@ -1084,7 +1085,6 @@ async def _run_to_markdown_job(
parse_method=parse_method,
)
- emit_status(STATUS_PROCESSING_OUTPUT)
zip_archive_success = compress_directory_to_zip(local_md_dir, archive_zip_path)
if zip_archive_success == 0:
logger.info('Compression successful')