diff options
Diffstat (limited to 'gup')
| -rwxr-xr-x | gup/pdf.gup | 30 | 
1 files changed, 24 insertions, 6 deletions
diff --git a/gup/pdf.gup b/gup/pdf.gup index 96f46ca..103aadb 100755 --- a/gup/pdf.gup +++ b/gup/pdf.gup  | |||
| @@ -18,8 +18,17 @@ cleanup() { | |||
| 18 | } | 18 | } | 
| 19 | trap cleanup EXIT | 19 | trap cleanup EXIT | 
| 20 | 20 | ||
| 21 | base=(${2%.pdf}.(md|lhs|tex)([1])) | 21 | typeset -a beamerAspects | 
| 22 | metadata=(${2%.pdf}.meta.yml([1]N)) | 22 | beamerAspects=(43 169) | 
| 23 | beamerAspect=beamerAspects[1] | ||
| 24 | |||
| 25 | if [[ $beamerAspects[(i)${2:r:e}] -le $#beamerAspects ]]; then | ||
| 26 | beamerAspect=${2:r:e} | ||
| 27 | 2=${2:r:r}.${2:e} | ||
| 28 | fi | ||
| 29 | |||
| 30 | base=(${2:r}.(md|lhs|tex)([1])) | ||
| 31 | metadata=(${2:r}.meta.yml([1]N)) | ||
| 23 | 32 | ||
| 24 | gup -u ${base} ${metadata} preamble.tex | 33 | gup -u ${base} ${metadata} preamble.tex | 
| 25 | 34 | ||
| @@ -39,18 +48,25 @@ if [[ -n ${metadata} ]]; then | |||
| 39 | input=$(mktemp) | 48 | input=$(mktemp) | 
| 40 | cleanupList+=("rm -v ${input}") | 49 | cleanupList+=("rm -v ${input}") | 
| 41 | 50 | ||
| 51 | typeset -a class | ||
| 52 | class=() | ||
| 53 | [[ ${base:e} == "tex" ]] && class=(-f latex) | ||
| 54 | |||
| 42 | logged pandoc -f markdown -t native -s ${metadata} | head -n -1 >>${input} | 55 | logged pandoc -f markdown -t native -s ${metadata} | head -n -1 >>${input} | 
| 43 | logged pandoc -R -t native ${base} >>${input} | 56 | logged pandoc -R ${class} -t native ${base} >>${input} | 
| 44 | 57 | ||
| 45 | extraArgs+=(-f native) | 58 | extraArgs+=(-f native) | 
| 46 | fi | 59 | fi | 
| 47 | 60 | ||
| 48 | # logged pandoc ${extraArgs} -t latex ${base} | cat -n >&2 | ||
| 49 | |||
| 50 | compileDir=$(mktemp -d) | 61 | compileDir=$(mktemp -d) | 
| 51 | cleanupList+=("cd /" "rm -rfv ${compileDir}") | 62 | cleanupList+=("cd /" "rm -rfv ${compileDir}") | 
| 52 | 63 | ||
| 53 | logged pandoc ${extraArgs} -t latex -o ${compileDir}/${base:t:r}.tex ${input} >&2 | 64 | if [[ ${base:t:r} == "presentation" ]]; then | 
| 65 | gup -u ${buildDir}/beamer-template.tex | ||
| 66 | extraArgs+=(--template=${buildDir}/beamer-template.tex -M "aspectratio=${beamerAspect}") | ||
| 67 | fi | ||
| 68 | |||
| 69 | logged pandoc ${extraArgs} -o ${compileDir}/${base:t:r}.tex ${input} >&2 | ||
| 54 | 70 | ||
| 55 | cd ${compileDir} | 71 | cd ${compileDir} | 
| 56 | for f (bib); do | 72 | for f (bib); do | 
| @@ -59,6 +75,8 @@ for f (bib); do | |||
| 59 | logged rsync -av ${base:h}/${f} . | 75 | logged rsync -av ${base:h}/${f} . | 
| 60 | done | 76 | done | 
| 61 | 77 | ||
| 78 | # cat -n ${base:t:r}.tex >&2 | ||
| 79 | |||
| 62 | max=5 | 80 | max=5 | 
| 63 | runs=0 | 81 | runs=0 | 
| 64 | run=true | 82 | run=true | 
