[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: table of contents for lua50, final
- From: Joe Myers <joe31416@...>
- Date: Tue, 15 Apr 2003 11:14:43 -0700 (PDT)
Hello List,
I missed a table of contents for the new (nice!) lua50 final distro, so I
wrote a perlscript to create one (appended below). So I'm sending this on
in case anyone else would find it useful.
Simply run this in the same directory as manual.html, it will create
files manual2.html and manual2-toc.html (table of contents).
If you've trouble running it (like, if you don't have perl installed), let
me know, I can either put this on the wiki / my website / or email you the
resulting files (too large to send on a list).
Joe
//////////////////// cut here ////////////////////
#!/usr/bin/env perl
# lua50toc.pl -- Joe Myers, joe31416@procrasticon.com 04/15/03
# hunts for header strings of form
# n1.n2.n3 - xxxx
# for example:
# <h1>1 - Introduction</h1>
# <h2>2.1 - Lexical Conventions</h2>
# <h3>2.2.1 - Coercion</h3>
# in the stock manual.html file, adding new anchor 'ref:---' before each
# in the revised manual ($Outfi = manual2.html)
# and building the table of contents ($Tocfi = index.html) at the
# same time.
# globals
$Infi = "manual.html"; # input file
$Outfi = "manual2.html"; # revised manual w/ 'ref:---' tags
$Tocfi = "manual2-toc.html"; # new table of contents
sub process {
my($wholematch, $mrk, $tag) = @_;
my $name = "ref:$tag";
print TOCFI qq(<a href="$Outfi#$name">$mrk</a><br>\n);
return qq(<a name="$name">$wholematch);
}
open(OUTFI, ">$Outfi");
open(TOCFI, ">$Tocfi");
print TOCFI <<START;
<html>
<head>
<title>lua50 contents (04/2003)</title>
</head>
<body>
<H1><center>lua50 contents (04/2003)</center></H1>
START
undef $/; # slurp!
open(IN, $Infi);
$_ = <IN>;
close(IN);
s#( <(h[1-3])> ((\d+(?:\.\d+)*) \s-\s .+?) </\2> )#
process($1,$3,$4) #isxge;
print OUTFI $_;
close(OUTFI);
print TOCFI "</body></html>\n";
close(TOCFI);
system("wc -l $Tocfi $Outfi");