about summary refs log tree commit diff stats
path: root/trunk/toc.sh
blob: fe440cb1dd9adda01ee072d4c9bea7f758550f29 (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
#!/bin/bash

outFile="$1";
shift 1;
glob="$@";

echo -n "Compiling $outFile"

for file in $glob; do
    title=$(grep '^title: ' $file | cut -d' ' -f2-);
    subtitle=$(grep '^subtitle: ' $file | cut -d' ' -f2-);
    htmlFile="${file%.txt}.html"
    # if [[ "$title" == "Autocento of the breakfast table" ]]; then
    #     echo "#. [$subtitle]($htmlFile)" >> "$outFile";
    # else
    #     echo "#. [$title]($htmlFile)" >> "$outFile";
    # fi
    if [[ -n "$subtitle" ]]; then
        echo "#. [$title: $subtitle]($htmlFile)" >> "$outFile"
    else
        echo "#. [$title]($htmlFile)" >> "$outFile";
    fi
    echo -n "."
done

echo "Done."