Skip to content

Commit 83aedbc

Browse files
committed
feat: format contest file
1 parent 85a469b commit 83aedbc

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

main.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33
from collections import defaultdict
44

55

6-
def format_contest_md(content: str) -> str:
7-
content = content.replace("[English Version](/solution/CONTEST_README_EN.md)", "")
8-
content = content.replace("[中文文档](/solution/CONTEST_README.md)", "")
9-
res = re.findall(r"\[(.*?)\]\((.*?)\)", content)
10-
for _, link in res:
11-
num = link.split("/")[-2].split(".")[0]
12-
num = int(num)
13-
content = content.replace(link, f"./lc/{num}.md")
14-
content = f"---\ncomments: true\n---\n\n" + content
15-
return content
6+
for contest_file in ["docs/contest.md", "docs-en/contest.md"]:
7+
with open(contest_file, "r", encoding="utf-8") as f:
8+
content = f.read()
169

17-
18-
def format_contest_md_en(content: str) -> str:
1910
content = content.replace("[English Version](/solution/CONTEST_README_EN.md)", "")
2011
content = content.replace("[中文文档](/solution/CONTEST_README.md)", "")
2112
res = re.findall(r"\[(.*?)\]\((.*?)\)", content)
@@ -24,20 +15,10 @@ def format_contest_md_en(content: str) -> str:
2415
num = int(num)
2516
content = content.replace(link, f"./lc/{num}.md")
2617
content = f"---\ncomments: true\n---\n\n" + content
27-
return content
28-
2918

30-
with open("docs/contest.md", "r", encoding="utf-8") as f:
31-
contest = f.read()
32-
contest = format_contest_md(contest)
33-
with open("docs/contest.md", "w", encoding="utf-8") as f:
34-
f.write(contest)
19+
with open(contest_file, "w", encoding="utf-8") as f:
20+
f.write(content)
3521

36-
with open("docs-en/contest.md", "r", encoding="utf-8") as f:
37-
contest_en = f.read()
38-
contest_en = format_contest_md_en(contest_en)
39-
with open("docs-en/contest.md", "w", encoding="utf-8") as f:
40-
f.write(contest_en)
4122

4223
code_dict = {
4324
"py": ("Python3", "python"),

0 commit comments

Comments
 (0)