BEGIN { chapter=0; section=0; subsection=0; fn=""; file1=""; file2=""; file3=""; fnhtml=""; toc=0; newfile=0; printf ("") > "html.lab"; } /\\chapter/ { if (match($0,/\\chapter{[^}]*}/)) { if (subsection) print "" if (section) print "" if (chapter) print "" chapter ++; checkfile(); title=substr($0,RSTART+9,RLENGTH-10); prefix=chapter"."; a[toc]="0:"prefix":"toc":"title; print "" if (section) print "" section ++; checkfile(); print "" shiftfiles("adoc_index.html"); } function checkfile() { if (fn!=FILENAME) { newfile=1; fn=FILENAME; fnhtml=fn; fninfo=fn; sub(/.src$/,".html",fnhtml); shiftfiles(fnhtml); toc=0; } } function shiftfiles(fn ,fninfo) { file1=file2; file2=file3; file3=fn; #printf "shift " fn "\n" >> "/dev/stderr"; if (file2!="") { fninfo="gen/"file2; sub(/.html$/,".info",fninfo); print "prev " file1 > fninfo; print "next " file3 >> fninfo; for (t=0; t> fninfo; close (fninfo); } } function getfiledate(fn ,date) { cmd="getfiledate "fn; cmd | getline date; close (cmd); return date; }