aboutsummaryrefslogtreecommitdiff
path: root/docs/makefile
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-11-18 14:48:58 +0100
committerlonkaars <loek@pipeframe.xyz>2022-11-18 14:48:58 +0100
commite47b1ddefa9989594bb81bd872b88c085cd777bc (patch)
tree288cee427d326814766a0f54a56601dfe1b6dffd /docs/makefile
parenta1b15467c49cea4080898b970cbc90e4fd4a32fd (diff)
WIP table of contents
Diffstat (limited to 'docs/makefile')
-rw-r--r--docs/makefile10
1 files changed, 8 insertions, 2 deletions
diff --git a/docs/makefile b/docs/makefile
index 9a994e4..843716a 100644
--- a/docs/makefile
+++ b/docs/makefile
@@ -4,11 +4,14 @@ M4 = m4
RM = rm -f
CHROME = chromium
CURL = curl
+PUP = pup
SRCS = $(wildcard *.md)
HTML_T = $(patsubst %.md,%.html, $(SRCS))
PDF_T = $(patsubst %.md,%.pdf, $(SRCS))
+.PRECIOUS: %.toc
+
all: $(HTML_T)
gen/paged.polyfill.js:
@@ -17,8 +20,11 @@ gen/paged.polyfill.js:
gen/start.html: gen/start.m4 gen/style.css
$(M4) -I gen $< > $@
-%.html: %.md gen/start.html gen/paged.polyfill.js
- $(PANDOC) $< --to=html | $(CAT) gen/start.html - gen/end.html > $@
+%.html: %.md %.toc gen/start.html gen/paged.polyfill.js
+ $(PANDOC) $< --to=html | $(CAT) gen/start.html $(word 2,$^) - gen/end.html > $@
+
+%.toc: %.md
+ $(PANDOC) $< -s --toc --to=html 2> /dev/null | $(PUP) '#TOC' | sed -r 's/<(.?)ul>/<\1ol>/g' > $@
%.pdf: %.html
$(CHROME) --headless --print-to-pdf=$@ $< 2> /dev/null