forked from ualib/agda-algebras
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-tex
executable file
·42 lines (34 loc) · 1.21 KB
/
generate-tex
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
#!/bin/bash
SRCDIR="src"
echo "SRCDIR = $SRCDIR"
INCLDIR="_includes"
echo "INCLDIR = $INCLDIR"
## markdown formatted links (to be appended before pandoc processing)
LINKFILE="$INCLDIR/UALib.Links.md"
#echo "LINKFILE = $LINKFILE"
## absolute module names with no src/ prefix and no .lagda suffix
CHOPMODS=$(find $SRCDIR -name "*.lagda" | sed -e 's|^src/[/]*||' -e 's|.lagda||')
# echo "CHOPMODS = $CHOPMODS"
## Options for the pandoc command
# (not using --top-level-division=part )
PANOPTS="-f markdown -t latex"
if [ $# -eq 0 ]
then
echo "No arguments supplied... processing ALL modules..."
for f in $CHOPMODS; do
echo "processing $f.lagda";
agda --latex --only-scope-checking src/$f.lagda;
cat $LINKFILE >> latex/$f.tex;
DOTNAME="latex/$(echo $f | sed 's|/|.|g').tex"
pandoc $PANOPTS latex/$f.tex -o $DOTNAME
sed -i '/[\]begin[{]center[}][\]rule/,$d' $DOTNAME;
done
else
echo "Processing $1 only..."
f="$(echo $1 | sed -e 's|^src/[/]*||' -e 's|.lagda||')"
agda --latex src/$f.lagda
cat $LINKFILE >> latex/$f.tex
DOTNAME="latex/$(echo $f | sed 's|/|.|g').tex"
pandoc $PANOPTS latex/$f.tex -o $DOTNAME
sed -i '/[\]begin[{]center[}][\]rule/,$d' $DOTNAME
fi