summaryrefslogtreecommitdiffstats
path: root/build.sh
blob: 306c572c97fb9d2e7c1a21cd29bb68540157028c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

build() {
	if ! grep '\\begin{document}' "$f" 1>/dev/null; then
		return
	fi

	latexmk "$f"
	pdf="$(printf %s "$f" | sed 's/\.tex$/.pdf/')"
	out="build/$(dirname "$f" | xargs basename | sed 's/^src$//')"
	mkdir -p "$out" && cp "$pdf" "$out"
}

for f in ./src/*.tex; do
	build "$f"
done

for f in ./src/**/*.tex; do
	build "$f"
done