IPF commited on
Commit
0d53b0b
·
verified ·
1 Parent(s): 93cfcee

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
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
- return f'<a href="#ref-{index}" class="citation-link" style="color:#2563eb;text-decoration:none;font-weight:600;">[{index}]</a>'
 
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)