Skip to content

Instantly share code, notes, and snippets.

@npryce
Created December 16, 2016 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npryce/af179f01f48272c9bfe6351af513bd64 to your computer and use it in GitHub Desktop.
Save npryce/af179f01f48272c9bfe6351af513bd64 to your computer and use it in GitHub Desktop.
Pandoc Makefile example
MARKDOWN_SRC:=$(shell find doc -name '*.md')
DIAGRAM_SRC:=$(shell find doc -name '*.plantuml')
MARKDOWN_FORMAT=markdown+fenced_code_blocks+fenced_code_attributes+grid_tables+footnotes
# Order is significant when multiple CSS files
CSS_SRC:=styles/style.css
SITE_HTML=$(MARKDOWN_SRC:doc/%.md=out/site/%.html) $(DIAGRAM_SRC:doc/%.plantuml=out/site/%.png)
SITE_CSS=$(CSS_SRC:styles/%=out/site/%)
all: $(SITE_HTML) $(SITE_CSS)
VPATH=doc:styles:out/tmp
out/site/%.html: %.md
@mkdir -p $(dir $@)
pandoc --standalone --from=$(MARKDOWN_FORMAT) --to=html \
--css http://fonts.googleapis.com/css?family=Raleway:400,300,600 \
--css $(shell echo '$(patsubst out/site/%,%,$@)' | sed -e s:[^/]::g -e s:/:../:g)style.css \
$^ \
| sed 's/\(<a href=".*\.\)\(md\)\(">\)/\1html\3/g' \
> $@
out/site/%: %
@mkdir -p $(dir $@)
cp $^ $@
out/site/%.png: %.plantuml
@mkdir -p $(dir $@)
cat $< | plantuml -pipe > $@
clean:
rm -rf .cache/
rm -rf out/
.PHONY: clean site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment