From aa32e9ba63891c3437076ba28b539b1f4b9c9d34 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 16 Mar 2022 01:53:57 -0700 Subject: [PATCH] =?UTF-8?q?pandoc-make:=20it=20works=20flawlessly=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/shell/bin/pandoc-make | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.config/shell/bin/pandoc-make b/.config/shell/bin/pandoc-make index 181991f..a336f34 100755 --- a/.config/shell/bin/pandoc-make +++ b/.config/shell/bin/pandoc-make @@ -4,16 +4,33 @@ # Usage: # pandoc-make html *.md +usage() { + cat <<-EOF + Usage: + $0 [output_type] [input_files] -# echo "Convert to... (default: html)" -# read -r FORMAT + Examples: + $0 pdf *.md + $0 .docx *.md # leading .'s are automatically removed from the output name + EOF +} -FORMAT="${1:-html}" -FIRST=true +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 - [ $FIRST ] && FIRST=false && continue + $SKIP_FIRST && SKIP_FIRST=false && continue if [ -f "$FILE" ]; then pandoc -s "$FILE" -o "${FILE%.*}.${FORMAT##.}" fi done + +# vim:et ts=3 sw=3