Skip to content

Commit

Permalink
Update genindex.py
Browse files Browse the repository at this point in the history
  • Loading branch information
heqin-zhu committed Jun 8, 2019
1 parent 7fcbeb5 commit fd46d6d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions utils/genIndex.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#coding: utf-8
import os
import re
from functools import partial
import markdown
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):
def subFunc(match,pre):
name, suf = match.groups()
return f'![{name}]({ImagePre+"/"+suf})'
return f'![{name}]({pre+"/"+suf})'

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


def getPath(path):
Expand Down

0 comments on commit fd46d6d

Please sign in to comment.