Last active
December 22, 2015 23:58
-
-
Save HPieters/6550024 to your computer and use it in GitHub Desktop.
Thesis - Generate thesis with pandoc and latex based on markdown input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clear | |
# Function to watch a folder | |
createThesis() { | |
echo "[`date +%H:%M:%S`] `ls *.md | tr '\n' ',' | sed 's/,$/\n/'`" | |
for i in *.md; do | |
[ -e "$i" ] || break | |
cat "$i" >> thesis.markdown | |
cat enter.markdown >> thesis.markdown | |
done | |
sed -n '/[%]/!p' thesis.markdown > thesis-clean.markdown | |
pandoc -s -S thesis-clean.markdown -o thesis-without.tex --variable=geometry:a4paper --variable fontsize=11pt --include-in-header=package.tex --latex-engine=xelatex --number-sections --toc | |
sleep 5 | |
xelatex thesis-without | |
sleep 2 | |
bibtex thesis-without | |
sleep 2 | |
xelatex thesis-without | |
sleep 5 | |
pandoc title.markdown -o "title.pdf" --variable mainfont='Corbel' --variable sansfont='Corbel' --latex-engine=xelatex | |
sleep 10 | |
pdftk A="title.pdf" B="thesis-without.pdf" cat A B output "output/thesis.pdf" | |
#Cleanup | |
rm -rf thesis.markdown | |
rm -rf thesis-without.pdf | |
rm -rf title.pdf | |
} | |
watchdog() { | |
chsum1=`find /Users//Dropbox/Thesis/Main/ -type f -name \*.md -exec md5 {} \;` | |
while [[ true ]] | |
do | |
chsum2=`find /Users//Dropbox/Thesis/Main/ -type f -name \*.md -exec md5 {} \;` | |
if [[ $chsum1 != $chsum2 ]] ; then | |
#Report to the user | |
echo "[`date +%H:%M:%S`] Woef! Change detected" | |
createThesis | |
echo "[`date +%H:%M:%S`] My work is done, resuming my watch!" | |
chsum1=$chsum2 | |
fi | |
sleep 2 | |
done | |
} | |
echo '['$(date +%H:%M:%S)'] Watchdog at your service!' | |
watchdog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment