Created
January 28, 2017 16:06
-
-
Save nextlevelshit/b8171174c8f8468df52cac580ccd6e81 to your computer and use it in GitHub Desktop.
git hook for markdown files, that should be compiled into pdf before committing
This file contains 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 | |
echo "Compiling markdown files ..." | |
regex="(.*)\.md" | |
list=$(git diff --cached --name-only --diff-filter=ACM) | |
while read -r line; do | |
if [[ $line =~ $regex ]]; then | |
file=${BASH_REMATCH[1]} | |
pandoc $file.md -o $file.pdf | |
# compile markdown files to pdf | |
git add $file.pdf | |
# add compiled files to commit | |
echo "$file.md -> $file.pdf" | |
fi | |
done <<< "$list" | |
echo "Finished Compiling and added files to Commit!" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+1