diff options
Diffstat (limited to 'doc/tools/index-texi')
-rwxr-xr-x | doc/tools/index-texi | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/doc/tools/index-texi b/doc/tools/index-texi new file mode 100755 index 00000000..8aa85184 --- /dev/null +++ b/doc/tools/index-texi @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +use Getopt::Long; + +GetOptions( 'map=s' => \%mapping ) || die "Wrong options\n"; + +for $file (@ARGV) { + + open(FILE, "$file") || die "File not found: $file\n"; + + $indir = 0; + + while (<FILE>) { + + if (/\<H1\>\<A NAME=\".*\" HREF=\".*\"\>(.*)\<\/A\>\<\/H1\>/) { + $index = $mapping{$1}; +# print "Index: $1 => $index\n"; + } elsif (/\<DIR\>/) { + $indir = 1; + } elsif (/\<\/DIR>/) { + $indir = 0; + } elsif ($indir) { + if (/\<LI\>\<A HREF=\"([^\"]*)\"\>([^<]*)\<\/A\>/) { + unless ($lastindex eq $index) { + if ($lastindex) { + print "</$lastindex>\n"; + } + print "<$index>\n"; + $lastindex = $index; + } + $name = dehtml($2); + $url = $1; + print STDOUT "<entry name=\"$name\" url=\"$url\"/>\n"; + } + } + } + + close(FILE); +} + +if ($lastindex) { + print "</$lastindex>\n"; +} + +sub dehtml +{ + my ( $str ) = @_; + + $str =~ s/\<CODE\>//g; + $str =~ s/\<\/CODE\>//g; + $str =~ s/\<TT\>//g; + $str =~ s/\<\/TT\>//g; + + return $str; +} + +# Local Variables: +# mode: perl +# fill-column: 120 +# End: |