render_card.sh - flashcards - Stupid LaTeX flashcard viewer
HTML git clone git://lumidify.org/flashcards.git (fast, but not encrypted)
HTML git clone https://lumidify.org/git/flashcards.git (encrypted, but very slow)
HTML git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/flashcards.git (over tor)
DIR Log
DIR Files
DIR Refs
DIR README
---
render_card.sh (677B)
---
1 #!/bin/sh
2
3 filename="`basename $1`"
4
5 defs=`cat "$2"`
6 meta1=`head -n 1 "$1" | tr -d '\n' | sed 's/|.*$//'`
7 meta2=`sed '2!d' "$1" | tr -d '\n'`
8 body=`tail -n +3 "$1"`
9
10 mkdir tmp
11 cd tmp
12
13 echo '\\documentclass[12pt]{article}' > tmp.tex
14 printf '%s' $defs >> tmp.tex
15 echo '\\pagestyle{empty}' >> tmp.tex
16 printf '\\begin{document}\n%s\n\\newpage\n%s\n\\newpage\n%s\n\\end{document}\n' "$meta1" "$meta2" "$body" >> tmp.tex
17 pdflatex tmp.tex
18 pdfcrop --margins "5 5 5 5" tmp.pdf tmp1.pdf
19 pdftoppm -png -rx 200 -ry 200 tmp1.pdf tmp
20 mv tmp-1.png "../cache/${filename}_front1.png"
21 mv tmp-2.png "../cache/${filename}_front2.png"
22 mv tmp-3.png "../cache/${filename}_back.png"
23
24 cd ..
25 rm -rf tmp