Skip to content

Instantly share code, notes, and snippets.

@lmullen
Created September 22, 2012 18:50
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save lmullen/3767386 to your computer and use it in GitHub Desktop.
Save lmullen/3767386 to your computer and use it in GitHub Desktop.
Make all markdown files in directory into PDFs
# Produce PDFs from all Markdown files in a directory
# Lincoln Mullen | http://lincolnmullen.com | lincoln@lincolnmullen.com
# List files to be made by finding all *.md files and appending .pdf
PDFS := $(patsubst %.md,%.md.pdf,$(wildcard *.md))
# The all rule makes all the PDF files listed
all : $(PDFS)
# This generic rule accepts PDF targets with corresponding Markdown
# source, and makes them using pandoc
%.md.pdf : %.md
pandoc $< -o $@
# Remove all PDF outputs
clean :
rm $(PDFS)
# Remove all PDF outputs then build them again
rebuild : clean all
@mesbahamin
Copy link

Exactly what I was looking for, and I learned a thing or two about makefiles too. Thanks!

@eliaszica
Copy link

Very useful, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment