ZhouChuYue
commited on
Commit
Β·
f788ae2
1
Parent(s):
99923d8
Gradio 6.0 compatibility, simplify UI layout
Browse files
app.py
CHANGED
|
@@ -84,14 +84,12 @@ def format_output(result: dict) -> tuple:
|
|
| 84 |
f"β Error: {result['error']}",
|
| 85 |
"",
|
| 86 |
"",
|
| 87 |
-
"",
|
| 88 |
)
|
| 89 |
|
| 90 |
return (
|
| 91 |
result.get("title", ""),
|
| 92 |
result.get("html", ""),
|
| 93 |
result.get("text", ""),
|
| 94 |
-
result.get("html", ""), # For HTML preview
|
| 95 |
)
|
| 96 |
|
| 97 |
|
|
@@ -359,40 +357,36 @@ with gr.Blocks(title="UltraData Math Parser") as demo:
|
|
| 359 |
)
|
| 360 |
|
| 361 |
with gr.Tabs():
|
| 362 |
-
with gr.TabItem("
|
| 363 |
-
|
| 364 |
-
label="
|
| 365 |
lines=15,
|
| 366 |
max_lines=15,
|
| 367 |
interactive=False,
|
| 368 |
autoscroll=False,
|
| 369 |
)
|
| 370 |
-
with gr.TabItem("
|
| 371 |
-
|
| 372 |
-
label="
|
| 373 |
lines=15,
|
| 374 |
max_lines=15,
|
| 375 |
interactive=False,
|
| 376 |
autoscroll=False,
|
| 377 |
)
|
| 378 |
-
with gr.TabItem("ποΈ Preview"):
|
| 379 |
-
preview_output = gr.HTML(
|
| 380 |
-
label="HTML Preview",
|
| 381 |
-
)
|
| 382 |
|
| 383 |
# Event handlers
|
| 384 |
parse_btn.click(
|
| 385 |
fn=process_input,
|
| 386 |
inputs=[html_input, base_url_input, process_math, include_tables, enable_forum, html_type],
|
| 387 |
-
outputs=[title_output, html_output, text_output
|
| 388 |
)
|
| 389 |
|
| 390 |
def clear_all():
|
| 391 |
-
return "", "", "", "", ""
|
| 392 |
|
| 393 |
clear_btn.click(
|
| 394 |
fn=clear_all,
|
| 395 |
-
outputs=[html_input, base_url_input, title_output, html_output, text_output
|
| 396 |
)
|
| 397 |
|
| 398 |
# Footer info
|
|
|
|
| 84 |
f"β Error: {result['error']}",
|
| 85 |
"",
|
| 86 |
"",
|
|
|
|
| 87 |
)
|
| 88 |
|
| 89 |
return (
|
| 90 |
result.get("title", ""),
|
| 91 |
result.get("html", ""),
|
| 92 |
result.get("text", ""),
|
|
|
|
| 93 |
)
|
| 94 |
|
| 95 |
|
|
|
|
| 357 |
)
|
| 358 |
|
| 359 |
with gr.Tabs():
|
| 360 |
+
with gr.TabItem("π Plain Text"):
|
| 361 |
+
text_output = gr.Textbox(
|
| 362 |
+
label="Plain Text (w3m rendered)",
|
| 363 |
lines=15,
|
| 364 |
max_lines=15,
|
| 365 |
interactive=False,
|
| 366 |
autoscroll=False,
|
| 367 |
)
|
| 368 |
+
with gr.TabItem("π Raw HTML"):
|
| 369 |
+
html_output = gr.Textbox(
|
| 370 |
+
label="Extracted HTML",
|
| 371 |
lines=15,
|
| 372 |
max_lines=15,
|
| 373 |
interactive=False,
|
| 374 |
autoscroll=False,
|
| 375 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
|
| 377 |
# Event handlers
|
| 378 |
parse_btn.click(
|
| 379 |
fn=process_input,
|
| 380 |
inputs=[html_input, base_url_input, process_math, include_tables, enable_forum, html_type],
|
| 381 |
+
outputs=[title_output, html_output, text_output],
|
| 382 |
)
|
| 383 |
|
| 384 |
def clear_all():
|
| 385 |
+
return "", "", "", "", ""
|
| 386 |
|
| 387 |
clear_btn.click(
|
| 388 |
fn=clear_all,
|
| 389 |
+
outputs=[html_input, base_url_input, title_output, html_output, text_output],
|
| 390 |
)
|
| 391 |
|
| 392 |
# Footer info
|