-
Notifications
You must be signed in to change notification settings - Fork 0
/
md2tex.py
28 lines (21 loc) · 1018 Bytes
/
md2tex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import re
from subprocess import check_output
find_md = re.compile(r'\S*\.md')
file = input('请输入要转换的文件名:(.md)\n')
if file == '':
file = check_output('dir', shell=True).decode('gb18030')
file = find_md.search(file).group()
file = file[:-3]
print('开始转换', file+'.md', '\n')
res = check_output(r'copy "C:\Files\latex_template\bibtex\gbt7714-bibtex-style\gbt7714.sty"', shell=True).decode('gb18030')
res = check_output(r'copy "C:\Files\latex_template\bibtex\gbt7714-bibtex-style\gbt7714-plain.bst"', shell=True).decode('gb18030')
res = check_output(r'copy "C:\Files\latex_template\bibtex\gbt7714-bibtex-style\gbt7714-unsrt.bst"', shell=True).decode('gb18030')
command = 'pandoc -s --template="C:/Files/latex_template/for_pandoc/mytemp.latex" -o {0}.tex {0}.md'.format(file)
res = check_output(command, shell=True).decode('gb18030')
print(res)
if res == '':
print('完成(*^-^*)')
else:
print('额……\n')
print(res)
input()