-
Notifications
You must be signed in to change notification settings - Fork 9
/
precommit.bash
executable file
·57 lines (50 loc) · 1.52 KB
/
precommit.bash
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
#!/bin/bash
subject=$(pwd)
cd $(dirname $0)
####
# Google Style Guide formatting for Java
# https://github.com/google/google-java-format
####
if [ ! -f google-java-format-1.0-all-deps.jar ]; then
echo "Downloading google-java-format"
wget https://github.com/google/google-java-format/releases/download/google-java-format-1.0/google-java-format-1.0-all-deps.jar
fi
javafmt="java -jar google-java-format-1.0-all-deps.jar --replace"
find $subject -name "*.java" -exec $javafmt {} +
####
# LaTeX formatter texpretty: TeX prettyprinter
####
if [ ! -f texpty ]; then
if [ ! -f texpretty-0.02.jar ]; then
echo "Downloading TeX prettyprinter"
wget http://ftp.math.utah.edu/pub/texpretty/texpretty-0.02.jar
jar xf texpretty-0.02.jar && rm -rf texpretty-0.02.jar META-INF
fi
cat <<EOF | patch texpretty-0.02/texpty.c
--- texpretty-0.02/texpty.o.c 2016-09-20 13:51:58.000000000 +0200
+++ texpretty-0.02/texpty.c 2016-09-20 13:52:03.000000000 +0200
@@ -5186,9 +5186,6 @@
if (line_length() > 0)
{
c_last = last_char(0);
- if (c_last == '~') /* delete undesirable ties before \cite and \nocite */
- next_position--;
- out_newline();
}
out_yytext();
}
EOF
(\
cd texpretty-0.02 && \
chmod +x configure && \
./configure && make && \
mv texpty ..\
) && \
rm -rf texpretty-0.02
fi
function texfmt() {
./texpty --no-comment-banner < $1 > $1.tmp && mv $1.tmp $1
}
export -f texfmt
find $subject -name "*.tex" -exec bash -c 'texfmt "$@"' bash {} \;
# latexindent.pl -w **/*.tex