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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#!/usr/bin/perl -w
# Copyright (c) 1998-99 by Marco Budde (Budde@tu-harburg.de)
# GNU General Public License
##############################################################
# sgmltools -> dhelp, dwww, index.html #
# #
# usage: sgml2dhelp <dhelp section> <dwww section> #
##############################################################
# you
$maintainer = 'Wouter Verhelst (wouter@debian.org)';
# regexp to find the root html file of a document
$file_expr = '^(.+)[^0-9]\.html$';
# regexp to produce a link name from the file name
$title_expr = '^(.+)\.html$';
##############################
# get abstract of document #
##############################
sub get_abstract
{
my $zw;
open (IN, "< $filename") or die "can't open $filename!\n";
$abstract = '';
while ($zw = <IN>)
{
if ($zw =~ /<FONT SIZE=-1 FACE=\"Helvetica, Arial\">(.*)/)
{
$abstract = $1;
while ($zw !~ /<\/FONT>/)
{
if (!($zw = <IN>))
{
$abstract = '';
return;
}
$abstract .= ' ' . $zw;
}
}
}
$abstract =~ s/<\/FONT>//;
$abstract =~ s/<\/em>//ig;
$abstract =~ s/<em>//ig;
$abstract =~ s/<\/i>//ig;
$abstract =~ s/<i>//ig;
$abstract =~ s/<\/b>//ig;
$abstract =~ s/<b>//ig;
$abstract =~ s/<\/code>//ig;
$abstract =~ s/<code>//ig;
$abstract =~ s/<a href=(.*?)>//ig;
$abstract =~ s/<\/a>//ig;
close (IN);
}
##################
# write .dhelp #
##################
sub write_dhelp
{
print DHELP "<item>\n";
print DHELP "<directory>$ARGV[0]\n";
print DHELP "<linkname>$linkname\n";
print DHELP "<filename>$filename\n";
print DHELP "<description>\n$abstract\n</description>\n";
print DHELP "</item>\n\n";
}
#########################
# .dwww-index support #
#########################
sub dwww_pwd
{
$pwd = `pwd`;
$pwd =~ /.*?\/usr\/doc\/*(.*)/;
$pwd = $1;
}
sub write_dwww
{
print DWWW "#section $ARGV[1]\n";
print DWWW "<dt><a href=\"$pwd/$filename\">$linkname</a>\n";
print DWWW "<dd>$abstract\n\n";
}
########################
# index.html support #
########################
sub write_index
{
print INDEX "<DT><A HREF=\"$filename\">$linkname</A>\n";
print INDEX "<DD>$abstract\n\n";
}
################
# main #
################
opendir (DIRHANDLE, '.');
@dircontent = readdir (DIRHANDLE);
closedir (DIRHANDLE);
open (DHELP, "> .dhelp");
open (INDEX, "> index.html");
print INDEX "<HTML>\n<BODY BGCOLOR=FFFFFF>\n<DL>\n";
open (DWWW, "> .dwww-index");
&dwww_pwd;
foreach $filename (sort @dircontent)
{
if ($filename =~ /$file_expr/)
{
$filename =~ /$title_expr/;
$linkname = $1;
$linkname =~ s/-HOWTO/ HOWTO/g;
print "$filename\n";
&get_abstract;
&write_dhelp;
&write_index;
&write_dwww;
}
}
close (DHELP);
print INDEX "</DL>\n<HR>\n<ADDRESS><SMALL>\n";
print INDEX "Please send comments to $maintainer.\n";
$time = gmtime (time);
print INDEX "<BR>This page was created $time GMT.</SMALL></ADDRESS>\n";
print INDEX "</BODY>\n</HTML>\n";
close (INDEX);
close (DWWW);
|