#line 10 "tohtml.nw" # Copyright 1994 by Norman Ramsey. All rights reserved. # See file COPYRIGHT for more information. #line 19 "tohtml.nw" # Don't try to understand this file! Look at icon/tohtml.nw in the noweb source! global braw, eraw procedure main(args) local delay, raw, where, localindex, noindex, shortxref #line 218 "tohtml.nw" useitemstab := table() defns := table("") defns_above := set() # keep track of defining chunks we've seen #line 25 "tohtml.nw" every braw | eraw := "" delay := !args == "-delay" noindex := !args == "-noindex" shortxref := if !args == "-longxref" then &null else 1 localindex := (/noindex, !args == "-localindex") # produce local identifier xref? raw := !args == "-raw" if \raw then {braw := "\\begin{rawhtml}"; eraw := "\\end{rawhtml}"} if !args == "-no-gen-comment" then &null else write(braw, "", eraw) while inputline := read() do inputline ? { #line 90 "tohtml.nw" if ="@text " then { text +:= *(line := tab(0)) if \code then writes(( #line 98 "tohtml.nw" 2(line ? {tab(many(' \t')); not pos(0)}, linkto(\lastindexref, escapeSpecials(line)), lastindexref := &null) #line 92 "tohtml.nw" ) | escapeSpecials(line)) else if \quoting then writes(( #line 123 "tohtml.nw" 2(line ? {tab(many(' \t')); not pos(0)}, linklabelto(lastxreflabel, lastindexref, escapeSpecials(line), "bare"), lastxreflabel := lastindexref := &null) #line 94 "tohtml.nw" ) | escapeSpecials(line)) else writes(( #line 107 "tohtml.nw" 1(line ? skip_white_tags() || linklabel(\lastxreflabel, skip_chars()) || tab(0), insert(defns_above, \lastxreflabel), lastxreflabel := &null) #line 96 "tohtml.nw" ) | line) } else #line 207 "tohtml.nw" if ="@nl" & pos(0) then { #line 292 "tohtml.nw" if \shortxref & (\pendinguses | \pendingprev | \pendingnext | \notused) then { #line 297 "tohtml.nw" if \pendinguses & *\useitems > 0 then { writes(" (") every i := 1 to *\useitems do { usedir := if member(defns_above, useitems[i]) then "<-U" else "U->" writes(if i > 1 then " " else "", linkto(useitems[i], usedir)) } writes(")") } if \pendingprev | \pendingnext then { writes(" [") writes(linkto(\pendingprev, "<-")) writes("D") writes(linkto(\pendingnext, "->")) writes("]") } #line 294 "tohtml.nw" pendinguses := pendingprev := pendingnext := notused := &null } #line 208 "tohtml.nw" write() } else #line 62 "tohtml.nw" if ="@begin code " then { code := 1 ; thischunk := &null #line 350 "tohtml.nw" useitems := [] notused := &null #line 64 "tohtml.nw" writes(braw, "
"); ecode := "" } else if ="@end code " then { #line 313 "tohtml.nw" if /shortxref then { useitems := useitemstab[\thischunk] if \pendingprev | \pendingnext | (\pendinguses, (*\useitems > 0 | \notused)) then { #line 356 "tohtml.nw" if ecode == "" then { writes("
") ecode := "" } #line 317 "tohtml.nw" #line 342 "tohtml.nw" useprefix := "Used " every i := 1 to *\useitems do { usedir := if member(defns_above, useitems[i]) then "above" else "below" usesuffix := if *\useitems > 1 then " (" || i || ")" else "" writes(useprefix, linkto(useitems[i], usedir || usesuffix)) useprefix := ", " } #line 318 "tohtml.nw" useitemstab[\thischunk] if *\useitems > 0 & (\pendingprev | \pendingnext) then writes("; ") p := if *\useitems > 0 then "previous" else "Previous" n := if *\useitems > 0 then "next" else "Next" if \pendingprev then if \pendingnext then writes(linkto(pendingprev, p), " and ", linkto(pendingnext, "next"), " definitions") else writes(linkto(pendingprev, p), " definition") else if \pendingnext then writes(linkto(pendingnext, n), " definition") if \pendingprev | \pendingnext | *\useitems > 0 then writes(".") if \notused then writes("
") pendinguses := pendingprev := pendingnext := useitems := notused := &null } } else &null #line 66 "tohtml.nw" code := nil ; previscode := 1 writes(ecode, eraw) } else #line 210 "tohtml.nw" if ="@defn " then { writechunk(lastxreflabel, lastxrefref, "dfn", thischunk := tab(0), defns[thischunk] || "=") insert(defns_above, \lastxreflabel) useitems := \useitemstab[thischunk] pendinguses := 1 #line 274 "tohtml.nw" every lastxreflabel | lastxrefref := &null #line 216 "tohtml.nw" defns[thischunk] := "+" } else #line 74 "tohtml.nw" if ="@begin docs " then { if \previscode then writes(if /raw then "
" else "\\par") previscode := &null text := 0 } else #line 82 "tohtml.nw" if ="@end docs " then { write(linklabel(\lastxreflabel, "*")) lastxreflabel := &null } else #line 222 "tohtml.nw" if ="@use " then { writechunk(lastxreflabel, lastxrefref, "i", tab(0)) #line 274 "tohtml.nw" every lastxreflabel | lastxrefref := &null #line 223 "tohtml.nw" } else #line 251 "tohtml.nw" if ="@xref " then { if fun := tab(upto(' ')) then {move(1); arg := tab(0)} else { fun := tab(0); arg := &null } case fun of { #line 265 "tohtml.nw" "label" : { #line 276 "tohtml.nw" warn_unused_xref("label", \lastxreflabel) #line 265 "tohtml.nw" ; lastxreflabel := arg } "ref" : { #line 278 "tohtml.nw" warn_unused_xref("ref", \lastxrefref) #line 266 "tohtml.nw" ; lastxrefref := arg } "prevdef" : pendingprev := arg "nextdef" : pendingnext := arg "beginuses" : useitems := [] "useitem" : put(useitems, arg) "enduses" : useitemstab[\thischunk] := useitems "notused" : notused := arg #line 364 "tohtml.nw" "begindefs" | "defitem" | "enddefs" : &null #line 367 "tohtml.nw" "beginchunks" : { write(braw, "
") ecode := "" } #line 317 "tohtml.nw" #line 342 "tohtml.nw" useprefix := "Used " every i := 1 to *\useitems do { usedir := if member(defns_above, useitems[i]) then "above" else "below" usesuffix := if *\useitems > 1 then " (" || i || ")" else "" writes(useprefix, linkto(useitems[i], usedir || usesuffix)) useprefix := ", " } #line 318 "tohtml.nw" useitemstab[\thischunk] if *\useitems > 0 & (\pendingprev | \pendingnext) then writes("; ") p := if *\useitems > 0 then "previous" else "Previous" n := if *\useitems > 0 then "next" else "Next" if \pendingprev then if \pendingnext then writes(linkto(pendingprev, p), " and ", linkto(pendingnext, "next"), " definitions") else writes(linkto(pendingprev, p), " definition") else if \pendingnext then writes(linkto(pendingnext, n), " definition") if \pendingprev | \pendingnext | *\useitems > 0 then writes(".") if \notused then writes("
") pendinguses := pendingprev := pendingnext := useitems := notused := &null } } else &null #line 410 "tohtml.nw" if /uglyindex | /shortxref then { #line 356 "tohtml.nw" if ecode == "" then { writes("
") ecode := "" } #line 412 "tohtml.nw" writes("Defines ") } else { writes("
"
else "]")
"beginuses" | "isdefined" | "useitem" | "enduses" : &null # use local links
#line 390 "tohtml.nw"
default : (\arg|"") ? warn_unknown("index " || fun)
}
}
# don't get any warnings if not doing indexing
} else
#line 237 "tohtml.nw"
if ="@quote" & pos(0) then { quoting := 1 ; writes(braw, "") } else
if ="@endquote" & pos(0) then { quoting := nil ; writes("
", eraw) } else
#line 240 "tohtml.nw"
if ="@file " then { filename := tab(0);
#line 274 "tohtml.nw"
every lastxreflabel | lastxrefref := &null
#line 240 "tohtml.nw"
} else
if ="@literal " then { writes(tab(0)) } else
if ="@header html " then {
#line 246 "tohtml.nw"
writes("
" || tab(find("]]"))
r ||:= tab(many(']')-2)
="]]" | fatal("impossible missing ]] in ", image(s))
r ||:= "
"
}
return r || tab(0)
}
end
#line 511 "tohtml.nw"
procedure warn_unknown(tag)
static warned
initial warned := set()
if not member(warned, tag) then {
write(&errout, "Warning: unrecognized escape @", tag, " ", tab(0))
insert(warned, tag)
}
return
end
#line 522 "tohtml.nw"
procedure fatal(L[])
write!([&errout, "noweb error in tohtml: "] ||| L)
exit(1)
end
#line 529 "tohtml.nw"
procedure rcsinfo ()
return "$Id: tohtml.nw,v 1.22 2008/10/06 01:03:05 nr Exp nr $" ||
"$Name: v2_12 $"
end