Skip to content

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

Preserve search snippet matches

jinzhenj24bc831a3c2d
diff --git a/mineru/cli/output.py b/mineru/cli/output.py
index 3d8e58e3..fd6ee56f 100644
--- a/mineru/cli/output.py
+++ b/mineru/cli/output.py
@@ -67,7 +67,7 @@ def _format_result_path(paths: Any) -> str:
def _format_snippet(snippet: Any) -> str:
- return str(snippet or "").replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ")[:80]
+ return str(snippet or "").replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ")
# ── parse ──────────────────────────────────────────────────────
diff --git a/tests/unittest/test_cli_next_command_design.py b/tests/unittest/test_cli_next_command_design.py
index d299ae6f..0adda4e4 100644
--- a/tests/unittest/test_cli_next_command_design.py
+++ b/tests/unittest/test_cli_next_command_design.py
@@ -183,6 +183,37 @@ def test_search_results_render_as_list_without_table(monkeypatch: Any) -> None:
assert not hasattr(printed[0], "columns")
+def test_search_result_snippet_preserves_fts_match_after_long_prefix(monkeypatch: Any) -> None:
+ printed: list[Any] = []
+
+ class _Console:
+ def print(self, item: Any, *args: Any, **kwargs: Any) -> None:
+ printed.append(item)
+
+ monkeypatch.setattr(output_mod, "console", _Console())
+
+ output_mod.format_search_results(
+ {
+ "total": 1,
+ "results": [
+ {
+ "filename": "deepseek.pdf",
+ "tier": "flash",
+ "snippet": (
+ "...on each node. Under this constraint, our MoE training framework can nearly "
+ "achieve full computation-communication overlap. <mark>Token</mark> <mark>Dropping</mark>"
+ ),
+ "paths": ["/tmp/deepseek.pdf"],
+ }
+ ],
+ }
+ )
+
+ rendered = str(printed[0])
+ assert "<mark>Token</mark>" in rendered
+ assert "<mark>Dropping</mark>" in rendered
+
+
def test_server_status_renders_separate_recent_log_panels(monkeypatch: Any) -> None:
printed: list[Any] = []
panels: list[dict[str, Any]] = []