-
Notifications
You must be signed in to change notification settings - Fork 1
/
prosToMinted.sh
52 lines (47 loc) · 1.35 KB
/
prosToMinted.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
#!/bin/bash
# Must be run in the root directory of a PROS project
# The input should be the root directory of a LaTeX project
OUTPUT="codeToLaTeX.tex"
if [ -e "project.pros" ]
then
if [ "$1" != "" ]
then
echo "Transferring code..."
printf "%%-----------------------------------------\n" > $OUTPUT
printf "\\section[Iteration Code]{Code}\n\n" >> $OUTPUT
#add to minted section
for i in ./include/*.h
do
if [ "${i##*/}" == "API.h" ]
then
continue; #don't add the PROS API to the notebook
fi
printf "\\subsection{include/%s}\n" "${i##*/}" >> $OUTPUT
printf "\\inputminted{c}{Code/include/%s}\n" "${i##*/}" >> $OUTPUT
printf "\\pagebreak\n\n" >> $OUTPUT
done
printf "\n\n" >> $OUTPUT
echo "Added headers"
for i in ./src/*.c
do
printf "\\subsection{src/%s}\n" "${i##*/}" >> $OUTPUT
printf "\\inputminted{c}{Code/src/%s}\n" "${i##*/}" >> $OUTPUT
printf "\\pagebreak\n\n" >> $OUTPUT
done
echo "Added Source Files"
#Copy files into LaTex directory
if [ -d "../$1/Code" ]
then
rm -rf ../$1/Code
fi
mkdir ../$1/Code
mkdir ../$1/Code/src
mkdir ../$1/Code/include
cp -r src/*.c ../$1/Code/src
cp -r include/. ../$1/Code/include
else
echo "You must specify a destination for the files"
fi
else
echo "Selected directory is not a PROS directory"
fi