aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/commonmark.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-24 18:17:26 -0300
committerEuAndreh <eu@euandre.org>2021-07-04 17:07:50 -0300
commit4dcfbd67afca57dbb21109579f825e60312b7f41 (patch)
tree0b41cc75ad6b2f2515658f93d4fc60f686c8aa78 /aux/workflow/commonmark.sh
parentnix/: Remove (diff)
downloadeuandre.org-4dcfbd67afca57dbb21109579f825e60312b7f41.tar.gz
euandre.org-4dcfbd67afca57dbb21109579f825e60312b7f41.tar.xz
aux/: Update
Diffstat (limited to 'aux/workflow/commonmark.sh')
-rwxr-xr-xaux/workflow/commonmark.sh65
1 files changed, 51 insertions, 14 deletions
diff --git a/aux/workflow/commonmark.sh b/aux/workflow/commonmark.sh
index 6016f51..b196867 100755
--- a/aux/workflow/commonmark.sh
+++ b/aux/workflow/commonmark.sh
@@ -1,20 +1,57 @@
#!/bin/sh
set -eu
-mkdir -p public
+while getopts 'N:o:r:w:L:' flag; do
+ case "$flag" in
+ N)
+ PROJECT_UC="$OPTARG"
+ ;;
+ o)
+ OUTDIR="$OPTARG"
+ ;;
+ r)
+ IN_FILE="$OPTARG"
+ ;;
+ w)
+ OUT_FILE="$OPTARG"
+ ;;
+ L)
+ THE_LANG="$OPTARG"
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
-PROJECT_UC="$1"
-F="$2"
-OUT="${3:-${F%.*}.html}"
+assert_arg() {
+ if [ -z "$1" ]; then
+ echo "Missing $2" >&2
+ exit 2
+ fi
+}
+
+assert_arg "${PROJECT_UC:-}" '-N PROJECT_UC'
+assert_arg "${OUTDIR:-}" '-o OUTDIR'
+assert_arg "${IN_FILE:-}" '-i IN_FILE'
+assert_arg "${THE_LANG:-}" '-L THE_LANG'
+
+if [ -z "${OUT_FILE:-}" ]; then
+ OUT_FILE="${IN_FILE%.md}.html"
+fi
+
+OUT="$OUTDIR/$OUT_FILE"
+mkdir -p "$(dirname "$OUT")"
pandoc \
- --toc \
- --highlight-style pygments \
- --toc-depth=2 \
- -s \
- --metadata title="$PROJECT_UC - ${F%.*}" \
- --metadata lang=en \
- -r commonmark \
- -w html \
- -H aux/workflow/favicon.html \
- < "$F" > "public/$OUT"
+ --toc \
+ --highlight-style pygments \
+ --toc-depth=2 \
+ -s \
+ --metadata title="$PROJECT_UC - ${IN_FILE%%.*}" \
+ --metadata "lang=$THE_LANG" \
+ -r commonmark \
+ -w html \
+ -H aux/workflow/favicon.html \
+ < "$IN_FILE" > "$OUT"