1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#!/usr/bin/tcl
proc head {fo title} {
puts $fo "<html>"
puts $fo "<head><title>$title</title></head>"
puts $fo "<body>"
puts $fo "<h1>$title</h1>"
}
proc foot {fo} {
puts $fo "<p>--><a href=\"index.html\">LaTeX index</a>"
puts $fo "</body>"
puts $fo "</html>"
}
set fi [open latex2e.html r]
set fo [open help/english/latex/index.html w]
set fidx [open help/english/latex/latex.idx w]
set lidx {}
while {![eof $fi]} {
gets $fi s
if {[regexp {NAME="(SEC[^"]*)} $s dummy sec]} {
foot $fo
close $fo
set sec [string tolower $sec]
set fo [open help/english/latex/${sec}.html w]
regexp {A NAME[^>]*>([^<]*)} $s dummy title
regsub -all {\\} $title {} key
puts $fidx [list $key $sec.html]
regsub -all {\\} $title {\\} title
head $fo $title
} else {
regsub -all {\\} $s {\\} s
if {[regexp {NAME="IDX([^"]*)"} $s dummy idx]} {
lappend lidx [list $idx $sec]
puts "$idx $sec"
} else {
regsub -all {HREF="latex2e.html#SEC([^"]*)"} $s {href="sec\1.html"} s
if [regexp {HREF="latex2e.html#IDX([^"]*)"} $s dummy idx] {
puts $s
set i [lsearch $lidx $idx]
set ref [lindex [lindex $lidx $i] 1]
regsub {HREF="latex2e.html#IDX([^"]*)"} $s \
"href=\"$ref.html\"" s
}
puts $fo $s
}
}
}
foot $fo
close $fo
close $fidx
close $fi
#set fi [open dummy.html r]
#set fo [open help/eng/latex/index.html w]
#puts $fo "<html>"
#puts $fo "<head><title>LaTeX index</title>"
#puts $fo "</head>"
#puts $fo "<body>"
#puts $fo "<h1>LaTeX Index</h1>"
#puts $fo "<ul>"
#while {![eof $fi]} {
# gets $fi s
# if {[regexp {<LI>} $s]} {
# puts $fo $s
# }
#}
#puts $fo "</ul>"
#puts $fo "<p>"
#puts $fo "--> <a href=\"../main.html#main\">Start menu</a>"
#puts $fo "</body>"
#puts $fo "</html>"
#close $fo
#close $fi
|