Skip to content

Instantly share code, notes, and snippets.

@jcchurch
Created July 29, 2020 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcchurch/2eff2240ee318bcbb438b5c12e6d24ab to your computer and use it in GitHub Desktop.
Save jcchurch/2eff2240ee318bcbb438b5c12e6d24ab to your computer and use it in GitHub Desktop.
#!/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