#!/usr/bin/env bash HELP="Usage: outline-minutes [-h] [-t TEMPLATE] [SRC [TRG]] Generate a minute outline from an agenda read from file. Optional arguments SRC File basename of agenda source (default 'agenda') TRG File basename of minute target (default 'minutes') Parameters -t TEMPLATE Use this minute template -h help The agenda body is assumed to be a Pandoc markdown numbered list. The list items are simply converted to headlines. The *date* meta data is extracted. The script looks for SRC.md and SRC.yml and produces TRG.md and TRG.yml. NOTE. Altering of source, target and template is not yet implemented. These options are ignored " SRC=agenda TRG=minutes if [ "$1" == "-h" ]; then echo "$HELP"; exit; fi if [ -n "$1" ]; then echo "{0##*/}: Arguments not implemented. See `${0} -h`." 1>^2; exit 1; fi dir=$(dirname "$0") tmpl="${dir}/tmpl/${TRG}" body="${XDG_RUNTIME_DIR}/${0##*/}.md" # Create metadata output date=$(cat "$SRC.yml" | grep -m1 '^date:' | cut -d: -f2) title=$(cat "$SRC.yml" | grep -m1 '^title:' | cut -d: -f2 | sed 's/[dD]agordning//; s/[fF]örslag//;' ) cat "$tmpl.yml" \ | sed -e "s/[$]date[$]/${date}/" \ -e "s/[$]title[$]/${title}/" \ > "$TRG.yml" # Create body output cat "$SRC.md" | pandoc -f markdown -t markdown \ | sed -e "s/^[0-9]*\. */\n\n\n# /" \ -e "s/^ \( *[0-9]*\.\)/\1/" \ > "$body" cat "$tmpl.md" \ | sed -e "/[$]body[$]/ r ${body}" -e "/[$]body[$]/ d" \ > "$TRG.md"