Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
332 |
-
|
333 |
-
report_text = report_text.replace("-----------------------------", "")
|
334 |
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
-
return
|
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(
|