dotfiles/.config/shell/bin/pandoc-make

36 lines
667 B
Bash
Executable file

#!/bin/bash
# Simple script for compiling/converting documents with pandoc because I can never remember how to use it
# Usage:
# pandoc-make html *.md
usage() {
cat <<-EOF
Usage:
$0 [output_type] [input_files]
Examples:
$0 pdf *.md
$0 .docx *.md # leading .'s are automatically removed from the output name
EOF
}
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
for FILE in "$@";do
$SKIP_FIRST && SKIP_FIRST=false && continue
if [ -f "$FILE" ]; then
pandoc -s "$FILE" -o "${FILE%.*}.${FORMAT##.}"
fi
done
# vim:et ts=3 sw=3