-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathmake_index.pl
70 lines (62 loc) · 1.48 KB
/
make_index.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
#
# Creates a .xhtml compliant index.html file
#
my $infile = shift @ARGV;
map { s/\.[0-9]$//; $pages{$_} = 1; } @ARGV;
open(I,$infile);
$first = 1;
print '<p class="SectionTitle">
Man pages
</p>
';
while (<I>) {
if (/^#\s*(.*)/) {
print "</table>\n" if (!$first);
print "<h2>$1</h2>\n";
print "<table width=\"100%\">\n";
$first = 0;
} else {
my $name = $_;
my $title;
chomp($name);
if (!exists($pages{$name})) {
print STDERR "$name is in $infile, but not in the rest of the args.\n";
print STDERR "Make sure it's not listed twice in $infile!\n";
}
open(H,"$name.html");
while (<H>) {
if (/<h1>(.*?)<\/h1>/i) {
$title = $1;
}
if (/<h2>NAME<\/h2>(.*)/i) {
$_ = $1;
# Ignore blank lines
while (/^\s*$/) {
$_ = <H>;
}
$title = $_;
chomp($title);
$title =~ s/\s*$name\s*-\s*//;
# Remove any complete <> tags
$title =~ s/<.*>//i;
# Remove any half open tags
$title =~ s/<.*//i;
}
}
close(H);
print " <tr>\n";
print " <td width=\"30%\"><a href=\"$name.html\">$name</a></td>\n";
print " <td>$title</td>\n";
print " </tr>\n";
print "\n";
delete $pages{$name};
}
}
print '</table>
<br/>';
@left = keys(%pages);
if ($#left > -1) {
print STDERR "missing a filing location for: ",
join(", ", @left), "\n";
}