[l2h] tableofcontents UL type - Perl script

Peter Morling pmorling at nat.sdu.dk
Wed Oct 29 12:26:28 CET 2003


Hi,

here's a perl script to post-process the HTML document and set the UL class
for the table of contents only.

-----------------------------------------------
#!/usr/bin/perl
$line = "";

while (<>) {            # Load all input lines into one string
   $f .= $_;
}

# Matching across lines
$a = $f;
$b = $f;
$c = $f;

$a =~ s/(.*)(<!--Table of Contents-->.*)/$1/gs;

$b =~ s/(.*)(<!--Table of Contents-->.*?<!--End of Table of
Contents-->)(.*)/$2/gs;
$b =~ s/<UL>/<UL class="toc">/gs;

$c =~ s/(.*<!--End of Table of Contents-->)(.*)/$2/gs;

print "$a$b$c";
-----------------------------------------------

Im sorry I don't know if this is good perl programming style (the
match-replace parts) since I really don't know Perl. If you can correct the
search/replace parts, please do.

I also hope that it's ok bringing up a perl-script, but it will make it
possible to produce a toc closer to LaTeX's toc and avoid the HTML bullets
(discs).

Best,

Peter












More information about the latex2html mailing list