Skip to content

Commit

Permalink
Correct image index
Browse files Browse the repository at this point in the history
  • Loading branch information
heqin-zhu committed Jun 8, 2019
1 parent 00630c2 commit 7fcbeb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -93,6 +93,7 @@ course
* [代数结构](./代数结构)
* [光学与原子物理](./光学与原子物理)
* [images](./images)
* [计算机图像学](./计算机图像学)
* [计算机网络](./计算机网络)
* [计算机系统详解](./计算机系统详解)
* [计算机与信息类](./计算机与信息类)
Expand Down
13 changes: 12 additions & 1 deletion utils/genIndex.py
Expand Up @@ -5,6 +5,16 @@
import shutil
from getSize import getSize
from config import PATH, HTML, WALKDIR, TARDIR, IGNORE, NAME, DOWNLOAD

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


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

hasPinyin = False
try:
from pypinyin import pinyin
Expand Down Expand Up @@ -120,7 +130,8 @@ def genIndex(path, dirs, files, htmlTemp=HTML):
readme=md2html(md))
filename = os.path.join(tar, NAME)
with open(filename, 'w') as f:
f.write(cont)
ImagePre = URL + path
f.write(re.sub(ImagePT,subFunc,cont))


def getPath(path):
Expand Down

0 comments on commit 7fcbeb5

Please sign in to comment.