forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_h1.py
More file actions
18 lines (18 loc) 路 690 Bytes
/
Copy pathsync_h1.py
File metadata and controls
18 lines (18 loc) 路 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json, re
from pathlib import Path
for f in sorted(Path(__file__).resolve().parent.parent.joinpath('lessons').glob('**/*.md')):
if any(x in str(f) for x in ['_archive','locales','TEMPLATE','README','index']): continue
c = f.read_text()
if not c.startswith('---'): continue
end = c.index('---', 3)
try: fm = json.loads(c[3:end].strip())
except: continue
eng = fm.get('title', '')
if not eng: continue
lines = c.split('\n')
for i, line in enumerate(lines):
if line.startswith('# ') and line[2:].strip() != eng.strip():
lines[i] = '# ' + eng
break
f.write_text('\n'.join(lines), encoding='utf-8')
print('done')