summaryrefslogtreecommitdiff
path: root/build-member.sh
blob: 49a920554997f6e477489cc9905731f4b49d3bd8 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash

set -eu

input=$1
output=$2

firstname ()
{
    local -r fullname=$1
    local name=${fullname%% *}
    echo ${name,}
}

generate-parameters ()
{
    read fullname

    cat <<EOF
title='${fullname}'
stylesheets=(membre)
transforms=("\$(transform-li-dropdown-current-a quatuor)"
            "\$(transform-li-current-a quatuor)"
            "\$(transform-li-current-a $(firstname "${fullname}"))")
EOF
}

pandoc-inline ()
{
    pandoc | sed -r 's,^<p>(.+)</p>$,\1,'
}

generate-main ()
{
    read fullname
    read instrument
    read emph1
    read emph2
    local -r name=$(firstname "${fullname}")

    cat <<EOF
<main style="--emph1-color: ${emph1}; --emph2-color: ${emph2}">
  <div class="bio-title">
    <h1 class="name">${fullname}</h1>
    <h2 class="instrument">${instrument}</h2>
  </div>
  <div class="bio">
EOF

    while read line
    do
        # Pasting from GDoc yields trailing spaces; remove those.
        if ! [[ ${line} =~ ([^:?]+[:?])\ (.+[^ ])\ * ]]
        then
            >&2 echo "Invalid line: ${line}"
        fi

        cat <<EOF
    <dl>
      <dt>$(pandoc-inline <<< "${BASH_REMATCH[1]}") </dt>
      <dd>$(pandoc-inline <<< ${BASH_REMATCH[2]})</dd>
    </dl>
EOF
    done

    cat <<EOF
  </div>
  <img src="images/${name}/portrait.png" style="background-image: url(images/${name}/bg.jpg)">
</main>
EOF
}

./build.sh <(generate-main < "${input}")        \
           <(generate-parameters < "${input}")  \
           "${output}"