Skip to content

Commit 7fcbeb5

Browse files
committed
Correct image index
1 parent 00630c2 commit 7fcbeb5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ course
9393
* [代数结构](./代数结构)
9494
* [光学与原子物理](./光学与原子物理)
9595
* [images](./images)
96+
* [计算机图像学](./计算机图像学)
9697
* [计算机网络](./计算机网络)
9798
* [计算机系统详解](./计算机系统详解)
9899
* [计算机与信息类](./计算机与信息类)

utils/genIndex.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
import shutil
66
from getSize import getSize
77
from config import PATH, HTML, WALKDIR, TARDIR, IGNORE, NAME, DOWNLOAD
8+
9+
URL = 'https://github.com/USTC-Resource/USTC-Course/tree/master/'
10+
ImagePre = ''
11+
ImagePT = re.compile(r'\!\[(.*?)\]\(([a-zA-Z\d\.].*?)\)')
12+
13+
14+
def subFunc(match):
15+
name, suf = match.groups()
16+
return f'![{name}]({ImagePre+"/"+suf})'
17+
818
hasPinyin = False
919
try:
1020
from pypinyin import pinyin
@@ -120,7 +130,8 @@ def genIndex(path, dirs, files, htmlTemp=HTML):
120130
readme=md2html(md))
121131
filename = os.path.join(tar, NAME)
122132
with open(filename, 'w') as f:
123-
f.write(cont)
133+
ImagePre = URL + path
134+
f.write(re.sub(ImagePT,subFunc,cont))
124135

125136

126137
def getPath(path):

0 commit comments

Comments
 (0)