34 lines
1.2 KiB
Makefile
34 lines
1.2 KiB
Makefile
INFILES := $(shell find ./ -name '*.md' -type f)
|
|
OUTFILES := $(patsubst %.md,%.html,$(INFILES))
|
|
CLEANFILES = $(shell find ./ -mindepth 2 -name '*.html' -type f)
|
|
INDEXFILES := $(patsubst %navigation.md,%index.html,$(filter %navigation.md,$(INFILES)))
|
|
NAVFILES := $(patsubst %navigation.md,%navigation.html,$(filter %navigation.md,$(INFILES)))
|
|
HEADFILES := $(patsubst %navigation.html,%header.html,$(NAVFILES))
|
|
SPACE := $(eval) $(eval)
|
|
|
|
|
|
all: $(OUTFILES) $(INDEXFILES) $(HEADFILES) header.txt footer.html
|
|
|
|
%navigation.html: %navigation.md
|
|
sed s/".md"/".html"/ $^ |pandoc -o $*navigation.html
|
|
|
|
%header.html: header.txt $(NAVFILES)
|
|
cat header.txt $(filter ./$(@D)%, $(NAVFILES)) > $@
|
|
|
|
%index.html: $(HEADFILES) footer.html
|
|
cat $(filter ./$(@D)%, $(HEADFILES)) footer.html > $@
|
|
|
|
%.html: %.md $(HEADFILES) footer.html
|
|
sed 's|href="|href="$(subst $(SPACE),,$(patsubst %,../,$(wordlist 2,3,$(subst /, ,$(@D)))))|g' $(filter ./$(word 1, $(subst /, ,$(@D)))/%, $(HEADFILES)) > $(@D)/tmpnav.html
|
|
cat endnav.txt >> $(@D)/tmpnav.html
|
|
pandoc --toc -s $(filter %.md,$^) -H head.txt -B $(@D)/tmpnav.html -A footer.html -o $*.html
|
|
|
|
header.txt:
|
|
|
|
footer.html:
|
|
|
|
cleanhtml:
|
|
rm $(CLEANFILES)
|
|
|
|
|