OPTIONS = --filter=pandoc-numbering
OPTIONS += --filter=pandoc-crossref

PDFOPTIONS = --highlight-style kate
PDFOPTIONS += --pdf-engine pdflatex
PDFOPTIONS += --number-sections
PDFOPTIONS += --template=./default.latex


HTMLOPTIONS += -t html5
HTMLOPTIONS += -c ../../css/styling.css
HTMLOPTIONS += --self-contained
HTMLOPTIONS += --mathjax=MathJax.js

MD=$(wildcard *.md)
HTML=$(MD:%.md=%.html)
PDF=$(MD:%.md=%.pdf)


all: $(HTML) $(PDF)

%.pdf: %.md Makefile
	sed -e 's/language-python/python/g' -e 's/language-bash/bash/g' $< > $*_tex.md
	pandoc -s $(OPTIONS) $(PDFOPTIONS) -o $@ $<
	rm $*_tex.md

%.html: %.md Makefile
	pandoc -s $(OPTIONS) $(HTMLOPTIONS) -o $@ $<

clean:
	rm -rf *.html *.pdf