Skip to content

Commit fd46d6d

Browse files
committed
Update genindex.py
1 parent 7fcbeb5 commit fd46d6d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

utils/genIndex.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#coding: utf-8
22
import os
33
import re
4+
from functools import partial
45
import markdown
56
import shutil
67
from getSize import getSize
78
from config import PATH, HTML, WALKDIR, TARDIR, IGNORE, NAME, DOWNLOAD
89

910
URL = 'https://github.com/USTC-Resource/USTC-Course/tree/master/'
10-
ImagePre = ''
1111
ImagePT = re.compile(r'\!\[(.*?)\]\(([a-zA-Z\d\.].*?)\)')
1212

1313

14-
def subFunc(match):
14+
def subFunc(match,pre):
1515
name, suf = match.groups()
16-
return f'![{name}]({ImagePre+"/"+suf})'
16+
return f'![{name}]({pre+"/"+suf})'
1717

1818
hasPinyin = False
1919
try:
@@ -130,8 +130,7 @@ def genIndex(path, dirs, files, htmlTemp=HTML):
130130
readme=md2html(md))
131131
filename = os.path.join(tar, NAME)
132132
with open(filename, 'w') as f:
133-
ImagePre = URL + path
134-
f.write(re.sub(ImagePT,subFunc,cont))
133+
f.write(re.sub(ImagePT,partial(subFunc,pre = URL+path),cont))
135134

136135

137136
def getPath(path):

0 commit comments

Comments
 (0)