blob: 4761f3730a9e32effe21efe20fa8a2a457f5c92f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/bin/sh
#
# toPDF.sh
#
# Usage: toPDF.sh [-o] INPUTFILE
#
# Compiles a file to a temporal PDF using pandoc, updating the temporal file if
# it already exists.
# Opens the file with $READER if -o option is given.
open=""
if [ "$1" = "-o" ]; then
open="1"
shift
fi
[ -z "$1" ] && exit 1
targetDir="/tmp/toPDF"
sourceFile="$1"
targetFile="${targetDir}/${sourceFile##*/}"
targetFile="${targetFile%.*}.pdf"
extension="${sourceFile##*.}"
texengine="xelatex"
[ -d "$targetDir" ] || mkdir -p "$targetDir"
case "$extension" in
"tex")
"$texengine" -output-directory "$targetDir" "$sourceFile"
;;
*)
pandoc "$sourceFile" -o "$targetFile" > ~/logs/toPDF.log
;;
esac
[ -n "$open" ] && "$READER" "$targetFile" &
|