gaim/www

Add Sametime to the list of supported protocols, add 'Novell' in front of GroupWise to match the About box, remove 'MSN window closing notification' from the feature list.
#!/usr/bin/perl
# This script has the same license as gaim
# FIXME. This script outputs tables. lynx can't handle tables; w3m is required
#
# Usage: ./reformat.pl faq.txt | w3m -no-graph -T text/html > FAQ
use strict;
use integer;
# "Constants"
my $line = '-' x 78;
# State variables
my $in_question_p = 0;
my @sections = ();
my @questions = ();
sub fix_anchors ($) {
my ($s) = @_;
my $it = '';
while ($s =~ /\S/) {
if ($s =~ /^(<a\b[^<>]*href=("?))([^"\s]+)(\2[^<>]*>)((?:(?!<\/a>).)*)(<\/a>)/i) {
my ($open1, $url, $open2, $text, $close) = ($1, $3, $4, $5, $6);
$s = $';
$url = "http://gaim.sf.net/$'" if $url =~ /^\.\//;
$url = "http://gaim.sf.net/$url"
if $url !~ /^#/ && $url !~ /:/;
# Attempt to handle "here" type links and such
if ($text =~ /^(?:here$|(?:these|this)\b.*)/i) {
$it .= "$open1$url$open2$url$close";
} elsif ($text =~ /^(.*)\bhere$/i) {
$it .= "$open1$url$open2$1 at $url$close";
} elsif ($url =~ /^#/
|| $url eq $text
|| $url eq "$text/"
|| $url eq "http://$text"
|| $url eq "http://$text/") {
$it .= "$open1$url$open2$text$close";
} else {
$it .= "$open1$url$open2$text$close ($url)";
}
} else { # FIXME. This is very inefficient
$it .= substr($s, 0, 1);
$s = substr($s, 1);
}
}
return $it;
}
sub finish_section () {
if (@questions) {
$sections[$#sections]->[1] = [ @questions ];
@questions = ();
}
}
while (<>) {
s/^!ANCHOR\s+(\S*)/<a name=\"\1\"><\/a>/;
s/^!COMMENT\s+(.*)//;
next unless /\S/;
if (/^!SECTION\s+(.*)/) {
finish_section if @questions;
push @sections, [$1];
} elsif (/^Q:\s*(.*)/) {
push @questions, [$1, []];
$in_question_p = 1;
} elsif (/^A:\s*(.*)/) {
push @{$questions[$#questions]->[1]}, $1;
$in_question_p = 0;
} elsif ($in_question_p) {
$questions[$#questions]->[0] .= " $_";
} else {
push @{$questions[$#questions]->[1]}, $_;
}
}
finish_section;
# Page heading
print "<h1>Gaim: The Pimpin' Penguin IM Clone Thats Good For The Soul</h1>\n";
# Index
my $i = 0;
for my $section (@sections) {
printf "<h3>%d. %s</h2>\n", ++$i, $section->[0];
printf "<table width=\"100%\">\n";
my $j = 0;
for my $question (@{$section->[1]}) {
printf "<tr><td width=56><td width=24>%d.%d.<td>", $i, ++$j;
printf "<a href=\"#s%dq%d\">%s</a></div>\n",
$i, $j, $question->[0];
}
printf "</table>\n";
}
# Actual questions
$i = 0;
for my $section (@sections) {
printf "<h2>+%s<br>| %d. %s<br>+%s</h2>\n",
$line, ++$i, $section->[0], $line;
my $j = 0;
for my $question (@{$section->[1]}) {
printf "<a name=\"s%dq%d\"></a>\n", $i, ++$j;
printf "<table width=\"100%\"><tr valign=top>\n";
printf "<td width=24 colspan=2>%d.%d", $i, $j;
printf "<td>%s\n", $question->[0];
printf "<tr><td colspan=3>&nbsp;\n";
printf "<tr><td width=12><td colspan=2>";
printf "<p>%s</p>\n",
fix_anchors(join("\n", @{$question->[1]}));
printf "</table>\n";
}
}