代码拉取完成,页面将自动刷新
import sys
import os.path
import glob
def getText(l):
l=l.replace('\\citep','')
l=l.replace('\\cite','')
return l
def checkFig(l):
i=l.find('\\includegraph')
if i>=0:
j=l.find('{',i)
if j>=0:
k=l.find('}',j)
if k>=0:
ff=l[j+1:k]
if ff.lower().endswith(".pdf"):
os.system('convert '+ff+" "+ff[0:-4]+".png")
ff=ff[0:-4]+".png"
if os.path.exists(ff): print("\n\n")
else:
ffs=glob.glob(ff+'*')
if len(ffs)>1: print("WARNING ambiguous pic",ffs)
if len(ffs)>=1: print("\n\n")
def texfile(tfich):
with open(tfich,'rb') as f : ls = f.readlines()
empty=False
eq=False
for l in ls:
l=l.strip()
if len(l)==0:
if not empty:
empty=True
print("")
continue
if l[0]=='\\':
if eq:
if l.startswith('\\end{eq'): eq=False
else: print(l)
if l.startswith('\\section'):
print('\n# '+getText(l[9:-1])+'\n')
elif l.startswith('\\subsection'):
print('\n## '+getText(l[12:-1])+'\n')
elif l.startswith('\\subsubsection'):
print('\n### '+getText(l[15:-1])+'\n')
elif l.startswith('\\begin{eq'): eq=True
elif l.startswith('\\input{'):
i=l.find('{')
if i>=0:
j=l.find('}',i)
if j>=0:
texfile(l[i+1:j]+'.tex')
continue
# supprime toutes les lignes qui commencent par \
checkFig(l)
if not empty:
empty=True
print("")
elif l[0]=='%':
# supprime toutes les lignes qui commencent par %
if not empty:
empty=True
print(getText(l))
else:
print(l)
empty=False
texfile(sys.argv[1])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。