summaryrefslogtreecommitdiff
path: root/html/gen.sh
blob: d14286e30161b8f29e814ed73a93102a2f0d38a8 (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
#!/bin/bash

set -euo pipefail

if [ $# -eq 0 ]
then
    exec find . -name \*.md -exec "$0" {} +
fi

for file
do
    if ! [ -f "$file" ]
    then
        echo >&2 "File not found: $file"
        continue
    fi
    echo "$file"
    {
        title=$(sed '/^# / { s/# //; q }' "$file")
        sed "s/__TITLE__/$title/" prelude.html
        echo "<body>"
        markdown2 "$file" -x fenced-code-blocks,highlightjs-lang
        echo "</body>"
    } > "${file%.md}".html
done