cyberandy commited on
Commit
5c65b3e
Β·
verified Β·
1 Parent(s): 0ce9ab0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -14
app.py CHANGED
@@ -328,21 +328,42 @@ def create_gradio_interface() -> gr.Blocks:
328
 
329
  def format_markdown_report(report_text: str) -> str:
330
  """Format the report text with proper Markdown and styling"""
331
- # Add custom CSS classes and formatting
332
- report_text = report_text.replace("============================", "")
333
- report_text = report_text.replace("-----------------------------", "")
334
 
335
- # Add styling to score sections
336
- report_text = report_text.replace("[β˜…β˜…β˜…β˜…β˜†]", "<span class='star-rating'>β˜…β˜…β˜…β˜…β˜†</span>")
337
- report_text = report_text.replace("πŸ“Š", "<span class='emoji-icon'>πŸ“Š</span>")
338
- report_text = report_text.replace("πŸ”", "<span class='emoji-icon'>πŸ”</span>")
339
- report_text = report_text.replace("πŸ“", "<span class='emoji-icon'>πŸ“</span>")
340
- report_text = report_text.replace("πŸ”„", "<span class='emoji-icon'>πŸ”„</span>")
341
- report_text = report_text.replace("πŸ’°", "<span class='emoji-icon'>πŸ’°</span>")
342
- report_text = report_text.replace("πŸ“ˆ", "<span class='emoji-icon'>πŸ“ˆ</span>")
343
- report_text = report_text.replace("πŸ”§", "<span class='emoji-icon'>πŸ”§</span>")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
 
345
- return report_text
346
 
347
  async def run_analysis(api_key: str,
348
  website_url: str,
@@ -415,7 +436,11 @@ def create_gradio_interface() -> gr.Blocks:
415
  analysis_output = gr.Markdown(
416
  value="Results will appear here...",
417
  label="Analysis Results",
418
- elem_classes="analysis-output"
 
 
 
 
419
  )
420
 
421
  analyze_button.click(
 
328
 
329
  def format_markdown_report(report_text: str) -> str:
330
  """Format the report text with proper Markdown and styling"""
331
+ lines = report_text.split('\n')
332
+ formatted_lines = []
 
333
 
334
+ for line in lines:
335
+ # Handle headings
336
+ if '=============================' in line:
337
+ continue
338
+ if '-----------------------------' in line:
339
+ formatted_lines.append('---')
340
+ continue
341
+
342
+ # Handle star ratings
343
+ if '[β˜…β˜…β˜…β˜…β˜†]' in line:
344
+ line = line.replace('[β˜…β˜…β˜…β˜…β˜†]', '`β˜…β˜…β˜…β˜…β˜†`')
345
+
346
+ # Handle section titles with emojis
347
+ if any(emoji in line for emoji in ['πŸ“Š', 'πŸ”', 'πŸ“', 'πŸ”„', 'πŸ’°', 'πŸ“ˆ', 'πŸ”§']):
348
+ formatted_lines.append('\n**' + line.strip() + '**\n')
349
+ continue
350
+
351
+ # Handle bullet points
352
+ if line.strip().startswith('β€’'):
353
+ line = line.replace('β€’', '-')
354
+
355
+ formatted_lines.append(line)
356
+
357
+ # Join the lines and add final formatting
358
+ formatted_text = '\n'.join(formatted_lines)
359
+
360
+ # Add spacing after section breaks
361
+ formatted_text = formatted_text.replace('---\n', '---\n\n')
362
+
363
+ # Ensure bullet points are properly spaced
364
+ formatted_text = formatted_text.replace('\n-', '\n\n-')
365
 
366
+ return formatted_text
367
 
368
  async def run_analysis(api_key: str,
369
  website_url: str,
 
436
  analysis_output = gr.Markdown(
437
  value="Results will appear here...",
438
  label="Analysis Results",
439
+ elem_classes="analysis-output",
440
+ sanitize_html=False, # Allow HTML for custom formatting
441
+ line_breaks=True, # Preserve line breaks
442
+ header_links=False, # Disable header links for cleaner look
443
+ show_copy_button=True # Allow users to copy the report
444
  )
445
 
446
  analyze_button.click(