blob: fb060265449fa53393c9f614f15f666471c3775f (
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
|
#!/bin/bash
outFile="$1";
header="$2";
shift 2;
glob="$@";
firstLineOf() { # $1 = file
endOfYaml=$(sed -n '/^\.\.\.$/=' "$1")
tryLineNumber=$((endOfYaml + 1))
try=""
while [[ -z $try ]]; do
try=$(head -n $tryLineNumber "$1" | tail -n 1 |\
sed -e 's/^[|>] //' -e 's/[][]//g' -e 's/^#.*//' -e 's/^--.*//')
(( tryLineNumber += 1 ))
done
echo "$try"
}
echo -n "Compiling ${outFile}"
cat "$header" > $outFile
for file in $glob; do
# Copy first line to $outFile & link
echo "[$(firstLineOf "$file")](${file%.*}.html)" >> $outFile;
echo -n ".";
done
echo "Done."
|