ZhouChuYue commited on
Commit
1238b33
Β·
1 Parent(s): f788ae2

add markdown

Browse files
Files changed (1) hide show
  1. app.py +43 -3
app.py CHANGED
@@ -84,12 +84,18 @@ def format_output(result: dict) -> tuple:
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
 
@@ -276,6 +282,35 @@ label {
276
  resize: none !important;
277
  }
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  /* Custom scrollbar styling */
280
  .gr-textbox textarea::-webkit-scrollbar {
281
  width: 8px;
@@ -357,6 +392,11 @@ with gr.Blocks(title="UltraData Math Parser") as demo:
357
  )
358
 
359
  with gr.Tabs():
 
 
 
 
 
360
  with gr.TabItem("πŸ“„ Plain Text"):
361
  text_output = gr.Textbox(
362
  label="Plain Text (w3m rendered)",
@@ -378,15 +418,15 @@ with gr.Blocks(title="UltraData Math Parser") as demo:
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
 
84
  f"❌ Error: {result['error']}",
85
  "",
86
  "",
87
+ f"**Error:** {result['error']}",
88
  )
89
 
90
+ # Format text as markdown (wrap in code block for better display)
91
+ text_content = result.get("text", "")
92
+ markdown_content = text_content if text_content else "_No content extracted_"
93
+
94
  return (
95
  result.get("title", ""),
96
  result.get("html", ""),
97
  result.get("text", ""),
98
+ markdown_content,
99
  )
100
 
101
 
 
282
  resize: none !important;
283
  }
284
 
285
+ /* Markdown box styling */
286
+ .markdown-box {
287
+ background: rgba(255, 255, 255, 0.95) !important;
288
+ border: 1px solid rgba(124, 58, 237, 0.3) !important;
289
+ border-radius: 8px !important;
290
+ padding: 16px !important;
291
+ min-height: 300px !important;
292
+ max-height: 350px !important;
293
+ overflow-y: auto !important;
294
+ color: #1a1a2e !important;
295
+ }
296
+
297
+ .markdown-box * {
298
+ color: #1a1a2e !important;
299
+ }
300
+
301
+ .markdown-box code {
302
+ background: rgba(124, 58, 237, 0.1) !important;
303
+ padding: 2px 6px !important;
304
+ border-radius: 4px !important;
305
+ }
306
+
307
+ .markdown-box pre {
308
+ background: #f4f4f8 !important;
309
+ padding: 12px !important;
310
+ border-radius: 6px !important;
311
+ overflow-x: auto !important;
312
+ }
313
+
314
  /* Custom scrollbar styling */
315
  .gr-textbox textarea::-webkit-scrollbar {
316
  width: 8px;
 
392
  )
393
 
394
  with gr.Tabs():
395
+ with gr.TabItem("✨ Markdown"):
396
+ markdown_output = gr.Markdown(
397
+ label="Markdown Preview",
398
+ elem_classes=["markdown-box"],
399
+ )
400
  with gr.TabItem("πŸ“„ Plain Text"):
401
  text_output = gr.Textbox(
402
  label="Plain Text (w3m rendered)",
 
418
  parse_btn.click(
419
  fn=process_input,
420
  inputs=[html_input, base_url_input, process_math, include_tables, enable_forum, html_type],
421
+ outputs=[title_output, html_output, text_output, markdown_output],
422
  )
423
 
424
  def clear_all():
425
+ return "", "", "", "", "", ""
426
 
427
  clear_btn.click(
428
  fn=clear_all,
429
+ outputs=[html_input, base_url_input, title_output, html_output, text_output, markdown_output],
430
  )
431
 
432
  # Footer info