diff options
author | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
commit | 7400e108286a0fceacdac63b125fdc924c2dd50c (patch) | |
tree | 4849176606778477ead8a9ded4c9ff43bf4a8feb /aux/workflow/commonmark.sh | |
parent | servers/nixvps/configuration.nix: Serve Git repositories from NGINX, remove G... (diff) | |
download | server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.gz server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.xz |
aux/: Update
Diffstat (limited to 'aux/workflow/commonmark.sh')
-rwxr-xr-x | aux/workflow/commonmark.sh | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/aux/workflow/commonmark.sh b/aux/workflow/commonmark.sh index 6016f51..6f5e59b 100755 --- a/aux/workflow/commonmark.sh +++ b/aux/workflow/commonmark.sh @@ -1,20 +1,42 @@ #!/bin/sh set -eu -mkdir -p public +while getopts 'N:t:l:' flag; do + case "$flag" in + N) + PROJECT_UC="$OPTARG" + ;; + t) + TITLE="$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 "${TITLE:-}" '-t TITLE' +assert_arg "${THE_LANG:-}" '-l THE_LANG' 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 - $TITLE" \ + --metadata "lang=$THE_LANG" \ + -r commonmark \ + -w html \ + -H aux/workflow/favicon.html |