File: cutlatexdoc

package info (click to toggle)
ts 9802-1
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 2,348 kB
  • ctags: 1,468
  • sloc: tcl: 4,567; ansic: 3,389; makefile: 88; sh: 1
file content (71 lines) | stat: -rwxr-xr-x 1,635 bytes parent folder | download | duplicates (2)
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
#!/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>--&gt;<a href=\"index.html\">LaTeX index</a>"
  puts $fo "</body>"
  puts $fo "</html>"
}

set fi [open latex2e.html r]
set fo [open help/eng/latex/index.html 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/eng/latex/${sec}.html w]
    regexp {A NAME[^>]*>([^<]*)} $s dummy title
    regsub -all {\\} $title {\&#92;} title
    head $fo $title
  } else {
    regsub -all {\\} $s {\&#92;} s
    if {[regexp {NAME="IDX([^"]*)"} $s dummy idx]} {
      keylset lidx $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
        regsub {HREF="latex2e.html#IDX([^"]*)"} $s \
          "href=\"[keylget lidx $idx].html\"" s
      }
      puts $fo $s
    }
  }
}
foot $fo
close $fo
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 "--&gt; <a href=\"../main.html#main\">Start menu</a>"
#puts $fo "</body>"
#puts $fo "</html>"
#close $fo
#close $fi