forked from kaityo256/python_zero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
37 lines (27 loc) · 1.07 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
INDEX=$(shell ls */README.md | sed 's/README.md/index.html/')
PANDOC_HTMLOPT=--mathjax -t html --template=template
PANDOC_TEXOPT=--highlight-style tango --latex-engine=lualatex -V documentclass=ltjarticle -V geometry:margin=1in -H ../mytemplate.tex
TARGET=$(INDEX)
ASSIGNMENT=$(shell grep --exclude=answer/*.md -l ^\#.*課題 */README.md | sed 's/README.md/assignment.pdf/')
all: $(TARGET) index.html
pdf: $(ASSIGNMENT)
index.md: README.md
sed 's/README.md/index.html/' $< > $@
sed -i 's/assignment.md/assignment.html/' $@
index.html: index.md
pandoc -s $< -o $@ $(PANDOC_HTMLOPT)
rm -f index.md
%/index.md: %/README.md
sed '2a [[Up]](../index.html)' $< > $@
sed -i '3a [[Repository]](https://github.com/kaityo256/python_zero)\n' $@
sed -i 's/assignment.md/assignment.html/' $@
%/index.html: %/index.md
pandoc -s $< -o $@ $(PANDOC_HTMLOPT)
%/assignment.md: %/README.md
sed -n '/^##\s.*課題/,$$p' $< > $@
%/assignment.pdf: %/assignment.md
cd $(dir $@);pandoc $(notdir $<) -s -o $(notdir $@) $(PANDOC_TEXOPT)
clean-pdf:
rm -f $(ASSIGNMENT)
clean:
rm -f $(TARGET) index.html