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

Last change on this file since 139002 was 120885, checked in by cal@…, 6 years ago

guide: new, more macports-y layout to replace the somewhat oldstyle layout of the guide

File size: 736 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\\1><div class=\"book\">$replacement"
10
11# Add the table of contents to all other html files.
12foreach path [glob -directory [lindex $argv 0] {*.html}] {
13    if {[file tail $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.