Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fd46d6d

Browse filesBrowse files
committed
Update genindex.py
1 parent 7fcbeb5 commit fd46d6d
Copy full SHA for fd46d6d

File tree

Expand file treeCollapse file tree

1 file changed

+4
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-5
lines changed

‎utils/genIndex.py

Copy file name to clipboardExpand all lines: utils/genIndex.py
+4-5Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.