#!/usr/bin/perl -w
use IO::File;
my @foo;
while (<>) {
if (/\\include{(.+?)}/ && $1 !~ /^part-/) {
push @foo, $1;
}
}
my $fh = new IO::File "indextmpl.html", "r";
while (<$fh>) {
if (/-- INDEXLINES --/) {
print "
\n";
for my $f (@foo) {
my $chapname = "UNDEFNAME";
my $status = undef;
if ($f eq "bib") {
$chapname = "Bibliography";
$status = "auto-generated";
}
else {
my $chf = new IO::File "${f}.tex", "r";
NAMESCAN: while (<$chf>) {
chomp;
if (/\\chapter{(.+?)}(\\label)?/) { $chapname = $1; }
if (/^\%STATUS:\s+(\S.+)/) { $status = $1; }
}
close $chf;
}
print '- ', $chapname, ', status: ',
(defined $status? "$status" : "not ready"),
' (TeX)
', "\n";
}
print "
\n";
}
else {
print;
}
}