From 76d23194ab7fdd0dfff7e4c7908f4ff9fe4b3dce Mon Sep 17 00:00:00 2001 From: urosm Date: Thu, 2 May 2024 20:10:51 +0200 Subject: [PATCH] update `Makefile` --- Makefile | 91 +++++++++----------------------------------------------- 1 file changed, 14 insertions(+), 77 deletions(-) diff --git a/Makefile b/Makefile index 878de7f..948ea92 100644 --- a/Makefile +++ b/Makefile @@ -1,101 +1,38 @@ 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 +# functions for pages, and parts, takes a list of sources 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)) +getparts = $(patsubst %.md,public_html/%.html.part,$(1)) -all: $(call getpages,$(notes)) - $(if $(orphans),$(RM) $(orphans)) +all: $(call getpages,$(shell pandoc lua pandoc/links.lua --follow index.md)) .PHONY: all -hidden: notes := $(wildcard $(shell ls -t .*.md *.md)) -hidden: all -.PHONY: hidden - -public_html/%.html: %.md sitemap.json links.json pandoc/templates/bavbavhaus.net.html5 - $(eval deps := $(shell jq -r '.["$<"] | join(" ")' links.json)) - $(if $(deps), $(MAKE) $(call getparts,$(deps))) +public_html/%.html: %.md + $(eval links := $(shell pandoc lua pandoc/links.lua $<)) + $(if $(links),$(MAKE) $(call getparts,$(links))) 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 \ + --metadata url=$*.html \ + $(patsubst %,--metadata links=%,$(filter-out $<,$^)) \ --output $@ \ $< -partials/%.html: %.md pandoc/templates/bavbavhaus.net.inline.html5 | partials +public_html/%.html.part: %.md pandoc \ --data-dir pandoc \ --defaults bavbavhaus.net.yaml \ --template bavbavhaus.net.inline.html5 \ - --id-prefix $< \ - --metadata url=$< \ - --lua-filter update_internal_targets.lua \ + --id-prefix $* \ + --metadata url=$*.html \ --output $@ \ $< -# preserve `partials/%.html` intermediate files -.PRECIOUS: partials/%.html -# 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 -clean: - $(RM) $(patsubst %.md,public_html/%.html,$(notes)) - $(RM) sitemap.json links.json - $(RM) -r partials .PHONY: clean - -# # 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 $@ $< +clean: + $(RM) public_html/*.html.part + $(RM) public_html/*.html