Niharmahesh commited on
Commit
a928259
·
verified ·
1 Parent(s): d67ad02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -360,14 +360,19 @@ def display_articles():
360
  with open(selected_file, 'r', encoding='utf-8') as file:
361
  html_content = file.read()
362
 
363
- # Use JavaScript to open content in new window
364
- st.markdown(f"""
365
  <script>
366
- var newWindow = window.open();
367
- newWindow.document.write(`{html_content.replace('`', '\\`')}`);
368
- newWindow.document.close();
 
 
 
 
369
  </script>
370
- """, unsafe_allow_html=True)
 
371
 
372
  except Exception as e:
373
  st.error(f"Error opening article: {str(e)}")
 
360
  with open(selected_file, 'r', encoding='utf-8') as file:
361
  html_content = file.read()
362
 
363
+ # Use JavaScript to open content in new window (safer approach)
364
+ js_code = """
365
  <script>
366
+ function openArticle() {
367
+ var newWindow = window.open();
368
+ var content = """ + repr(html_content) + """;
369
+ newWindow.document.write(content);
370
+ newWindow.document.close();
371
+ }
372
+ openArticle();
373
  </script>
374
+ """
375
+ st.markdown(js_code, unsafe_allow_html=True)
376
 
377
  except Exception as e:
378
  st.error(f"Error opening article: {str(e)}")