Skip to content

Instantly share code, notes, and snippets.

@giuliano-macedo
Created August 28, 2020 23:59
Show Gist options
  • Save giuliano-macedo/d2ba2ee2864116ca41104c2e8a5845f4 to your computer and use it in GitHub Desktop.
Save giuliano-macedo/d2ba2ee2864116ca41104c2e8a5845f4 to your computer and use it in GitHub Desktop.
pandoc + nodemon tool, need eisvogel template
#!/usr/bin/env python3
import argparse
import os
parser=argparse.ArgumentParser()
parser.add_argument("input",type=str)
args=parser.parse_args()
out_pdf=os.path.splitext(os.path.split(args.input)[-1])[0] +".pdf"
##create empty pdf file
#https://stackoverflow.com/a/17280876/5133524
with open(out_pdf,"w") as f:
f.write("%PDF-1.0\n1 0 obj<</Pages 2 0 R>>endobj 2 0 obj<</Kids[3 0 R]/Count 1>>endobj 3 0 obj<</MediaBox[0 0 3 3]>>endobj\ntrailer<</Root 1 0 R>>")
os.system(f"evince {out_pdf}&")
exec_=f"pandoc -f commonmark_x --template eisvogel --listings {args.input} -o {out_pdf}"
os.system(f"nodemon --exec '{exec_}' -e 'md'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment