diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-06-07 02:14:31 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-06-07 02:14:31 +0200 |
commit | e7b84f8b87da8ea1add3cda9ba3a07cf1f86e7b6 (patch) | |
tree | f0d2de6986e4fa66ebe90f30a81fcf943c9c7a45 /gup | |
parent | ff8deaa9ed63e6bd067c45c75966a24f7bfcaab3 (diff) | |
download | uni-e7b84f8b87da8ea1add3cda9ba3a07cf1f86e7b6.tar uni-e7b84f8b87da8ea1add3cda9ba3a07cf1f86e7b6.tar.gz uni-e7b84f8b87da8ea1add3cda9ba3a07cf1f86e7b6.tar.bz2 uni-e7b84f8b87da8ea1add3cda9ba3a07cf1f86e7b6.tar.xz uni-e7b84f8b87da8ea1add3cda9ba3a07cf1f86e7b6.zip |
Much more extensive pdf compiling
Diffstat (limited to 'gup')
-rw-r--r-- | gup/Gupfile | 2 | ||||
-rwxr-xr-x | gup/pdf.gup | 76 | ||||
-rw-r--r-- | gup/ps.gup | 7 |
3 files changed, 81 insertions, 4 deletions
diff --git a/gup/Gupfile b/gup/Gupfile index 0478f35..8912143 100644 --- a/gup/Gupfile +++ b/gup/Gupfile | |||
@@ -1,5 +1,7 @@ | |||
1 | pdf.gup: | 1 | pdf.gup: |
2 | 2 | ||
3 | ps.gup: | ||
4 | **/*.ps | ||
3 | abgabe.gup: | 5 | abgabe.gup: |
4 | **/abgabe.zip | 6 | **/abgabe.zip |
5 | manifest.gup: | 7 | manifest.gup: |
diff --git a/gup/pdf.gup b/gup/pdf.gup index 3b3aa3a..96f46ca 100755 --- a/gup/pdf.gup +++ b/gup/pdf.gup | |||
@@ -1,9 +1,77 @@ | |||
1 | #!/usr/bin/env zsh | 1 | #!/usr/bin/env zsh |
2 | 2 | ||
3 | base=(${2%.pdf}.(md|lhs)([1])) | 3 | ret=0 |
4 | 4 | ||
5 | gup -u ${base} preamble.tex | 5 | logged() { |
6 | printf ">>> ā%sā in %s\n" "$*" $(pwd) >&2 | ||
7 | ${@} | ||
8 | ret=$? | ||
9 | printf ">>> %d\n" $ret >&2 | ||
10 | } | ||
6 | 11 | ||
7 | for i ({0..1}); do | 12 | typeset -a cleanupList |
8 | pandoc -t latex -o $1 -V "geometry=margin=2cm" -V "fontfamily=libertine" -H preamble.tex --listings --latex-engine=lualatex ${base} >&2 | 13 | cleanupList=() |
14 | cleanup() { | ||
15 | for cmd in ${cleanupList}; do | ||
16 | eval $cmd | ||
17 | done | ||
18 | } | ||
19 | trap cleanup EXIT | ||
20 | |||
21 | base=(${2%.pdf}.(md|lhs|tex)([1])) | ||
22 | metadata=(${2%.pdf}.meta.yml([1]N)) | ||
23 | |||
24 | gup -u ${base} ${metadata} preamble.tex | ||
25 | |||
26 | buildDir=$(pwd) | ||
27 | |||
28 | base=${base:A} | ||
29 | metadata=${metadata:A} | ||
30 | cd ${base:h} | ||
31 | |||
32 | input=${base} | ||
33 | |||
34 | typeset -a extraArgs | ||
35 | extraArgs=(-R -V "geometry=margin=2cm" -V "fontfamily=libertine" -H ${buildDir}/preamble.tex --listings --latex-engine=lualatex --filter=pandoc-citeproc --biblatex) | ||
36 | |||
37 | |||
38 | if [[ -n ${metadata} ]]; then | ||
39 | input=$(mktemp) | ||
40 | cleanupList+=("rm -v ${input}") | ||
41 | |||
42 | logged pandoc -f markdown -t native -s ${metadata} | head -n -1 >>${input} | ||
43 | logged pandoc -R -t native ${base} >>${input} | ||
44 | |||
45 | extraArgs+=(-f native) | ||
46 | fi | ||
47 | |||
48 | # logged pandoc ${extraArgs} -t latex ${base} | cat -n >&2 | ||
49 | |||
50 | compileDir=$(mktemp -d) | ||
51 | cleanupList+=("cd /" "rm -rfv ${compileDir}") | ||
52 | |||
53 | logged pandoc ${extraArgs} -t latex -o ${compileDir}/${base:t:r}.tex ${input} >&2 | ||
54 | |||
55 | cd ${compileDir} | ||
56 | for f (bib); do | ||
57 | printf "Checking for ā%sā\n" ${base:h}/${f} >&2 | ||
58 | [[ -e ${base:h}/${f} ]] || continue | ||
59 | logged rsync -av ${base:h}/${f} . | ||
60 | done | ||
61 | |||
62 | max=5 | ||
63 | runs=0 | ||
64 | run=true | ||
65 | while ${run} && [[ ${runs} -lt ${max} ]]; do | ||
66 | output=$(mktemp) | ||
67 | cleanupList+=("rm -v ${output}") | ||
68 | logged lualatex ${base:t:r}.tex >${output} </dev/null | ||
69 | ( return $ret ) || { logged cat ${output}; break } | ||
70 | grep -C 2 -i "warning" ${output} | ||
71 | run=false | ||
72 | grep -Eq $'(\\(re\\)run Biber)|(Please rerun LaTeX)' ${output} && run=true | ||
73 | [[ -e ${base:t:r}.bcf && runs -eq 0 ]] && logged biber ${base:t:r} | ||
74 | runs=$((runs + 1)) | ||
9 | done | 75 | done |
76 | |||
77 | cp -v ${base:t:r}.pdf $1 | ||
diff --git a/gup/ps.gup b/gup/ps.gup new file mode 100644 index 0000000..f4d158e --- /dev/null +++ b/gup/ps.gup | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/usr/bin/env zsh | ||
2 | |||
3 | base=${2:r}.pdf | ||
4 | |||
5 | gup -u ${base} | ||
6 | |||
7 | pdf2ps ${base} $1 \ No newline at end of file | ||