pandoc-make: it works flawlessly™
This commit is contained in:
parent
12087a1655
commit
aa32e9ba63
1 changed files with 22 additions and 5 deletions
|
@ -4,16 +4,33 @@
|
||||||
# Usage:
|
# Usage:
|
||||||
# pandoc-make html *.md
|
# pandoc-make html *.md
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<-EOF
|
||||||
|
Usage:
|
||||||
|
$0 [output_type] [input_files]
|
||||||
|
|
||||||
# echo "Convert to... (default: html)"
|
Examples:
|
||||||
# read -r FORMAT
|
$0 pdf *.md
|
||||||
|
$0 .docx *.md # leading .'s are automatically removed from the output name
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
FORMAT="${1:-html}"
|
if [ -z "$1" ]; then
|
||||||
FIRST=true
|
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
|
for FILE in "$@";do
|
||||||
[ $FIRST ] && FIRST=false && continue
|
$SKIP_FIRST && SKIP_FIRST=false && continue
|
||||||
if [ -f "$FILE" ]; then
|
if [ -f "$FILE" ]; then
|
||||||
pandoc -s "$FILE" -o "${FILE%.*}.${FORMAT##.}"
|
pandoc -s "$FILE" -o "${FILE%.*}.${FORMAT##.}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# vim:et ts=3 sw=3
|
||||||
|
|
Loading…
Add table
Reference in a new issue