|
@@ -3,21 +3,22 @@ set -euo pipefail
|
|
|
IFS=$'\n\t'
|
|
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
|
- echo "$(basename $0) MARKDOWN-FILE" >&2
|
|
|
+ echo "$(basename $0) MARKDOWN-FILE+" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
-MDFILE=$1
|
|
|
-PDFFILE=$(basename $MDFILE .md).pdf
|
|
|
-FILE=$(mktemp XXXXXXXXXX-${MDFILE})
|
|
|
-HAS_METADATA=0
|
|
|
+while (( "$#" )); do
|
|
|
+ MDFILE=$1
|
|
|
+ echo "Processing ${MDFILE}."
|
|
|
+ PDFFILE=$(basename $MDFILE .md).pdf
|
|
|
+ FILE=$(mktemp XXXXXXXXXX-${MDFILE})
|
|
|
+ HAS_METADATA=0
|
|
|
+ if head -n 1 ${MDFILE} | grep -- '---' > /dev/null ; then
|
|
|
+ echo "Metadata Block Found"
|
|
|
+ HAS_METADATA=1
|
|
|
+ fi
|
|
|
|
|
|
-if head -n 1 ${MDFILE} | grep -- '---' > /dev/null ; then
|
|
|
- echo "Metadata Block Found"
|
|
|
- HAS_METADATA=1
|
|
|
-fi
|
|
|
-
|
|
|
-cat <<EOF >> $FILE
|
|
|
+ cat <<EOF >> $FILE
|
|
|
---
|
|
|
documentclass: scrartcl
|
|
|
classoption:
|
|
@@ -44,21 +45,23 @@ hyperrefoptions:
|
|
|
- bookmarks=true
|
|
|
EOF
|
|
|
|
|
|
-if [ $HAS_METADATA -eq 1 ] ; then
|
|
|
- cat $MDFILE | sed '1 d' >> $FILE
|
|
|
-else
|
|
|
- echo "..." >> $FILE
|
|
|
- cat $MDFILE >> $FILE
|
|
|
-fi
|
|
|
+ if [ $HAS_METADATA -eq 1 ] ; then
|
|
|
+ cat $MDFILE | sed '1 d' >> $FILE
|
|
|
+ else
|
|
|
+ echo "..." >> $FILE
|
|
|
+ cat $MDFILE >> $FILE
|
|
|
+ fi
|
|
|
|
|
|
-echo "Processing file to PDF."
|
|
|
-pandoc -f markdown \
|
|
|
- -s -t pdf \
|
|
|
- --highlight-style monochrome \
|
|
|
- --pdf-engine='lualatex' \
|
|
|
- -o $PDFFILE \
|
|
|
- $FILE
|
|
|
+ echo "Processing file to PDF."
|
|
|
+ pandoc -f markdown \
|
|
|
+ -s -t pdf \
|
|
|
+ --highlight-style monochrome \
|
|
|
+ --pdf-engine='lualatex' \
|
|
|
+ -o $PDFFILE \
|
|
|
+ $FILE
|
|
|
|
|
|
-echo "Done."
|
|
|
+ echo "Done."
|
|
|
+ rm $FILE
|
|
|
|
|
|
-rm $FILE
|
|
|
+ shift
|
|
|
+done
|