source: trunk/doc-new/toc-for-chunked.tcl @ 82805

Last change on this file since 82805 was 38440, checked in by raimue@…, 12 years ago

doc-new/toc-for-chunked.tcl:
Handle all *.html files no matter how they are named (support for use.id.as.filename)

File size: 714 bytes
Line 
1# Adds the table of contents to every file of the chunked documentation.
2
3
4# Get the table of contents from the index.html file and create the
5# replacement string.
6set file [open "[lindex $argv 0]/index.html"]
7regexp {<div class="toc">.+?</div>} [read $file] replacement
8close $file
9set replacement "<body>$replacement<div class=\"book\">"
10
11# Add the table of contents to all other html files.
12foreach path [glob -directory [lindex $argv 0] {*.html}] {
13    if {$path == "index.html"} {
14        continue
15    }
16
17    set file [open $path r+]
18    set data [read $file]
19    regsub {<body>} $data $replacement data
20    regsub {</body>} $data {</div></body>} data
21    seek $file 0
22    puts $file $data
23    close $file
24}
Note: See TracBrowser for help on using the repository browser.