EasySci commited on
Commit
b4ea0bc
·
1 Parent(s): dec8930

Update TLDR.py

Browse files
Files changed (1) hide show
  1. TLDR.py +10 -11
TLDR.py CHANGED
@@ -46,11 +46,13 @@ def run_code(category, loaded_dict, event = None):
46
  def update_mainTLDR(buttons_to_add, paper_list):
47
  main_tldr = []
48
 
49
- table_of_contents = [] # List to store the table of contents entries
50
-
51
  if buttons_to_add:
 
52
  for i in range(len(buttons_to_add)):
53
  category_content = []
 
 
 
54
  for paper in paper_list[i]:
55
 
56
  # Create the HTML content for both links with line breaks
@@ -69,7 +71,7 @@ def update_mainTLDR(buttons_to_add, paper_list):
69
  category_content.append(paper_content)
70
 
71
  category_column = pn.Column(
72
- pn.pane.Markdown(f"# [{buttons_to_add[i]}](#{buttons_to_add[i]}) <a id='{buttons_to_add[i]}'></a>"),
73
  pn.layout.Spacer(height=20),
74
  *category_content,
75
  pn.layout.Spacer(height=10),
@@ -80,16 +82,13 @@ def update_mainTLDR(buttons_to_add, paper_list):
80
 
81
  main_tldr.append(category_column)
82
 
83
- # Add entry to the table of contents
84
- table_of_contents.append(f"- [{buttons_to_add[i]}](#{buttons_to_add[i]})")
 
 
 
85
 
86
  else:
87
  main_tldr.append(pn.pane.Markdown("# Please select some tags!"))
88
 
89
- # Create the table of contents Markdown text
90
- toc_text = "\n".join(table_of_contents)
91
-
92
- # Prepend the table of contents to the main content
93
- main_tldr.insert(0, pn.pane.Markdown(f"## Table of Contents\n{toc_text}\n"))
94
-
95
  return main_tldr
 
46
  def update_mainTLDR(buttons_to_add, paper_list):
47
  main_tldr = []
48
 
 
 
49
  if buttons_to_add:
50
+ table_of_contents = []
51
  for i in range(len(buttons_to_add)):
52
  category_content = []
53
+ category_title = f"{buttons_to_add[i]}"
54
+ table_of_contents.append(f"- [{category_title}](#{category_title.lower().replace(' ', '-')})")
55
+
56
  for paper in paper_list[i]:
57
 
58
  # Create the HTML content for both links with line breaks
 
71
  category_content.append(paper_content)
72
 
73
  category_column = pn.Column(
74
+ pn.pane.Markdown(f"# {category_title}"),
75
  pn.layout.Spacer(height=20),
76
  *category_content,
77
  pn.layout.Spacer(height=10),
 
82
 
83
  main_tldr.append(category_column)
84
 
85
+ # Create the table of contents Markdown text
86
+ toc_text = "\n".join(table_of_contents)
87
+
88
+ # Insert the table of contents at the beginning of the main content
89
+ main_tldr.insert(0, pn.pane.Markdown(f"## Table of Contents\n{toc_text}\n"))
90
 
91
  else:
92
  main_tldr.append(pn.pane.Markdown("# Please select some tags!"))
93
 
 
 
 
 
 
 
94
  return main_tldr