Skip to content

Instantly share code, notes, and snippets.

@kdelwat
Created November 14, 2015 02:14
Show Gist options
  • Save kdelwat/a5e2d6a038fb50d1ce43 to your computer and use it in GitHub Desktop.
Save kdelwat/a5e2d6a038fb50d1ce43 to your computer and use it in GitHub Desktop.
#!/bin/bash
git --work-tree=/var/notesworking --git-dir=/var/notes checkout -f
changed=$(git diff-tree -r HEAD | sed 's/^.*\s[A-Z]\s\s*//g' | sed 1d)
for filename in $changed
do
echo $filename
filetype=$(echo $filename | sed 's/.*\.//g')
if [ $filetype == "md" ]
then
stripped=$(echo $filename | sed 's/.md//g')
fullpath=/var/notesworking/$filename
tempoutpath=/var/notesworking/$stripped".pdf"
outpath=/var/www/notes/$stripped".pdf"
echo $fullpath
echo $outpath
onlyfilename=$(echo $stripped | sed 's/^.*\///g')
sedString="s/"$onlyfilename".*$//g"
workingd=$(echo $fullpath | sed $sedString)
outd=$(echo $outpath | sed $sedString)
mkdir -p $outd
cd $workingd
pandoc $fullpath -t latex -o $outpath --latex-engine=xelatex
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment