2022-03-16 01:32:08 -07:00
|
|
|
#!/bin/bash
|
|
|
|
# Simple script for compiling/converting documents with pandoc because I can never remember how to use it
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
# pandoc-make html *.md
|
|
|
|
|
2022-03-16 01:53:57 -07:00
|
|
|
usage() {
|
|
|
|
cat <<-EOF
|
|
|
|
Usage:
|
|
|
|
$0 [output_type] [input_files]
|
2022-03-16 01:32:08 -07:00
|
|
|
|
2022-03-16 01:53:57 -07:00
|
|
|
Examples:
|
|
|
|
$0 pdf *.md
|
|
|
|
$0 .docx *.md # leading .'s are automatically removed from the output name
|
|
|
|
EOF
|
|
|
|
}
|
2022-03-16 01:32:08 -07:00
|
|
|
|
2022-03-16 01:53:57 -07:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
usage && exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
echo "error: no files specified"
|
|
|
|
usage && exit 1
|
|
|
|
fi
|
|
|
|
FORMAT="$1"
|
|
|
|
SKIP_FIRST=true
|
2022-03-16 01:32:08 -07:00
|
|
|
|
|
|
|
for FILE in "$@";do
|
2022-03-16 01:53:57 -07:00
|
|
|
$SKIP_FIRST && SKIP_FIRST=false && continue
|
2022-03-16 01:32:08 -07:00
|
|
|
if [ -f "$FILE" ]; then
|
|
|
|
pandoc -s "$FILE" -o "${FILE%.*}.${FORMAT##.}"
|
|
|
|
fi
|
|
|
|
done
|
2022-03-16 01:53:57 -07:00
|
|
|
|
|
|
|
# vim:et ts=3 sw=3
|