Created
July 13, 2020 17:03
-
-
Save machouinard/06d66bdb3e2277f30a960c4f9e18ad13 to your computer and use it in GitHub Desktop.
Convert single or bulk files from markdown to other formats using Pandoc.
This file contains hidden or 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
SRC := $(wildcard *.md) | |
OUTPUT=\ | |
$(SRC:.md=.html) \ | |
$(SRC:.md=.pdf) \ | |
$(SRC:.md=.docx) \ | |
$(SRC:.md=.rtf) \ | |
PDFOUT=\ | |
$(SRC:.md=.pdf)\ | |
RM=/bin/rm | |
PANDOC=/usr/local/bin/pandoc | |
OPTS=-f markdown+smart | |
HTML_OPTS=-o html5 -s | |
PDF_OPTS=--pdf-engine=xelatex | |
DOCX_OPTS= | |
RTF_OPTS=-s | |
# Command matching | |
%.html : %.md | |
$(PANDOC) $(OPTS) $(HTML_OPTS) -o $@ $< | |
%.pdf : %.md | |
$(PANDOC) $(OPTS) $(PDF_OPTS) -o $@ $< | |
%.docx : %.md | |
$(PANDOC) $(OPTS) $(DOCX_OPTS) -o $@ $< | |
%.rtf : %.md | |
$(PANDOC) $(OPTS) $(RTF_OPTS) -o $@ $< | |
# Phony targets | |
# Run `make` or `make all` to convert to all types. | |
# Run `make name.pdf` to convert name.md to PDF | |
# Run `make clean` to delete all converted docs | |
.PHONY: all clean pdf | |
all : $(OUTPUT) | |
pdf : $(PDFOUT) | |
clean: | |
- $(RM) $(OUTPUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment