Skip to content

Commit 49b7405

Browse files
committed
Fix capitlization issue
1 parent e01fae8 commit 49b7405

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Scripts/update_project_readme.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
GITHUB_README_PATH = Path("README.md")
99
LINK_ICON = "🔗"
1010

11+
ROMAN_NUMERALS = {
12+
"i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x",
13+
"xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix", "xx"
14+
}
15+
16+
def smart_capitalize(word: str) -> str:
17+
"""Capitalize a word unless it's a Roman numeral in lowercase."""
18+
if word.lower() in ROMAN_NUMERALS:
19+
return word.upper()
20+
return word.capitalize()
21+
1122
def fetch_question_details(slug: str):
1223
"""Fetch difficulty and tags from LeetCode GraphQL API."""
1324
url = "https://leetcode.com/graphql"
@@ -111,7 +122,7 @@ def main():
111122
continue
112123
folder_number, slug = match.groups()
113124
folder_number = str(int(folder_number))
114-
title = f"{folder_number}. " + " ".join([w.capitalize() for w in slug.split("-")])
125+
title = f"{folder_number}. " + " ".join([smart_capitalize(w) for w in slug.split("-")])
115126

116127
difficulty, tags = fetch_question_details(slug)
117128
problems.append((slug, folder_number, title, difficulty, tags))

0 commit comments

Comments
 (0)