Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
|
@@ -171,6 +171,11 @@ class SimpleBrowser:
|
|
| 171 |
return self.used_citations.index(cursor)
|
| 172 |
|
| 173 |
def get_page_info(self, cursor: int) -> Optional[Dict[str, str]]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
if 0 <= cursor < len(self.page_stack):
|
| 175 |
url = self.page_stack[cursor]
|
| 176 |
page = self.pages.get(url)
|
|
@@ -487,7 +492,8 @@ def render_citations(text: str, browser: SimpleBrowser) -> str:
|
|
| 487 |
info = browser.get_page_info(cursor)
|
| 488 |
if info and info.get('url'):
|
| 489 |
# Return clickable index link pointing to reference section
|
| 490 |
-
|
|
|
|
| 491 |
except:
|
| 492 |
pass
|
| 493 |
return m.group(0)
|
|
|
|
| 171 |
return self.used_citations.index(cursor)
|
| 172 |
|
| 173 |
def get_page_info(self, cursor: int) -> Optional[Dict[str, str]]:
|
| 174 |
+
# Prioritize link_map as it stores search result metadata
|
| 175 |
+
if cursor in self.link_map:
|
| 176 |
+
return self.link_map[cursor]
|
| 177 |
+
|
| 178 |
+
# Fallback to page_stack for opened pages
|
| 179 |
if 0 <= cursor < len(self.page_stack):
|
| 180 |
url = self.page_stack[cursor]
|
| 181 |
page = self.pages.get(url)
|
|
|
|
| 492 |
info = browser.get_page_info(cursor)
|
| 493 |
if info and info.get('url'):
|
| 494 |
# Return clickable index link pointing to reference section
|
| 495 |
+
# Aligned with generate_html_example.py style (green via CSS class)
|
| 496 |
+
return f'<a href="#ref-{index}" class="citation-link">[{index}]</a>'
|
| 497 |
except:
|
| 498 |
pass
|
| 499 |
return m.group(0)
|