tmp_compile.sh (769B)
1 # Compiles the flashcard with the given ID to PDF, 2 # adding the necessary frontmatter beforehand. 3 4 if [ $# -eq 0 ] 5 then 6 echo "USAGE: ./tmp_compile.sh <flashcard_id>" 7 exit 1 8 fi 9 10 if [ ! -e "flashcards/$1" ] 11 then 12 echo "File doesn't exist: flashcards/$1" 13 exit 1 14 fi 15 16 meta1=`head -n 1 "flashcards/$1" | tr -d '\n' | sed 's/\|.*$//'` 17 meta2=`sed '2!d' "flashcards/$1" | tr -d '\n'` 18 body=`tail -n +3 "flashcards/$1"` 19 printf '\\documentclass[grid,avery5371]{flashcards}\n' > tmp_compile.tex 20 cat defs.tex >> tmp_compile.tex 21 printf '\\cardfrontstyle{headings}\n' >> tmp_compile.tex 22 printf '\\begin{document}\n\\begin{flashcard}[%s]{%s}\n%s\n\\end{flashcard}\n\\end{document}\n' "$meta1" "$meta2" "$body" >> tmp_compile.tex 23 pdflatex tmp_compile.tex 24 rm tmp_compile.{aux,log,tex}