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

Last change on this file since 149135 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
RevLine 
[38342]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
[120885]9set replacement "<body\\1><div class=\"book\">$replacement"
[38342]10
11# Add the table of contents to all other html files.
[38440]12foreach path [glob -directory [lindex $argv 0] {*.html}] {
[120885]13    if {[file tail $path] == "index.html"} {
[38440]14        continue
15    }
16
[38342]17    set file [open $path r+]
18    set data [read $file]
[120885]19    regsub {<body([^>]+)>} $data $replacement data
[38342]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.