aboutsummaryrefslogblamecommitdiff
path: root/aux/workflow/commonmark.sh
blob: 39aacb479d39263e36896128ef2991a06b8b83a2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


         
                               



                                            

                                       
                          
                  







                                          
 







                                            

                                          
 
        







                                                 

                                                 
#!/bin/sh
set -eu

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))

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 - $TITLE" \
	--metadata "lang=$THE_LANG"             \
	-r commonmark                           \
	-w html                                 \
	-H aux/workflow/favicon.html            \
	-H aux/workflow/style.css