2014-01-21 09:25:03 +01:00
|
|
|
#!/bin/sh
|
2014-01-21 09:31:45 +01:00
|
|
|
#
|
|
|
|
# See LICENSE for license details.
|
|
|
|
#
|
2014-01-21 09:25:03 +01:00
|
|
|
|
|
|
|
mkfilename() {
|
|
|
|
printf "%.4d-%s" "$1" "$2" | tr '# :.' '_'
|
|
|
|
printf ".txt"
|
|
|
|
}
|
|
|
|
|
|
|
|
mkunderline() {
|
|
|
|
i=$1
|
|
|
|
while [ $i -gt 1 ];
|
|
|
|
do
|
|
|
|
printf "%s" "$2"
|
|
|
|
i=$(($i - 1))
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
fname=""
|
|
|
|
snum=0
|
|
|
|
|
|
|
|
while IFS='
|
|
|
|
' read -r line;
|
|
|
|
do
|
|
|
|
case $line in
|
|
|
|
\#\#*)
|
|
|
|
titlelen="$(utf8expr length "$line")"
|
|
|
|
title="$(utf8expr substr "$line" 3 $titlelen)"
|
|
|
|
fname="$(mkfilename "$snum" "$title")"
|
|
|
|
snum=$((snum + 1))
|
|
|
|
printf "\n %s\n %s\n\n" \
|
|
|
|
"$title" "$(mkunderline $titlelen "=")" > $fname
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
[ -n "$fname" ] && \
|
|
|
|
printf " %s\n" "$line" \
|
|
|
|
| sed 's,\t, ,' \
|
|
|
|
| sed 's,\*,o,' >> $fname
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|