ZhouChuYue
commited on
Commit
Β·
2b0def0
1
Parent(s):
5d42049
feat: synchronize UI style with L3 Generator (glassmorphism, dark theme)
Browse files
app.py
CHANGED
|
@@ -207,190 +207,233 @@ EXAMPLE_HTML = """<!DOCTYPE html>
|
|
| 207 |
</html>"""
|
| 208 |
|
| 209 |
|
| 210 |
-
# Custom CSS for better aesthetics
|
| 211 |
custom_css = """
|
| 212 |
-
@import url('https://fonts.googleapis.com/css2?family=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
.gradio-container {
|
| 215 |
-
font-family: '
|
| 216 |
-
background:
|
| 217 |
-
|
| 218 |
}
|
| 219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
.main-title {
|
| 221 |
-
font-family: '
|
| 222 |
-
font-weight:
|
| 223 |
-
font-size:
|
| 224 |
-
background: linear-gradient(
|
| 225 |
-webkit-background-clip: text !important;
|
| 226 |
-webkit-text-fill-color: transparent !important;
|
| 227 |
-
background-clip: text !important;
|
| 228 |
text-align: center !important;
|
| 229 |
margin-bottom: 0.5rem !important;
|
|
|
|
|
|
|
| 230 |
}
|
| 231 |
|
| 232 |
.subtitle {
|
| 233 |
text-align: center !important;
|
| 234 |
-
color:
|
| 235 |
font-size: 1.1rem !important;
|
| 236 |
-
margin-bottom:
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
.gr-box {
|
| 240 |
-
border-radius: 12px !important;
|
| 241 |
-
border: 1px solid rgba(124, 58, 237, 0.3) !important;
|
| 242 |
-
background: rgba(15, 15, 35, 0.8) !important;
|
| 243 |
-
backdrop-filter: blur(10px) !important;
|
| 244 |
}
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
background:
|
| 249 |
-
|
| 250 |
-
border
|
| 251 |
-
|
|
|
|
|
|
|
| 252 |
}
|
| 253 |
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
| 258 |
font-size: 1rem !important;
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
letter-spacing: 1px !important;
|
| 264 |
-
}
|
| 265 |
-
|
| 266 |
-
.gr-button-primary:hover {
|
| 267 |
-
transform: translateY(-2px) !important;
|
| 268 |
-
box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4) !important;
|
| 269 |
}
|
| 270 |
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
}
|
| 278 |
|
| 279 |
-
|
| 280 |
-
|
|
|
|
|
|
|
| 281 |
font-weight: 600 !important;
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
border-bottom: 2px solid rgba(0, 212, 255, 0.3) !important;
|
| 286 |
}
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
border-radius: 12px !important;
|
| 292 |
-
padding: 1rem !important;
|
| 293 |
}
|
| 294 |
|
| 295 |
-
.
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
}
|
| 298 |
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
padding: 2px 6px !important;
|
| 302 |
-
border-radius: 4px !important;
|
| 303 |
font-family: 'JetBrains Mono', monospace !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
}
|
| 305 |
|
| 306 |
-
|
| 307 |
-
|
|
|
|
|
|
|
| 308 |
}
|
| 309 |
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
}
|
| 315 |
|
| 316 |
-
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
| 318 |
}
|
| 319 |
|
| 320 |
-
|
| 321 |
-
|
|
|
|
| 322 |
}
|
| 323 |
|
| 324 |
-
/*
|
| 325 |
-
.gr-
|
| 326 |
-
|
| 327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
}
|
| 329 |
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
max-height: 580px !important;
|
| 334 |
-
overflow-y: auto !important;
|
| 335 |
}
|
| 336 |
|
| 337 |
-
|
| 338 |
-
.
|
| 339 |
-
|
| 340 |
-
|
| 341 |
border-radius: 8px !important;
|
| 342 |
-
padding: 16px !important;
|
| 343 |
-
min-height: 580px !important;
|
| 344 |
-
max-height: 580px !important;
|
| 345 |
-
overflow-y: auto !important;
|
| 346 |
-
color: #1a1a2e !important;
|
| 347 |
}
|
| 348 |
|
| 349 |
-
.
|
| 350 |
-
|
|
|
|
| 351 |
}
|
| 352 |
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
}
|
| 358 |
|
| 359 |
-
.
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
}
|
| 365 |
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
}
|
| 370 |
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
}
|
| 375 |
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
}
|
| 380 |
|
| 381 |
-
|
| 382 |
-
|
|
|
|
|
|
|
| 383 |
}
|
| 384 |
"""
|
| 385 |
|
| 386 |
# Build Gradio interface
|
| 387 |
-
with gr.Blocks(title="UltraData Math Parser") as demo:
|
| 388 |
-
gr.HTML(f'<style>{custom_css}</style>')
|
| 389 |
gr.HTML('<h1 class="main-title">π UltraData Math Parser</h1>')
|
| 390 |
gr.HTML('<p class="subtitle">Unified HTML Parser for Mathematical Content Extraction</p>')
|
| 391 |
|
| 392 |
with gr.Row():
|
| 393 |
-
with gr.Column(scale=1):
|
| 394 |
gr.HTML('<div class="section-header">π₯ Input</div>')
|
| 395 |
|
| 396 |
with gr.Tabs():
|
|
@@ -448,7 +491,7 @@ with gr.Blocks(title="UltraData Math Parser") as demo:
|
|
| 448 |
parse_btn = gr.Button("π Parse HTML", variant="primary", size="lg")
|
| 449 |
clear_btn = gr.Button("ποΈ Clear", variant="secondary", size="lg")
|
| 450 |
|
| 451 |
-
with gr.Column(scale=1):
|
| 452 |
gr.HTML('<div class="section-header">π€ Output</div>')
|
| 453 |
|
| 454 |
title_output = gr.Textbox(
|
|
@@ -511,7 +554,7 @@ with gr.Blocks(title="UltraData Math Parser") as demo:
|
|
| 511 |
|
| 512 |
# Footer info
|
| 513 |
gr.HTML("""
|
| 514 |
-
<div
|
| 515 |
<p>π¬ <strong>UltraData Math Parser</strong> - Part of the UltraData-Math Project</p>
|
| 516 |
<p>Specialized in extracting mathematical content from web pages with MathML, LaTeX, and formula support.</p>
|
| 517 |
</div>
|
|
|
|
| 207 |
</html>"""
|
| 208 |
|
| 209 |
|
| 210 |
+
# Custom CSS for better aesthetics - Matched with L3 Generator
|
| 211 |
custom_css = """
|
| 212 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
|
| 213 |
+
|
| 214 |
+
:root {
|
| 215 |
+
--primary-color: #6366f1;
|
| 216 |
+
--text-light: #f8fafc;
|
| 217 |
+
--text-gray: #cbd5e1;
|
| 218 |
+
--panel-bg: rgba(15, 23, 42, 0.6);
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
body {
|
| 222 |
+
background-color: #0f172a;
|
| 223 |
+
color: var(--text-light);
|
| 224 |
+
}
|
| 225 |
|
| 226 |
.gradio-container {
|
| 227 |
+
font-family: 'Inter', sans-serif !important;
|
| 228 |
+
background: radial-gradient(circle at top left, #1e1b4b, #0f172a) !important;
|
| 229 |
+
max-width: 1200px !important;
|
| 230 |
}
|
| 231 |
|
| 232 |
+
/* Force all text to be light by default to combat Gradio's light theme defaults */
|
| 233 |
+
.gradio-container * {
|
| 234 |
+
color: var(--text-light);
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/* Title & Header */
|
| 238 |
.main-title {
|
| 239 |
+
font-family: 'Inter', sans-serif !important;
|
| 240 |
+
font-weight: 800 !important;
|
| 241 |
+
font-size: 3rem !important;
|
| 242 |
+
background: linear-gradient(to right, #818cf8, #c084fc, #f472b6) !important;
|
| 243 |
-webkit-background-clip: text !important;
|
| 244 |
-webkit-text-fill-color: transparent !important;
|
|
|
|
| 245 |
text-align: center !important;
|
| 246 |
margin-bottom: 0.5rem !important;
|
| 247 |
+
/* Reset color for gradient text */
|
| 248 |
+
color: transparent !important;
|
| 249 |
}
|
| 250 |
|
| 251 |
.subtitle {
|
| 252 |
text-align: center !important;
|
| 253 |
+
color: var(--text-gray) !important;
|
| 254 |
font-size: 1.1rem !important;
|
| 255 |
+
margin-bottom: 3rem !important;
|
| 256 |
+
font-weight: 300 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
}
|
| 258 |
|
| 259 |
+
/* Panels */
|
| 260 |
+
.glass-panel {
|
| 261 |
+
background: var(--panel-bg) !important;
|
| 262 |
+
backdrop-filter: blur(12px) !important;
|
| 263 |
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 264 |
+
border-radius: 16px !important;
|
| 265 |
+
padding: 24px !important;
|
| 266 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
|
| 267 |
}
|
| 268 |
|
| 269 |
+
/* Labels - High Contrast, Clean Black */
|
| 270 |
+
.block > label > span,
|
| 271 |
+
.form > label > span,
|
| 272 |
+
.gr-form > label > span,
|
| 273 |
+
.label-wrap > span {
|
| 274 |
+
color: #000000 !important; /* Pure Black */
|
| 275 |
+
font-weight: 700 !important;
|
| 276 |
font-size: 1rem !important;
|
| 277 |
+
margin-bottom: 0.5rem !important;
|
| 278 |
+
text-shadow: 0 0 2px #ffffff, 0 0 4px #ffffff !important; /* White glow/outline for visibility */
|
| 279 |
+
background-color: transparent !important;
|
| 280 |
+
padding: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
}
|
| 282 |
|
| 283 |
+
/* Info Text (Description) */
|
| 284 |
+
span.description, .description {
|
| 285 |
+
color: #000000 !important;
|
| 286 |
+
font-weight: 600 !important;
|
| 287 |
+
text-shadow: 0 0 2px #ffffff !important;
|
| 288 |
+
opacity: 1 !important;
|
| 289 |
}
|
| 290 |
|
| 291 |
+
/* Fix Radio/Checkbox alignment & styling */
|
| 292 |
+
fieldset label span {
|
| 293 |
+
margin-bottom: 0 !important;
|
| 294 |
+
text-shadow: none !important;
|
| 295 |
font-weight: 600 !important;
|
| 296 |
+
color: #0f172a !important; /* Dark text for unselected options (white background) */
|
| 297 |
+
display: flex !important;
|
| 298 |
+
align-items: center !important;
|
|
|
|
| 299 |
}
|
| 300 |
|
| 301 |
+
/* Selected radio button text should be white */
|
| 302 |
+
fieldset label.selected span {
|
| 303 |
+
color: #ffffff !important;
|
|
|
|
|
|
|
| 304 |
}
|
| 305 |
|
| 306 |
+
/* Radio group title (e.g., Difficulty Level) */
|
| 307 |
+
fieldset legend, fieldset legend span,
|
| 308 |
+
.gr-radio > label, .gr-radio > label span,
|
| 309 |
+
.gradio-container .label-wrap, .gradio-container .label-wrap span {
|
| 310 |
+
color: #000000 !important;
|
| 311 |
+
font-weight: 700 !important;
|
| 312 |
+
text-shadow: 0 0 2px #ffffff, 0 0 4px #ffffff !important;
|
| 313 |
}
|
| 314 |
|
| 315 |
+
/* Inputs & Textareas - Dark Grey Background for Contrast */
|
| 316 |
+
.gr-input, textarea, input, .gr-box, .gr-check-radio, .gr-dropdown {
|
|
|
|
|
|
|
| 317 |
font-family: 'JetBrains Mono', monospace !important;
|
| 318 |
+
background-color: #1e293b !important; /* Slate 800 - Lighter than bg, darker than text */
|
| 319 |
+
border: 1px solid #64748b !important; /* Visible Slate Border */
|
| 320 |
+
color: #ffffff !important;
|
| 321 |
+
box-shadow: none !important;
|
| 322 |
}
|
| 323 |
|
| 324 |
+
/* Focus state */
|
| 325 |
+
.gr-input:focus, textarea:focus, input:focus {
|
| 326 |
+
border-color: #ffffff !important; /* White border on focus */
|
| 327 |
+
background-color: #334155 !important; /* Slightly lighter on focus */
|
| 328 |
}
|
| 329 |
|
| 330 |
+
/* Override default block backgrounds */
|
| 331 |
+
.gradio-container .block, .gradio-container .panel {
|
| 332 |
+
background-color: transparent !important;
|
| 333 |
+
border: none !important;
|
| 334 |
}
|
| 335 |
|
| 336 |
+
/* Fix for dropdown options background */
|
| 337 |
+
ul.options, .gr-dropdown-options {
|
| 338 |
+
background-color: #1e293b !important;
|
| 339 |
+
color: #ffffff !important;
|
| 340 |
+
border: 1px solid #64748b !important;
|
| 341 |
}
|
| 342 |
|
| 343 |
+
/* Markdown prose */
|
| 344 |
+
.prose, .prose p, .prose h1, .prose h2, .prose h3, .prose strong, .prose li {
|
| 345 |
+
color: var(--text-light) !important;
|
| 346 |
}
|
| 347 |
|
| 348 |
+
/* Buttons */
|
| 349 |
+
.gr-button-primary {
|
| 350 |
+
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
|
| 351 |
+
border: none !important;
|
| 352 |
+
color: white !important;
|
| 353 |
+
font-weight: 600 !important;
|
| 354 |
+
border-radius: 8px !important;
|
| 355 |
+
transition: transform 0.2s, box-shadow 0.2s !important;
|
| 356 |
}
|
| 357 |
|
| 358 |
+
.gr-button-primary:hover {
|
| 359 |
+
transform: translateY(-1px) !important;
|
| 360 |
+
box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3) !important;
|
|
|
|
|
|
|
| 361 |
}
|
| 362 |
|
| 363 |
+
.gr-button-secondary {
|
| 364 |
+
background: rgba(30, 41, 59, 0.8) !important;
|
| 365 |
+
border: 1px solid rgba(148, 163, 184, 0.3) !important;
|
| 366 |
+
color: var(--text-gray) !important;
|
| 367 |
border-radius: 8px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
}
|
| 369 |
|
| 370 |
+
.gr-button-secondary:hover {
|
| 371 |
+
background: rgba(51, 65, 85, 0.8) !important;
|
| 372 |
+
color: var(--text-light) !important;
|
| 373 |
}
|
| 374 |
|
| 375 |
+
/* Tabs */
|
| 376 |
+
.tabs {
|
| 377 |
+
border: none !important;
|
| 378 |
+
background: transparent !important;
|
| 379 |
+
margin-bottom: 2rem !important;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
.tab-nav {
|
| 383 |
+
border-bottom: 1px solid rgba(148, 163, 184, 0.2) !important;
|
| 384 |
+
justify-content: center !important;
|
| 385 |
}
|
| 386 |
|
| 387 |
+
.tab-nav button {
|
| 388 |
+
font-weight: 600 !important;
|
| 389 |
+
font-size: 1rem !important;
|
| 390 |
+
color: var(--text-gray) !important;
|
| 391 |
+
transition: all 0.3s ease !important;
|
| 392 |
}
|
| 393 |
|
| 394 |
+
.tab-nav button.selected {
|
| 395 |
+
color: #818cf8 !important;
|
| 396 |
+
border-bottom: 2px solid #818cf8 !important;
|
| 397 |
}
|
| 398 |
|
| 399 |
+
/* Section Header */
|
| 400 |
+
.section-header {
|
| 401 |
+
color: #818cf8 !important;
|
| 402 |
+
font-weight: 700 !important;
|
| 403 |
+
font-size: 1.5rem !important;
|
| 404 |
+
margin-bottom: 1.5rem !important;
|
| 405 |
+
padding-bottom: 0.5rem !important;
|
| 406 |
+
border-bottom: 2px solid rgba(129, 140, 248, 0.3) !important;
|
| 407 |
+
text-shadow: 0 2px 4px rgba(0,0,0,0.3);
|
| 408 |
}
|
| 409 |
|
| 410 |
+
/* Footer */
|
| 411 |
+
.footer-text {
|
| 412 |
+
text-align: center;
|
| 413 |
+
margin-top: 4rem;
|
| 414 |
+
padding: 2rem;
|
| 415 |
+
color: var(--text-gray);
|
| 416 |
+
font-size: 0.9rem;
|
| 417 |
+
border-top: 1px solid rgba(148, 163, 184, 0.1);
|
| 418 |
+
}
|
| 419 |
+
.footer-text a {
|
| 420 |
+
color: #818cf8 !important;
|
| 421 |
}
|
| 422 |
|
| 423 |
+
/* Accordion */
|
| 424 |
+
.gr-accordion {
|
| 425 |
+
background-color: rgba(30, 41, 59, 0.4) !important;
|
| 426 |
+
border: 1px solid rgba(148, 163, 184, 0.2) !important;
|
| 427 |
}
|
| 428 |
"""
|
| 429 |
|
| 430 |
# Build Gradio interface
|
| 431 |
+
with gr.Blocks(title="UltraData Math Parser", css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
|
|
| 432 |
gr.HTML('<h1 class="main-title">π UltraData Math Parser</h1>')
|
| 433 |
gr.HTML('<p class="subtitle">Unified HTML Parser for Mathematical Content Extraction</p>')
|
| 434 |
|
| 435 |
with gr.Row():
|
| 436 |
+
with gr.Column(scale=1, elem_classes=["glass-panel"]):
|
| 437 |
gr.HTML('<div class="section-header">π₯ Input</div>')
|
| 438 |
|
| 439 |
with gr.Tabs():
|
|
|
|
| 491 |
parse_btn = gr.Button("π Parse HTML", variant="primary", size="lg")
|
| 492 |
clear_btn = gr.Button("ποΈ Clear", variant="secondary", size="lg")
|
| 493 |
|
| 494 |
+
with gr.Column(scale=1, elem_classes=["glass-panel"]):
|
| 495 |
gr.HTML('<div class="section-header">π€ Output</div>')
|
| 496 |
|
| 497 |
title_output = gr.Textbox(
|
|
|
|
| 554 |
|
| 555 |
# Footer info
|
| 556 |
gr.HTML("""
|
| 557 |
+
<div class="footer-text">
|
| 558 |
<p>π¬ <strong>UltraData Math Parser</strong> - Part of the UltraData-Math Project</p>
|
| 559 |
<p>Specialized in extracting mathematical content from web pages with MathML, LaTeX, and formula support.</p>
|
| 560 |
</div>
|