Created
July 29, 2020 18:41
-
-
Save jcchurch/2eff2240ee318bcbb438b5c12e6d24ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import subprocess | |
import glob | |
import os | |
import os.path | |
import sys | |
def getProcessOutput(myCommand): | |
call = subprocess.Popen(myCommand, stdin=subprocess.PIPE, stdout=subprocess.PIPE) | |
call.wait() | |
(output, error) = call.communicate() | |
decode = "BAD OUTPUT" | |
try: | |
decode = output.decode("utf-8") | |
except UnicodeDecodeError: | |
pass | |
return decode | |
def renderPDF(fullpath): | |
parts = fullpath.split("/") | |
mydir = "/".join(parts[:-1]) | |
newfile = parts[-1].replace(".md", ".pdf") | |
command = "pandoc -t beamer --slide-level 2 --toc -s {} -o {}".format(fullpath, newfile) | |
getProcessOutput(command.split()) | |
if __name__=='__main__': | |
renderPDF(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment