import re with open("modules/research_tab.py", "r", encoding="utf-8") as f: content = f.read() # 1. Define the new JS snippet FLOATING_CARD_JS = """ FLOATING_CARD_JS = ''' ''' """ # Insert the global constant near the top after imports if "FLOATING_CARD_JS =" not in content: content = re.sub(r'import re\n', r'import re\n\n' + FLOATING_CARD_JS + '\n', content, count=1) # Modify _make_citations_interactive pattern_make_citations = re.compile( r'floating_card_js = \'\'\'\n\s*