-
Notifications
You must be signed in to change notification settings - Fork 14
/
languagecheck_overleaf.sh
55 lines (49 loc) · 1.43 KB
/
languagecheck_overleaf.sh
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
#!/bin/bash
if [ -z "$1" ]; then
echo "SYNAPSIS: $0 overleafurl [maintexfile]"
echo
echo "Example: bash languagecheck_overleaf.sh https://www.overleaf.com/1234567890abcdef mypaper.tex"
exit 1
fi
rm -rf overleaf_repo
D=$(dirname $0)
url=$1
giturl=${url/www.overleaf.com/git.overleaf.com/}
echo "Fetching overleaf repository ${giturl} (with git clone)..."
git clone --depth=1 ${giturl} overleaf_repo
pushd overleaf_repo
if [ -z "$2" ]; then
if [ "$(ls *.tex|wc -l)" == "1" ]
then
texname=$(ls *.tex|head -n1)
texname=${texname/.tex/}
echo "Guessing manuscript name: '$texname'"
else
echo "Multiple manuscript names: '$(ls *.tex)'"
echo "call this script again with either: "
for texname in *.tex; do
echo " - bash $0 $url $texname"
done
exit 1
fi
else
texname=$2
texname=${texname/.tex/}
fi
popd
echo "Extracting text from "$texname.tex" file (with detex)..."
bash $D/detex.sh overleaf_repo/$texname.tex || exit 1
pushd overleaf_repo
echo "Running pdflatex on $texname"
pdflatex -interaction batchmode $texname 2>/dev/null
echo "Running bibtex on $texname"
bibtex $texname || exit 1
echo "Running pdflatex again on $texname"
pdflatex -interaction batchmode $texname 2>/dev/null
pdflatex -interaction batchmode $texname || exit 1
popd
echo
echo "Building PDF of the paper seems to have succeeded!"
echo
python ${D}/languagecheck.py overleaf_repo/$texname.{tex,pdf} || exit 1
xdg-open overleaf_repo/${texname}.tex_index.html