44 lines
1.2 KiB
Makefile
44 lines
1.2 KiB
Makefile
SHELL := /bin/bash
|
|
|
|
TARGETS := $(patsubst %.md,%.html,$(wildcard *.md))
|
|
CSSINC := assets/css.inc
|
|
|
|
# our main html5 template, mostly taken from :
|
|
# https://github.com/jgm/pandoc-templates/blob/master/default.html5
|
|
TEMPLATE := assets/pandoc-template.html5
|
|
|
|
# CSS to be included as stylesheets and alternate stylesheets
|
|
CSS := assets/ghost.css
|
|
ALTCSS := assets/ghost-dark.css assets/ghost-caca.css
|
|
|
|
OPTS := --standalone --include-in-header=$(CSSINC) --template=$(TEMPLATE) \
|
|
--metadata=title:"$(call TIT,$<)" --from=gfm --to=html5
|
|
|
|
# To provide a title to pandoc. We take the first line starting with '#',
|
|
# and remove initial '#' and spaces
|
|
TITLE = $(shell sed -n '0,/^#/ s/^[# ]*//p' $1)
|
|
|
|
define ADD_LINE
|
|
printf '<link rel="%s" href="%s">\n' "$(2)" "$(1)" >> $(3);
|
|
endef
|
|
|
|
.PHONY: all html clean $(CSSINC)
|
|
|
|
all: $(CSSINC) html
|
|
|
|
html: $(TARGETS)
|
|
|
|
clean:
|
|
@echo cleaning $(TARGETS) $(CSSINC)
|
|
@rm -f $(TARGETS) $(CSSINC)
|
|
|
|
$(CSSINC): $(_CSS) $(_ALTCSS)
|
|
@echo generating $@
|
|
@rm -f $@
|
|
@$(foreach css,$(_CSS),$(call ADD_LINE,$(css),stylesheet,$@))
|
|
@$(foreach css,$(_ALTCSS),$(call ADD_LINE,$(css),alternate stylesheet,$@))
|
|
|
|
%.html: %.md $(_CSS)
|
|
@echo generating $@
|
|
@pandoc $(PANDOCOPTS) -o $@ $<
|