-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
executable file
·101 lines (88 loc) · 2.75 KB
/
Makefile
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
SOURCEDIR = src
TEMPLATES = templates
BUILDDIR = build
PDFENGINE = lualatex
PDFENGINE_OPT = --shell-escape
SOURCES=$(wildcard $(SOURCEDIR)/*.md)
SLIDES=$(patsubst $(SOURCEDIR)/%.md,$(BUILDDIR)/%.html,$(SOURCES))
PDFS=$(patsubst $(SOURCEDIR)/%.md,$(BUILDDIR)/%.pdf,$(SOURCES))
BOOKS=$(patsubst $(SOURCEDIR)/%.md,$(BUILDDIR)/%.tex,$(SOURCES))
.PHONY: all
all: slides pdfs book
.PHONY: slides
slides: $(SLIDES)
.PHONY: pdfs
pdfs: $(PDFS)
.PHONY: book
book: build/book.pdf
.PHONY: clean
clean:
latexmk -C $(TEMPLATES)/book.tex
rm -f \
$(foreach slide, $(SLIDES), "$(slide)") \
$(foreach pdf, $(PDFS), "$(pdf)") \
$(foreach book, $(BOOKS), "$(book)") \
build/book.*
rmdir --ignore-fail-on-non-empty $(BUILDDIR)
$(SLIDES): $(BUILDDIR)/%.html : $(SOURCEDIR)/%.md
mkdir -p $(BUILDDIR)
sed -e 's/(\(img\/\)/($(SOURCEDIR)\/\1/g' "$^" \
| sed -e "\$$a# Sources" \
| pandoc -s \
-f markdown \
-t dzslides \
--embed-resources \
--standalone \
--lua-filter=meta.lua \
--citeproc \
-V show-notes=true \
-V title="" \
-V title-prefix="HE-Arc" \
-H $(TEMPLATES)/header.html \
-o "$@"
$(PDFS): $(BUILDDIR)/%.pdf : $(SOURCEDIR)/%.md
mkdir -p $(BUILDDIR)
sed -e 's/(\(img\/\)/($(SOURCEDIR)\/\1/g' "$^" \
| sed -e "\$$a# Sources" \
| pandoc -s \
-f markdown+emoji \
-t latex \
--pdf-engine=$(PDFENGINE) \
--pdf-engine-opt=$(PDFENGINE_OPT) \
--lua-filter=meta.lua \
--lua-filter=english.lua \
--citeproc \
-H $(TEMPLATES)/header.tex \
-V documentclass="scrartcl" \
-V links-as-notes=true \
-o "$@"
$(BOOKS): $(BUILDDIR)/%.tex: $(SOURCEDIR)/%.md
mkdir -p $(BUILDDIR)
sed -e 's/(\(img\/\)/($(SOURCEDIR)\/\1/g' "$^" \
| sed -e '0,/<footer>/ s/^#.*$$//g' \
| sed -e 's/<footer>.*<\/footer>//g' \
| sed -e 's/^----*//g' \
| sed -e "\$$a# Sources" \
| pandoc -f markdown+emoji \
-t latex \
--lua-filter=meta.lua \
--lua-filter=english.lua \
--citeproc \
> $@
$(BUILDDIR)/book.pdf: $(TEMPLATES)/book.tex $(BOOKS)
latexmk -pdflua $<
latexmk -c $<
mv book.pdf build/
$(BUILDDIR)/index.html: $(SLIDES)
cat $(TEMPLATES)/indexTop.html > $@
$(foreach source,$(sort $^),echo "<div class="chapter"><a href='$(source)' class='left'>" | sed -e "s/$(BUILDDIR)\///g" >> $@; \
echo $(basename $(source)) | sed -e "s/$(BUILDDIR)\///g" \
-e "s/[[:digit:]]\+-//g" \
-e "s/-/ /g" \
-e "s/\b\(.\)/\u\1/g" >> $@; \
echo "</a><a href='$(patsubst %.html,%.pdf,$(source))' class='right'>PDF</a></div>" | sed -e "s/$(BUILDDIR)\///g" >> $@;)
echo "<a href='book.pdf' class='book'>Livre complet</a>" >> $@
cat $(TEMPLATES)/indexBottom.html >> $@
cat $(SOURCEDIR)/css/normalize.css > $(BUILDDIR)/style.css
cat $(SOURCEDIR)/css/component.css >> $(BUILDDIR)/style.css
cat $(SOURCEDIR)/css/demo.css >> $(BUILDDIR)/style.css