~acdw/tssg

c481b6ae423d5c4a56d11baa71ef37b6bccec13b — Case Duckworth 5 years ago 2413fae
clean up generated toc
1 files changed, 6 insertions(+), 6 deletions(-)

M tssg.sh
M tssg.sh => tssg.sh +6 -6
@@ 1,9 1,9 @@
#!/bin/sh
I=./index.html;O="${1:-out}";H=hd.txt;F=ft.txt;mkdir -p $O;touch $H $F $I
alias eo='echo >>"$OF"' p=printf;po(){ cat $H "$@" $F >"$OF"; }
for f in ./*.html;do [ "$f" = $I ] || (OF="$O/$f";p "$f\t";
po "$f";eo "<a id=ret href=$I>return</a>";p OK\\n;) done
p $I\\t;OF="$O/$I~";eo '<ul id=toc>';for p in $O/*.html;do
alias eo='echo >>"$Q"' p=printf;po(){ cat $H "$@" $F >"$Q"; }
for f in ./*.html;do [ "$f" = $I ] || (Q="$O/$f";p "$f\t";
po "$f";eo "<a id=ret href=$I>&lt;</a>";p OK\\n;) done
p $I\\t;Q="$O/$I~";eo '<ul id=toc>';for p in $O/*.html;do
[ -e "$p" ] && (t="$(sed -n 's,.*<title>\(.*\)</title>.*,\1,ip;T;q' "$p")"
eo "<li><a href='${p##*/}'>$t</a></li>";) done;eo "</ul>";OF="$O/$I";
po $I "$O/$I~";p OK\\n
eo "<li><a href='${p##*/}'>$t</a></li>";) done;eo "</ul>";BF="$Q";Q="$O/$I";
po $I "$BF";rm "$BF";p OK\\n