3
3
from collections import defaultdict
4
4
5
5
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"---\n comments: 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 ()
16
9
17
-
18
- def format_contest_md_en (content : str ) -> str :
19
10
content = content .replace ("[English Version](/solution/CONTEST_README_EN.md)" , "" )
20
11
content = content .replace ("[中文文档](/solution/CONTEST_README.md)" , "" )
21
12
res = re .findall (r"\[(.*?)\]\((.*?)\)" , content )
@@ -24,20 +15,10 @@ def format_contest_md_en(content: str) -> str:
24
15
num = int (num )
25
16
content = content .replace (link , f"./lc/{ num } .md" )
26
17
content = f"---\n comments: true\n ---\n \n " + content
27
- return content
28
-
29
18
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 )
35
21
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 )
41
22
42
23
code_dict = {
43
24
"py" : ("Python3" , "python" ),
0 commit comments