2022-09-24 18:07:46 -04:00
|
|
|
#!/bin/bash
|
2022-10-04 17:42:16 -04:00
|
|
|
# render.sh: part of the tape-and-string framework.
|
2023-02-01 12:59:45 -05:00
|
|
|
# v2.1
|
|
|
|
declare -A prog
|
|
|
|
prog[m4]=`readlink -f main.html.m4`
|
|
|
|
prog[lib]=`readlink -f lib.m4`
|
|
|
|
prog[title]=`readlink -f titlelookup`
|
|
|
|
function tape {
|
|
|
|
case $1 in
|
|
|
|
*.txti) redcloth $1 ;;
|
|
|
|
*.org) org-ruby --translate html $1 ;;
|
|
|
|
*.md) comrak --gfm $1 ;;
|
|
|
|
*.html) cat $1 ;;
|
2023-02-05 20:56:56 -05:00
|
|
|
*) pandoc --columns 168 -t html $i || echo "Skipping $i, unknown format" ;;
|
2023-02-01 12:59:45 -05:00
|
|
|
esac
|
|
|
|
}
|
2023-02-05 06:47:27 -05:00
|
|
|
function yn {
|
|
|
|
while true; do
|
|
|
|
read -p "$* [y/n]:" yn
|
|
|
|
case $yn in
|
|
|
|
[Yy]*) return 0;;
|
|
|
|
[Nn]*)
|
|
|
|
echo "Aborted."
|
|
|
|
return 1;;
|
|
|
|
*) echo "Please answer Yes or No.";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-01-21 18:23:04 -05:00
|
|
|
cd ..
|
2023-02-05 20:56:56 -05:00
|
|
|
files=(`find -not -path './_*' -not -path './css'`)
|
2023-01-21 18:40:35 -05:00
|
|
|
for i in ${files[@]}; do
|
2023-02-01 12:59:45 -05:00
|
|
|
echo $i
|
2023-01-21 18:40:35 -05:00
|
|
|
if test -d $i; then
|
2023-02-01 11:04:04 -05:00
|
|
|
if test -d ../$i; then
|
2023-02-01 12:59:45 -05:00
|
|
|
mkdir -vp ../$i
|
2023-02-01 11:04:04 -05:00
|
|
|
else continue
|
|
|
|
fi
|
2023-01-21 18:40:35 -05:00
|
|
|
elif test -f $i; then
|
2023-02-01 16:08:28 -05:00
|
|
|
tape $i | sed 's/^\s\{1,4\}//' | m4 -DTITLE="$(${prog[title]} $i)" -DLIB=${prog[lib]} ${prog[m4]} > ../${i%.*}.html
|
2023-01-21 18:40:35 -05:00
|
|
|
else
|
|
|
|
echo "Skipping $i, unknown file type"
|
|
|
|
fi
|
2022-09-24 18:07:46 -04:00
|
|
|
done
|