pandoc-make: allow for pandoc arguments
This commit is contained in:
parent
ce104e4922
commit
c7623a05bd
1 changed files with 16 additions and 7 deletions
|
@ -7,11 +7,16 @@
|
||||||
usage() {
|
usage() {
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
Usage:
|
Usage:
|
||||||
$0 [output_type] [input_files]
|
$0 [output_type] [pandoc_args for file 1] [pandoc_args for file 1] [input_files]
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
$0 pdf *.md
|
$0 pdf *.md
|
||||||
$0 .docx *.md # leading .'s are automatically removed from the output name
|
$0 .docx *.md # leading .'s are automatically removed from the output format
|
||||||
|
|
||||||
|
Note:
|
||||||
|
To put a file in pandoc arguments without having it be compiled to its own document, put a './' at the start of the path to it
|
||||||
|
You can have as many arg/file combinations you want
|
||||||
|
The argument array is cleared between input files
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,13 +32,17 @@ if [[ -z "$2" ]]; then
|
||||||
echo "error: no files specified"
|
echo "error: no files specified"
|
||||||
usage && exit 1
|
usage && exit 1
|
||||||
fi
|
fi
|
||||||
FORMAT="$1"
|
|
||||||
SKIP_FIRST=true
|
OUTPUT_FORMAT="$1"
|
||||||
|
SKIP_FIRST=true # don't process the first argument, it is the output format
|
||||||
|
|
||||||
for FILE in "$@";do
|
for FILE in "$@";do
|
||||||
$SKIP_FIRST && SKIP_FIRST=false && continue
|
$SKIP_FIRST && SKIP_FIRST=false && continue
|
||||||
if [[ -f "$FILE" ]]; then
|
if [[ -f "$FILE" ]] && [[ "${FILE:0:2}" != "./" ]]; then
|
||||||
pandoc -s "$FILE" -o "${FILE%.*}.${FORMAT##.}"
|
pandoc -s "$FILE" "${PANDOC_ARGS[@]}" -o "${FILE%.*}.${OUTPUT_FORMAT##.}"
|
||||||
|
PANDOC_ARGS=()
|
||||||
|
else
|
||||||
|
PANDOC_ARGS+=("$FILE")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue