#!/usr/local/bin/bee -s ero="none"; side=no; s=""; sss=""; ss=""; cor=0; boo=0; tbl=""; toclev2=no; toclev3=no if (!file(".pretx.ibi").ok) quit "Please run pretx and tx2htm prior to running this script." eee=yes read '.pretx.ibi' t=T T=t.B!~'#' doargs(Nof(T)) if (side) tbl="
" for i=2, Nof(ss) #FOR EACH SEPERATE WEBPAGE if((i-boo+1)0 & T[i-boo+1].F!=sss[i]) then if(i+1<=Nof(T)) then " Error_splittx ***> in (or near) the heading of " + sss[i] ero="\nHeading Error in splittx:" ero+="The section:" + T[i+1].F + " \nhas the heading:" + sss[i] write append string ero '.splittxerr.tx' endif if (eee) quit " Error_splittx ***> Please correct the error and run splittx again." boo+=1 endif while(t[i+cor].B~"#") cor+=1 endwhile show " Info> splittx: writing page " + i + " of " + Nof(ss) + ": " + T[i].B + "\t" + T[i].D z=linkss(T,i, side) d=toc(t,i,cor, side, z) fin=ss[i] if side then fin=Replace(fin, 'split>.*?', '') fin2=Replace(ss[i], 'split>', '') fin2=Replace(fin2, '
', '
') fin2=Replace(fin2, 'darkblue', 'black') fin2=Replace(fin2, "(.*?)\<\/a\>', '\1') final=HtmlHeader() + Style() + fin2 + "" write string final path + "/" + T[i].B + "print.htm" endif final = HtmlHeader()+ Style() + rtop + tbl + d + fin + rbot + "" write string final path + "/" + T[i].B+".htm" endfor write string HtmlHeader()+Style()+searchh()+"" path + "/searchh.htm" read string '.splittxerr.tx' name='tryy' if !tryy then write string " Info> no errors found" '.splittxerr.tx' "No errors found" endif show tryy quit #======================================== #================================================= #======================================== function linkss(T, i, side) v="" #Search a="" #Next b="" #Previous c="" #Up e="" #Contents and Index f="" #Print g="" #h2 title v+='
=T[i].E) if T[l].E==T[i].E then a=" 0) then while (l>=2) & (T[l].E>=T[i].E) if T[l].E==T[i].E then b=" 0) then done=no for z=i-1, 2, -1 if (T[z].E+1==T[i].E) then c=" 1) & (T[u].E>=T[i].E)) #find next highest level u=u-1 endwhile if T[u].E==1 then #if its one then set a to the index a=u b=i elseif T[u].E==2 then # otherwise set b to the index and find the first level b=u while((u>1) & (T[u].E!=1)) u=u-1 endwhile a=u #and set it to a u=b c=i elseif T[u].E==3 then c=u while((u>1) & (T[u].E!=2)) u=u-1 endwhile b=u while((u>1) & (T[u].E!=1)) u=u-1 endwhile a=u u=c endif if T[i].E==1 then a=i endif if side then d+="" + T[a].A + " "+Up(T[a].F)+"
\n" d+="
" + z #z-->links d+="
" if b!=0 & T[b].E==2 then d+="" + T[b].A + " "+Up(T[b].F)+"
\n" endif endif children=no childnum=0 child=0 o=i+1 while ( o<=Nof(T) ) & ( T[o].E>T[i].E ) if (T[o].E==T[i].E+1) then childnum+=1 children=yes child=o endif o+=1 endwhile if childnum==1 then " Error_splittx ***>: file " + T[i].F + " has only one child. See .splittxerr.tx" ero="\nSingle child parent: " + T[i].F +"\n" ero+="Child: " + T[child].F + "\n" write append string ero ".splittxerr.tx" if (eee) quit " Error_splittx ***> please correct errors and run splittx again." endif if (Nof(ss[i-cor])<175) args//="inserttoc" #---------------------------------------- #---------------------------------------- if !side then #side flag check for oo=1, 20 d+=Spacer(1) endfor for j=2, Nof(T) #printout first level if (T[j].E==1) then if (j!=i) & (j!=a) then d+=" " + Upn(T[j].D) + " | " else d+="" + Upn(T[j].D)+ " | " endif endif endfor d+="" if d[Nof(d)-1]=='|' then d=d[1:$-3] endif #---------------------------------------- #---------------------------------------- d+="
" j=a+1 while(j<=Nof(T)&(T[j].E>=2)) #printout second level if (T[j].E==2) then if (j!=i) & (j!=b) then d+=" " + Upn(T[j].D) + " | " else d+="" + Upn(T[j].D)+ " | " endif endif j+=1 endwhile if d[Nof(d)-1]=='|' then d=d[1:$-3] endif d+="
" endif #side flag check #---------------------------------------- #---------------------------------------- if(T[i].E!=1) then #if not in the first level then j=b+1 if (T[i].E==2) then if (children) then d+="
" if args=="inserttoc" then d+="Section Contents | " toclev2=yes else d+="Section Intro | " toclev2=no endif endif else d+="
" if toclev2 then d+=" Section Contents | " else d+=" Section Intro | " endif endif while(j<=Nof(T)&(T[j].E>=3)&!(T[i].E==2 & args=="inserttoc")) #printout third level if (T[j].E==3) then if (j!=i & j!=c) then if Nof(T[j].B~"#")==0 then d+=" " + Upn(T[j].D) + " | " else d+=" " + Upn(T[j].D) + " | " endif else d+="" + Upn(T[j].D)+ " | " endif endif j+=1 endwhile if d[Nof(d)-1]=='|' then d=d[1:$-3] endif if T[i].E==2 & (children) then d+="
" elseif T[i].E!=2 then d+="
" endif endif #end level check #---------------------------------------- #---------------------------------------- if(T[i].E>2) then #if not in the first or second level then if c!=0 & side then d+="
"+ T[c].A + " " + Upn(T[c].F) + "
\n" endif j=c+1 if (T[i].E==3) then if (children) then d+="
" if args=="inserttoc" then d+="Section Contents | " toclev3=yes else d+="Section Intro | " toclev3=no endif endif else d+="
" if toclev3 then d+=" Section Contents | " else d+=" Section Intro | " endif endif while(j<=Nof(T)&(T[j].E>3)&!(T[i].E==3 & args=='inserttoc')) #printout fourth level if (T[j].E==4) then if (j!=i) then if Nof(T[j].B~"#")==0 then d+=" " + Upn(T[j].D) + " | " else d+=" " + Upn(T[j].D) + " | " endif else d+="" + Upn(T[j].D)+ " | " endif endif j+=1 endwhile if d[Nof(d)-1]=='|' then d=d[1:$-3] endif if T[i].E==3 & (children) then d+="
" elseif T[i].E!=3 then d+="
" endif if T[i].E==4 & side then d+="
"+ T[i].A + " " + (T[i].F) + "
\n" endif endif #---------------------------------------- #---------------------------------------- if args=="inserttoc" then if (i==Nof(T) | T[i].E==4) then " Error_splittx ***> 'inserttoc' problem. See .splittxerr.tx" ero="\nOptional Argument Error: " + T[i].F + "\n" ero+="Either the 'inserttoc' argument is invalid for this page or the page is an empty child." write append string ero '.splittxerr.tx' if (eee) quit "Please correct error and run again." else d+="
" o=i+1 while(o<=Nof(T) & T[o].E>T[i].E) if(T[o].E-1==T[i].E)then d+="\n" + Spacer(3) + T[o].A + " " + Upn(T[o].F) + "\n
\n" endif o+=1 endwhile endif endif return d endfunction #======================================== #================================================= #======================================== function frameset(T) f="" f+='' + HH + '' + "\n" #f+=' ' + "\n" f+=' ' + "\n" f+=' '')' + "\n" html+=' document.writeln(" body {")' + "\n" html+=' document.writeln(" margin-left: 8%;")' + "\n" html+=' document.writeln(" margin-right: 8%;")' + "\n" html+=' document.writeln(" font-family: sans-serif;")' + "\n" html+=' document.writeln(" }")' + "\n" html+=' document.writeln(" h2 { margin-left: -3% }")' + "\n" html+=' document.writeln(" h3,h4,h5,h6 { margin-left: -2% }")' + "\n" html+=' document.writeln(" pre {")' + "\n" html+=' document.writeln(" font-weight: normal;")' + "\n" html+=' document.writeln('' white-space: pre; font-family: "Courier New", monospace;'')' + "\n" html+=' document.writeln(" }")' + "\n" html+=' document.writeln(" tt {")' + "\n" html+=' document.writeln(" font-weight: normal;")' + "\n" html+=' document.writeln('' white-space: pre; font-family: "Courier New", monospace;'')' + "\n" html+=' document.writeln(" }")' + "\n" html+=' document.writeln(" em { font-style: italic; font-weight: bold }")' + "\n" html+=' document.writeln(" strong { text-transform: uppercase; font-weight: bold }")' + "\n" html+=' document.writeln(" ")' + "\n" html+='} ' + "\n" html+='function MM_findObj(n, d) { //v3.0' + "\n" html+=' var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {' + "\n" html+=' d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}' + "\n" html+=' if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i>Sum(@," ") # return (Split(s) % function(x) (x=='and'|x=='to'|x=='a'|x=='an'|x=='for|'x=='by'|x=='or'|x=='of'|x=='the')?x:Toupper(x,1))>>Sum(@," ") endfunction function Upn(s) return s; endfunction function doargs(noft) write string "" '.splittxerr.tx' if (!shell.ParseArgs("esfp",{"side","err","full","path"}) | Nof(shell.args)>1) then #PROCESS ARGS helpp() quit endif side=shell.options.s | shell.options.side #SIDE FLAG CHECK if (side) write string frameset(T) path + "/" + "frames.htm" if (shell.options.e | shell.options.err) then #ERROR FLAG CHECK eee=no endif if(! shell.options.path) shell.options.path=shell.options.p #PATH SET if(! shell.options.path) then shell.options.path=path endif if(! shell.options.path) shell.options.path="man" unix mkdir $path if(Nof(shell.args)==0) shell.args[1] = "stdin" #STANDARD INPUT SET for i=1,Nof(shell.args) read string shell.args[i] name="aaa"; s+= aaa; endfor s=Replace(s, '\{\}', '{ }') sss # titles ss # body texts sss=string(Match(s, ' END endfunction