-
Notifications
You must be signed in to change notification settings - Fork 0
/
makePdfs.py
26 lines (21 loc) · 791 Bytes
/
makePdfs.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
#!/usr/bin/env python3
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
import sh
def make_pdf(filename):
parent = str(list(filename.parents)[0])
file_parent = ''
if parent.endswith('algebra'):
file_parent = 'LA-'
elif parent.endswith('datastructures'):
file_parent = 'GAD-'
sh.pandoc(f'{filename}', '-f', 'markdown', '-t', 'latex',
'-o', f'/Users/az/Uni/pdf/{file_parent}{filename.stem}.pdf',
'-S', '--latex-engine=xelatex')
def markdown_files():
cwd = Path('/Users/az/Uni/')
return cwd.glob('**/*.md')
if __name__ == "__main__":
with ThreadPoolExecutor() as executor:
futures = {executor.submit(make_pdf, f) for f in markdown_files()}
_ = [id(f) for f in futures]