File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ def update_readme(readme_path, rows_str):
128128 readme_path .write_text (updated_text )
129129
130130
131+ def normalize_slug (slug : str ) -> str :
132+ """Normalize slug by replacing multiple consecutive dashes with single dashes."""
133+ return re .sub (r'-+' , '-' , slug )
134+
131135def main ():
132136 problems = []
133137
@@ -139,8 +143,9 @@ def main():
139143 match = re .match (r"(\d+)-(.+)" , folder )
140144 if not match :
141145 continue
142- folder_number , slug = match .groups ()
146+ folder_number , raw_slug = match .groups ()
143147 folder_number = str (int (folder_number ))
148+ slug = normalize_slug (raw_slug ) # Normalize the slug
144149 title = f"{ folder_number } . " + " " .join ([smart_capitalize (w ) for w in slug .split ("-" )])
145150
146151 difficulty , tags = fetch_question_details (slug )
Original file line number Diff line number Diff line change @@ -93,6 +93,10 @@ def tag_badge(tag: str) -> str:
9393 """Render topic tags as small gray badges."""
9494 return f'<span style="background-color:#607D8B; color:white; padding:2px 6px; border-radius:6px; font-size:0.75em; margin-right:0.2rem;">{ tag } </span>'
9595
96+ def normalize_slug (slug : str ) -> str :
97+ """Normalize slug by replacing multiple consecutive dashes with single dashes."""
98+ return re .sub (r'-+' , '-' , slug )
99+
96100for prob_folder in sorted (os .listdir (SRC_DIR )):
97101 prob_path = Path (SRC_DIR ) / prob_folder
98102 if not prob_path .is_dir ():
@@ -101,8 +105,9 @@ def tag_badge(tag: str) -> str:
101105 match = re .match (r'(\d+)-(.+)' , prob_folder )
102106 if not match :
103107 continue
104- number , title_slug = match .groups ()
108+ number , raw_title_slug = match .groups ()
105109 number = str (int (number ))
110+ title_slug = normalize_slug (raw_title_slug ) # Normalize the slug
106111 title = ' ' .join ([smart_capitalize (w ) for w in title_slug .split ('-' )])
107112
108113 readme_path = prob_path / "README.md"
You can’t perform that action at this time.
0 commit comments