2014-01-21 09:25:03 +01:00
|
|
|
#!/bin/sh
|
2018-07-22 18:00:39 +02:00
|
|
|
|
2014-01-21 09:25:03 +01:00
|
|
|
mkfilename() {
|
2018-07-22 18:00:39 +02:00
|
|
|
printf "%.4d-%s" "$1" "$2" | tr '# :.()/' '_'
|
2014-01-21 09:25:03 +01:00
|
|
|
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" \
|
2018-07-22 18:00:39 +02:00
|
|
|
"$title" "$(mkunderline $titlelen "=")" >> $fname
|
2014-01-21 09:25:03 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
[ -n "$fname" ] && \
|
2018-07-22 18:00:39 +02:00
|
|
|
printf " %s\n" "$line" \
|
2018-08-13 09:47:36 +02:00
|
|
|
| sed 's, , ,' \
|
2018-08-26 10:05:35 +02:00
|
|
|
| sed 's,^\([[:blank:]]*\)\*,\1o,' >> $fname
|
2014-01-21 09:25:03 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|