Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -509,9 +509,9 @@ def render_citations(text: str, browser: SimpleBrowser) -> str:
|
|
| 509 |
title = info.get('title', 'No Title')
|
| 510 |
snippet = info.get('snippet', '')
|
| 511 |
|
| 512 |
-
# Unescape HTML entities
|
| 513 |
-
title_display = title
|
| 514 |
-
snippet_display = snippet if snippet else 'No description available'
|
| 515 |
|
| 516 |
# Extract domain from URL
|
| 517 |
try:
|
|
@@ -524,13 +524,8 @@ def render_citations(text: str, browser: SimpleBrowser) -> str:
|
|
| 524 |
if line_info:
|
| 525 |
line_html = f'<div class="citation-tooltip-line">π {line_info}</div>'
|
| 526 |
|
| 527 |
-
# Create citation with tooltip
|
| 528 |
-
tooltip_html = f'
|
| 529 |
-
<div class="citation-tooltip-title">{title_display}</div>
|
| 530 |
-
{line_html}
|
| 531 |
-
<div class="citation-tooltip-snippet">{snippet_display}</div>
|
| 532 |
-
<div class="citation-tooltip-url">π {html.escape(domain)}</div>
|
| 533 |
-
</span>'''
|
| 534 |
|
| 535 |
return f'<span class="citation-wrapper"><a href="{html.escape(url)}" target="_blank" class="citation-link">[{index}]</a>{tooltip_html}</span>'
|
| 536 |
|
|
|
|
| 509 |
title = info.get('title', 'No Title')
|
| 510 |
snippet = info.get('snippet', '')
|
| 511 |
|
| 512 |
+
# Unescape HTML entities and remove newlines to prevent rendering issues
|
| 513 |
+
title_display = html.unescape(title).replace('\n', ' ').replace('\r', '').strip()
|
| 514 |
+
snippet_display = html.unescape(snippet).replace('\n', ' ').replace('\r', '').strip() if snippet else 'No description available'
|
| 515 |
|
| 516 |
# Extract domain from URL
|
| 517 |
try:
|
|
|
|
| 524 |
if line_info:
|
| 525 |
line_html = f'<div class="citation-tooltip-line">π {line_info}</div>'
|
| 526 |
|
| 527 |
+
# Create citation with tooltip (single line to avoid markdown conversion issues)
|
| 528 |
+
tooltip_html = f'<span class="citation-tooltip"><div class="citation-tooltip-title">{title_display}</div>{line_html}<div class="citation-tooltip-snippet">{snippet_display}</div><div class="citation-tooltip-url">π {html.escape(domain)}</div></span>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
|
| 530 |
return f'<span class="citation-wrapper"><a href="{html.escape(url)}" target="_blank" class="citation-link">[{index}]</a>{tooltip_html}</span>'
|
| 531 |
|