update `Makefile`

urosm 2024-04-12 22:28:47 +02:00
parent f859aa360e
commit 123d764286
2 changed files with 101 additions and 40 deletions

101
Makefile 100644
View File

@ -0,0 +1,101 @@
SHELL = /bin/sh
.SUFFIXES:
# collect notes, sorted by time
notes := $(wildcard $(shell ls -t *.md))
# functions for pages and parts, takes a list of notes as the only argument
getpages = $(patsubst %.md,public_html/%.html,$(1))
getparts = $(patsubst %.md,partials/%.html,$(1))
# collect orphans
orphans = $(filter-out \
$(call getpages,$(notes)),\
$(wildcard public_html/*.html) $(wildcard public_html/.*.html))
.PHONY: all
all: $(call getpages,$(notes))
$(if $(orphans),$(RM) $(orphans))
.PHONY: hidden
hidden: notes := $(wildcard $(shell ls -t .*.md *.md))
hidden: all
public_html/%.html: %.md sitemap.json links.json
$(eval deps := $(shell jq -r '.["$<"] | unique | join(" ")' links.json))
$(if $(deps), $(MAKE) $(call getparts,$(deps)))
pandoc \
--data-dir pandoc \
--defaults bavbavhaus.net.yaml \
--template bavbavhaus.net.html5 \
--metadata url=$< \
--lua-filter insert_sitemap.lua \
--lua-filter insert_links.lua \
--lua-filter update_internal_targets.lua \
--output $@ \
$<
# preserve `partials/%.html` intermediate files
.PRECIOUS: partials/%.html
partials/%.html: %.md | partials
pandoc \
--data-dir pandoc \
--defaults bavbavhaus.net.yaml \
--template bavbavhaus.net.inline.html5 \
--id-prefix $< \
--metadata url=$< \
--lua-filter update_internal_targets.lua \
--output $@ \
$<
# create `partials` directory if it doesn't exist
partials:
test -d $@ || mkdir $@
# generate `sitemap.json`
sitemap.json: FORCE
pandoc lua pandoc/sitemap.lua $@ $(notes)
# generate `links.json`
links.json: FORCE
pandoc lua pandoc/links.lua $@ $(notes)
FORCE: ;
# clean all targets
.PHONY: clean
clean:
$(RM) $(patsubst %.md,public_html/%.html,$(notes))
$(RM) sitemap.json links.json
$(RM) -r partials
# # dest
# .PHONY: dest
# dest:
# test -d "dest" || mkdir "dest"
#
# # docx
# dest/%.docx: notes/%.md\
# pandoc/defaults/docx.yaml\
# pandoc/reference-sl.docx\
# pandoc/csl/chicago-fullnote-sl.csl\
# pandoc/filters/pandoc-quotes.lua\
# pandoc/filters/delink.lua\
# | dest
# pandoc --data-dir=pandoc -ddocx -o $@ $<
#
# # pdf
# dest/%.pdf: notes/%.md\
# pandoc/defaults/pdf.yaml\
# pandoc/csl/chicago-fullnote-sl.csl\
# | dest
# pandoc --data-dir=pandoc -dpdf -o $@ $<
#
# # presentation
# dest/%.s5.html: notes/%.md\
# pandoc/defaults/s5.yaml\
# pandoc/templates/default.s5\
# pandoc/s5/default/pretty.css\
# pandoc/s5/default/framing.css\
# pandoc/csl/chicago-fullnote-sl.csl\
# pandoc/filters/pandoc-quotes.lua\
# | dest
# pandoc --data-dir=pandoc -ds5 -o $@ $<

View File

@ -1,40 +0,0 @@
SHELL = /bin/sh
# ikiwiki
.PHONY: all
all:
rm -f public_html/*.html
pandoc lua pandoc/bavbavhaus.net.lua
# dest
.PHONY: dest
dest:
test -d "dest" || mkdir "dest"
# docx
dest/%.docx: notes/%.md\
pandoc/defaults/docx.yaml\
pandoc/reference-sl.docx\
pandoc/csl/chicago-fullnote-sl.csl\
pandoc/filters/pandoc-quotes.lua\
pandoc/filters/delink.lua\
| dest
pandoc --data-dir=pandoc -ddocx -o $@ $<
# pdf
dest/%.pdf: notes/%.md\
pandoc/defaults/pdf.yaml\
pandoc/csl/chicago-fullnote-sl.csl\
| dest
pandoc --data-dir=pandoc -dpdf -o $@ $<
# presentation
dest/%.s5.html: notes/%.md\
pandoc/defaults/s5.yaml\
pandoc/templates/default.s5\
pandoc/s5/default/pretty.css\
pandoc/s5/default/framing.css\
pandoc/csl/chicago-fullnote-sl.csl\
pandoc/filters/pandoc-quotes.lua\
| dest
pandoc --data-dir=pandoc -ds5 -o $@ $<