diff options
Diffstat (limited to 'gup')
-rwxr-xr-x | gup/pdf.gup | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/gup/pdf.gup b/gup/pdf.gup index d0ebac5..31515af 100755 --- a/gup/pdf.gup +++ b/gup/pdf.gup | |||
@@ -28,7 +28,11 @@ if [[ $beamerAspects[(i)${2:r:e}] -le $#beamerAspects ]]; then | |||
28 | fi | 28 | fi |
29 | 29 | ||
30 | base=(${2:r}.(md|lhs|tex)([1])) | 30 | base=(${2:r}.(md|lhs|tex)([1])) |
31 | metadata=(${2:r}.meta.yml([1]N)) | 31 | metadata=${2:r}.meta.yml |
32 | |||
33 | if ! [[ -e ${metadata} ]] && ! gup --buildable ${metadata}; then | ||
34 | metadata="" | ||
35 | fi | ||
32 | 36 | ||
33 | gup -u ${base} ${metadata} preamble.tex | 37 | gup -u ${base} ${metadata} preamble.tex |
34 | 38 | ||
@@ -41,9 +45,13 @@ cd ${base:h} | |||
41 | input=${base} | 45 | input=${base} |
42 | 46 | ||
43 | typeset -a extraArgs | 47 | typeset -a extraArgs |
44 | extraArgs=(-R -V "geometry=margin=2cm" -V "fontfamily=libertine" -H ${buildDir}/preamble.tex --listings --latex-engine=lualatex --filter=pandoc-citeproc --biblatex) | 48 | extraArgs=(-R -V "geometry=margin=2cm" -V "fontfamily=libertine" -H ${buildDir}/preamble.tex --listings --latex-engine=lualatex --biblatex) |
49 | #extraArgs+=(--filter=pandoc-citeproc) | ||
45 | 50 | ||
46 | 51 | ||
52 | compileDir=$(mktemp -d) | ||
53 | cleanupList+=("cd /" "rm -rfv ${compileDir}") | ||
54 | |||
47 | if [[ -n ${metadata} ]]; then | 55 | if [[ -n ${metadata} ]]; then |
48 | input=$(mktemp) | 56 | input=$(mktemp) |
49 | cleanupList+=("rm -v ${input}") | 57 | cleanupList+=("rm -v ${input}") |
@@ -56,10 +64,19 @@ if [[ -n ${metadata} ]]; then | |||
56 | logged pandoc -R ${class} -t native ${base} >>${input} | 64 | logged pandoc -R ${class} -t native ${base} >>${input} |
57 | 65 | ||
58 | extraArgs+=(-f native) | 66 | extraArgs+=(-f native) |
59 | fi | ||
60 | 67 | ||
61 | compileDir=$(mktemp -d) | 68 | |
62 | cleanupList+=("cd /" "rm -rfv ${compileDir}") | 69 | bibFiles=$(pandoc -f markdown -t json -s ${metadata} | jq -r '.meta.bibliography.c[] | (.c[0].c)? // .c') |
70 | |||
71 | gup -u ${(f)bibFiles} | ||
72 | |||
73 | for bibFile (${(f)bibFiles}); do | ||
74 | targetPath=${compileDir}/$(realpath --relative-to=${base:h} -- ${base:h}/${bibFile:h}) | ||
75 | |||
76 | [[ ! -e ${targetPath} ]] && logged mkdir -p ${targetPath} | ||
77 | logged cp ${bibFile} ${targetPath}/${bibFile:t} | ||
78 | done | ||
79 | fi | ||
63 | 80 | ||
64 | if [[ ${base:t:r} == "presentation" ]]; then | 81 | if [[ ${base:t:r} == "presentation" ]]; then |
65 | gup -u ${buildDir}/beamer-template.tex | 82 | gup -u ${buildDir}/beamer-template.tex |
@@ -70,15 +87,10 @@ fi | |||
70 | logged pandoc ${extraArgs} -o ${compileDir}/${base:t:r}.tex ${input} >&2 | 87 | logged pandoc ${extraArgs} -o ${compileDir}/${base:t:r}.tex ${input} >&2 |
71 | 88 | ||
72 | cd ${compileDir} | 89 | cd ${compileDir} |
73 | for f (bib); do | ||
74 | printf "Checking for ā%sā\n" ${base:h}/${f} >&2 | ||
75 | [[ -e ${base:h}/${f} ]] || continue | ||
76 | logged rsync -av ${base:h}/${f} . | ||
77 | done | ||
78 | 90 | ||
79 | # cat -n ${base:t:r}.tex >&2 | 91 | # cat -n ${base:t:r}.tex >&2 |
80 | 92 | ||
81 | max=5 | 93 | max=10 |
82 | runs=0 | 94 | runs=0 |
83 | run=true | 95 | run=true |
84 | while ${run} && [[ ${runs} -lt ${max} ]]; do | 96 | while ${run} && [[ ${runs} -lt ${max} ]]; do |