Skip to content

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

feat: add popover menus for model and paper links in Gradio header

myhlolie382100c38c8
diff --git a/mineru/cli_old/gradio_app.py b/mineru/cli_old/gradio_app.py
index 883b8e17..b56f7e89 100644
--- a/mineru/cli_old/gradio_app.py
+++ b/mineru/cli_old/gradio_app.py
@@ -1476,7 +1476,12 @@ HEADER_I18N_PLACEHOLDERS = {
"{{HEADER_STARS_ALT}}": "header_stars_alt",
"{{HEADER_CODE_LINK}}": "header_code_link",
"{{HEADER_MODEL_LINK}}": "header_model_link",
+ "{{HEADER_MODEL_HUGGINGFACE_LINK}}": "header_model_huggingface_link",
+ "{{HEADER_MODEL_MODELSCOPE_LINK}}": "header_model_modelscope_link",
"{{HEADER_PAPER_LINK}}": "header_paper_link",
+ "{{HEADER_PAPER_MINERU_REPORT}}": "header_paper_mineru_report",
+ "{{HEADER_PAPER_MINERU25_REPORT}}": "header_paper_mineru25_report",
+ "{{HEADER_PAPER_MINERU25PRO_REPORT}}": "header_paper_mineru25pro_report",
"{{HEADER_HOMEPAGE_LINK}}": "header_homepage_link",
"{{HEADER_DOWNLOAD_LINK}}": "header_download_link",
}
@@ -1733,7 +1738,12 @@ def main(ctx,
"header_stars_alt": "stars",
"header_code_link": "Code",
"header_model_link": "Model",
+ "header_model_huggingface_link": "Hugging Face",
+ "header_model_modelscope_link": "ModelScope",
"header_paper_link": "Paper",
+ "header_paper_mineru_report": "MinerU · arXiv: 2409.18839",
+ "header_paper_mineru25_report": "MinerU 2.5 · arXiv: 2509.22186",
+ "header_paper_mineru25pro_report": "MinerU 2.5 Pro · arXiv: 2604.04771",
"header_homepage_link": "Homepage",
"header_download_link": "Download",
"max_pages": "Max convert pages",
@@ -1779,7 +1789,12 @@ def main(ctx,
"header_stars_alt": "GitHub 星标",
"header_code_link": "代码",
"header_model_link": "模型",
+ "header_model_huggingface_link": "Hugging Face",
+ "header_model_modelscope_link": "ModelScope",
"header_paper_link": "论文",
+ "header_paper_mineru_report": "MinerU · arXiv: 2409.18839",
+ "header_paper_mineru25_report": "MinerU 2.5 · arXiv: 2509.22186",
+ "header_paper_mineru25pro_report": "MinerU 2.5 Pro · arXiv: 2604.04771",
"header_homepage_link": "主页",
"header_download_link": "下载",
"max_pages": "最大转换页数",
@@ -1873,7 +1888,7 @@ def main(ctx,
suffixes = [f".{suffix}" for suffix in pdf_suffixes + image_suffixes + office_suffixes]
_blocks_kwargs = {} if IS_GRADIO_6 else {"css": APP_CSS, "js": APP_JS}
with gr.Blocks(**_blocks_kwargs) as demo:
- gr.HTML(render_header_html(i18n))
+ gr.HTML(render_header_html(i18n), elem_classes=["mineru-header-html"])
with gr.Row(elem_classes=["mineru-workspace-row"]):
with gr.Column(variant='panel', scale=2, min_width=280, elem_classes=["mineru-control-column"]):
input_file = gr.File(
diff --git a/mineru/resources/gradio_header.html b/mineru/resources/gradio_header.html
index 44fb9fd1..590b2ac9 100644
--- a/mineru/resources/gradio_header.html
+++ b/mineru/resources/gradio_header.html
@@ -23,6 +23,93 @@
.external-link:hover {
cursor: pointer !important;
}
+ .mineru-header-menu {
+ position: relative;
+ }
+ .block.mineru-header-html,
+ .block.mineru-header-html .html-container,
+ .block.mineru-header-html .prose {
+ overflow: visible !important;
+ position: relative !important;
+ z-index: 100 !important;
+ }
+ .mineru-demo-header .mineru-header-trigger {
+ appearance: none;
+ font: inherit;
+ display: inline-flex;
+ align-items: center;
+ height: 36px;
+ line-height: 36px;
+ padding: 0 16px !important;
+ margin: 0;
+ background: transparent !important;
+ border: 0;
+ border-color: transparent !important;
+ }
+ .mineru-header-trigger:hover,
+ .mineru-header-trigger:focus,
+ .mineru-header-trigger:focus-visible,
+ .mineru-header-trigger:active {
+ background: transparent !important;
+ border-color: transparent !important;
+ color: #ffffff !important;
+ outline: none !important;
+ box-shadow: none !important;
+ }
+ .mineru-header-menu::after {
+ content: "";
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 100%;
+ height: 12px;
+ }
+ .mineru-header-popover {
+ position: absolute;
+ left: 50%;
+ top: calc(100% + 10px);
+ z-index: 20;
+ width: 280px;
+ max-width: calc(100vw - 48px);
+ padding: 8px;
+ border: 1px solid rgba(255, 255, 255, 0.18);
+ border-radius: 8px;
+ background: rgba(17, 24, 39, 0.82);
+ backdrop-filter: blur(10px);
+ box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
+ opacity: 0;
+ pointer-events: none;
+ transform: translate(-50%, 8px);
+ transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
+ visibility: hidden;
+ }
+ .mineru-model-popover {
+ width: 160px;
+ }
+ .mineru-header-menu:hover .mineru-header-popover,
+ .mineru-header-menu:focus-within .mineru-header-popover {
+ opacity: 1;
+ pointer-events: auto;
+ transform: translate(-50%, 0);
+ visibility: visible;
+ }
+ .mineru-demo-header .mineru-header-popover-link {
+ display: block;
+ padding: 10px 12px !important;
+ border-radius: 6px;
+ color: rgba(255, 255, 255, 0.92) !important;
+ font-size: 14px;
+ line-height: 1.25;
+ text-align: center;
+ white-space: nowrap;
+ }
+ .mineru-header-popover-link:hover,
+ .mineru-header-popover-link:focus {
+ background: rgba(255, 255, 255, 0.12);
+ color: #ffffff !important;
+ outline: none;
+ text-decoration: none !important;
+ }
a {
text-decoration: none;
}
@@ -44,6 +131,18 @@
.mineru-demo-header .external-link:hover {
text-decoration: none !important;
}
+ .mineru-demo-header .external-link {
+ font-size: 14px !important;
+ font-weight: 400 !important;
+ }
+ .mineru-demo-header .mineru-header-popover,
+ .mineru-demo-header .mineru-header-popover * {
+ color: rgba(255, 255, 255, 0.92) !important;
+ }
+ .mineru-demo-header .mineru-header-popover-link:hover,
+ .mineru-demo-header .mineru-header-popover-link:focus {
+ color: #ffffff !important;
+ }
</style></head>
<body>
@@ -110,23 +209,32 @@
<span style="color: white">{{HEADER_CODE_LINK}}</span>
</a>
</span>
- <!-- Code Link. -->
- <span class="link-block">
- <a href="https://huggingface.co/opendatalab/MinerU2.5-Pro-2605-1.2B" target="_blank" class="external-link button is-normal is-rounded is-dark" style="text-decoration: none; cursor: pointer">
+ <!-- Model Links. -->
+ <span class="link-block mineru-header-menu mineru-model-menu">
+ <button type="button" class="external-link button is-normal is-rounded is-dark mineru-header-trigger mineru-model-trigger" style="text-decoration: none; cursor: pointer" aria-haspopup="true">
<span class="icon" style="margin-right: 4px">
<i class="fas fa-cube" style="color: white; margin-right: 4px"></i>
</span>
<span style="color: white">{{HEADER_MODEL_LINK}}</span>
- </a>
+ </button>
+ <span class="mineru-header-popover mineru-model-popover">
+ <a href="https://huggingface.co/opendatalab/MinerU2.5-Pro-2605-1.2B" target="_blank" class="mineru-header-popover-link mineru-model-popover-link">{{HEADER_MODEL_HUGGINGFACE_LINK}}</a>
+ <a href="https://modelscope.cn/models/OpenDataLab/MinerU2.5-Pro-2605-1.2B" target="_blank" class="mineru-header-popover-link mineru-model-popover-link">{{HEADER_MODEL_MODELSCOPE_LINK}}</a>
+ </span>
</span>
- <!-- arXiv Link. -->
- <span class="link-block">
- <a href="https://arxiv.org/abs/2604.04771" target="_blank" class="external-link button is-normal is-rounded is-dark" style="text-decoration: none; cursor: pointer">
+ <!-- arXiv Links. -->
+ <span class="link-block mineru-header-menu mineru-paper-menu">
+ <button type="button" class="external-link button is-normal is-rounded is-dark mineru-header-trigger mineru-paper-trigger" style="text-decoration: none; cursor: pointer" aria-haspopup="true">
<span class="icon" style="margin-right: 8px">
<i class="fas fa-file" style="color: white"></i>
</span>
<span style="color: white">{{HEADER_PAPER_LINK}}</span>
- </a>
+ </button>
+ <span class="mineru-header-popover mineru-paper-popover">
+ <a href="https://arxiv.org/abs/2409.18839" target="_blank" class="mineru-header-popover-link mineru-paper-popover-link">{{HEADER_PAPER_MINERU_REPORT}}</a>
+ <a href="https://arxiv.org/abs/2509.22186" target="_blank" class="mineru-header-popover-link mineru-paper-popover-link">{{HEADER_PAPER_MINERU25_REPORT}}</a>
+ <a href="https://arxiv.org/abs/2604.04771" target="_blank" class="mineru-header-popover-link mineru-paper-popover-link">{{HEADER_PAPER_MINERU25PRO_REPORT}}</a>
+ </span>
</span>
<!-- Homepage Link. -->
diff --git a/tests/unittest/test_kit_commands.py b/tests/unittest/test_kit_commands.py
index 5edd1252..e5d6c239 100644
--- a/tests/unittest/test_kit_commands.py
+++ b/tests/unittest/test_kit_commands.py
@@ -863,6 +863,36 @@ def test_gradio_frontend_uses_v1_only_tier_visibility() -> None:
assert "mineru-hide-force-ocr" not in js_text
+def test_gradio_header_model_and_paper_links_use_popovers() -> None:
+ """校验 Gradio header 的模型和论文入口使用可悬浮展开的多链接菜单。"""
+ header_text = Path("mineru/resources/gradio_header.html").read_text(encoding="utf-8")
+ gradio_text = Path("mineru/cli_old/gradio_app.py").read_text(encoding="utf-8")
+
+ assert 'class="link-block mineru-header-menu mineru-model-menu"' in header_text
+ assert 'class="link-block mineru-header-menu mineru-paper-menu"' in header_text
+ assert "mineru-header-popover mineru-model-popover" in header_text
+ assert "mineru-header-popover mineru-paper-popover" in header_text
+ assert "https://huggingface.co/opendatalab/MinerU2.5-Pro-2605-1.2B" in header_text
+ assert "https://modelscope.cn/models/OpenDataLab/MinerU2.5-Pro-2605-1.2B" in header_text
+ assert "https://arxiv.org/abs/2409.18839" in header_text
+ assert "https://arxiv.org/abs/2509.22186" in header_text
+ assert "https://arxiv.org/abs/2604.04771" in header_text
+ assert ".block.mineru-header-html" in header_text
+ assert ".mineru-demo-header .external-link {\n font-size: 14px !important;" in header_text
+ assert 'gr.HTML(render_header_html(i18n), elem_classes=["mineru-header-html"])' in gradio_text
+
+ for placeholder, translation_key in {
+ "{{HEADER_MODEL_HUGGINGFACE_LINK}}": "header_model_huggingface_link",
+ "{{HEADER_MODEL_MODELSCOPE_LINK}}": "header_model_modelscope_link",
+ "{{HEADER_PAPER_MINERU_REPORT}}": "header_paper_mineru_report",
+ "{{HEADER_PAPER_MINERU25_REPORT}}": "header_paper_mineru25_report",
+ "{{HEADER_PAPER_MINERU25PRO_REPORT}}": "header_paper_mineru25pro_report",
+ }.items():
+ assert placeholder in header_text
+ assert f'"{placeholder}": "{translation_key}"' in gradio_text
+ assert f'"{translation_key}"' in gradio_text
+
+
def test_gradio_submit_inputs_are_v1_only() -> None:
"""校验 Gradio 公开控制面只保留 v1 API 支持的单次任务输入。"""
gradio_text = Path("mineru/cli_old/gradio_app.py").read_text(encoding="utf-8")