-
-
Save roktas/676169 to your computer and use it in GitHub Desktop.
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 | |
# Jekyll girdilerinden pdf üret. | |
# Örnek: <betik> 9/_posts/2010-11-14-kramdown.md | |
PATH=/var/lib/gems/1.8/bin:$PATH | |
[ $# -gt 0 ] || { | |
echo >&2 "Kullanım: $0 <jekyll markdown dosyası>" | |
echo >&2 "Örnek: $0 9/_posts/2010-11-14-kramdown.md" | |
exit 1 | |
} | |
[ -n "$(which kramdown)" ] || { | |
echo >&2 "kramdown kurulu değil" | |
echo >&2 " sudo gem install kramdown" | |
exit 1 | |
} | |
[ -n "$(which pdflatex)" ] || { | |
echo >&2 "texlive kurulu değil" | |
echo >&2 " sudo apt-get install texlive" | |
exit 1 | |
} | |
INFILE="$(readlink -f "$1")" | |
[ -f "$INFILE" ] || { | |
echo >&2 "Yok böyle bir dosya: $INFILE" | |
exit 1 | |
} | |
BASE="$(basename "$INFILE")" | |
BASE="${BASE%%.*}" | |
TEMPDIR=$(mktemp -d) || exit 1 | |
trap 'err=$?; rm -rf $TEMPDIR; exit $err' EXIT HUP QUIT INT TERM | |
ORIGDIR="$PWD"; ( | |
cd "$TEMPDIR" && { | |
printf "# "; sed -ne 's/^[Tt]itle:[[:blank:]]*//p' "$INFILE"; echo | |
sed -e '1,/^---/d' "$INFILE" | |
} | kramdown -o latex --template document >"${BASE}.tex" | |
TEXINPUTS=$ORIGDIR:$TEXINPUTS: pdflatex -interaction=batchmode "${BASE}.tex" >/dev/null 2>&1 | |
) && { | |
OUTFILE="${TEMPDIR}/${BASE}.pdf" | |
if [ -f "$OUTFILE" ]; then | |
mv "$OUTFILE" . | |
echo >&2 "${BASE}.pdf hazır." | |
exit 0 | |
fi | |
} | |
echo >&2 "pdf üretilemedi." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment