blob: a383c0914638de8f4755fcda5e305a37e3c78339 (
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
|
#!/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"
[ -d "$targetDir" ] || mkdir -p "$targetDir"
pandoc "$sourceFile" -o "$targetFile"
[ -n "$open" ] && "$READER" "$targetFile" &
|