blob: 843716ac6e9159afcb95504cf95a539f803fc517 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
PANDOC = pandoc
CAT = cat
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:
$(CURL) -Ls https://unpkg.com/pagedjs/dist/paged.polyfill.js > $@
gen/start.html: gen/start.m4 gen/style.css
$(M4) -I gen $< > $@
%.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
clean:
$(RM) $(HTML_T) $(PDF_T) gen/start.html gen/paged.polyfill.js
|