blob: afd18c32396c797553bfd9b8ec5947c1b1a4da64 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/bin/bash
build()
{
for FMT in $FORMATS
do
mkdir -p build/pandoc/$FMT
OPTS="-f rst"
case $FMT in
"html") OPTS="$OPTS -t html --variable lang=it"
EXT=".html"
SPLIT=true;;
"latex") OPTS="$OPTS -t latex --variable lang=italian"
EXT=".tex"
SPLIT=true;;
"pdf") OPTS="$OPTS --latex-engine=xelatex --variable lang=italian"
EXT=".pdf"
SPLIT=true;;
"epub") OPTS="$OPTS -t epub --variable lang=it"
EXT=".epub"
SPLIT=false;;
esac
if $SPLIT
then
mkdir -p build/pandoc/$FMT/$TARGET
for FNAME in $TARGET/*.rst
do
pandoc $OPTS -o build/pandoc/$FMT/${FNAME/.rst/}$EXT $FNAME
done
else
pandoc $OPTS -o build/pandoc/$FMT/$TARGET$EXT $TARGET/*.rst
fi
done
}
print_help()
{
echo "Usage: pandoc_build.sh [-H] [-l] [-p] [-e]"
echo " {esempi,strumenti} [{esempi,strumenti} ...]"
echo "Options:"
echo " -H HTML5 snippet"
echo " -l latex snippet"
echo " -p PDF"
echo " -e epub"
}
# Option parsing
FORMATS=""
while getopts "hHlpoe" Option
do
case $Option in
h) print_help
exit;;
H) FORMATS="$FORMATS html";;
l) FORMATS="$FORMATS latex";;
p) FORMATS="$FORMATS pdf";;
e) FORMATS="$FORMATS epub";;
esac
done
shift $(($OPTIND - 1))
for TARGET in $*
do
case $TARGET in
"esempi") build;;
"strumenti") build;;
*) print_help;;
esac
done
|