site-neo/render.sh

45 lines
976 B
Bash
Raw Normal View History

2022-09-24 22:07:46 +00:00
#!/bin/bash
2022-10-04 21:42:16 +00:00
# render.sh: part of the tape-and-string framework.
2023-02-01 17:59:45 +00: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-06 01:56:56 +00:00
*) pandoc --columns 168 -t html $i || echo "Skipping $i, unknown format" ;;
2023-02-01 17:59:45 +00:00
esac
}
2023-02-05 11:47:27 +00: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 23:23:04 +00:00
cd ..
2023-02-06 01:56:56 +00:00
files=(`find -not -path './_*' -not -path './css'`)
2023-01-21 23:40:35 +00:00
for i in ${files[@]}; do
2023-02-01 17:59:45 +00:00
echo $i
2023-01-21 23:40:35 +00:00
if test -d $i; then
2023-02-01 16:04:04 +00:00
if test -d ../$i; then
2023-02-01 17:59:45 +00:00
mkdir -vp ../$i
2023-02-01 16:04:04 +00:00
else continue
fi
2023-01-21 23:40:35 +00:00
elif test -f $i; then
2023-02-01 21:08:28 +00:00
tape $i | sed 's/^\s\{1,4\}//' | m4 -DTITLE="$(${prog[title]} $i)" -DLIB=${prog[lib]} ${prog[m4]} > ../${i%.*}.html
2023-01-21 23:40:35 +00:00
else
echo "Skipping $i, unknown file type"
fi
2022-09-24 22:07:46 +00:00
done