aboutsummaryrefslogtreecommitdiffstats
path: root/lib/outline-minutes
blob: dee37ef451b0c414961994c0df4ee68f310a8745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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"