# 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 if ($s =~ /^(<a\b[^<>]*href=("?))([^"\s]+)(\2[^<>]*>)((?:(?!<\/a>).)*)(<\/a>)/i) { my ($open1, $url, $open2, $text, $close) = ($1, $3, $4, $5, $6); $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"; || $url eq "http://$text" || $url eq "http://$text/") { $it .= "$open1$url$open2$text$close"; $it .= "$open1$url$open2$text$close ($url)"; } else { # FIXME. This is very inefficient $sections[$#sections]->[1] = [ @questions ]; s/^!ANCHOR\s+(\S*)/<a name=\"\1\"><\/a>/; if (/^!SECTION\s+(.*)/) { finish_section if @questions; push @questions, [$1, []]; push @{$questions[$#questions]->[1]}, $1; } elsif ($in_question_p) { $questions[$#questions]->[0] .= " $_"; push @{$questions[$#questions]->[1]}, $_; print "<h1>Gaim: The Pimpin' Penguin IM Clone Thats Good For The Soul</h1>\n"; for my $section (@sections) { printf "<h3>%d. %s</h2>\n", ++$i, $section->[0]; printf "<table width=\"100%\">\n"; 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", for my $section (@sections) { printf "<h2>+%s<br>| %d. %s<br>+%s</h2>\n", $line, ++$i, $section->[0], $line; 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> \n"; printf "<tr><td width=12><td colspan=2>"; fix_anchors(join("\n", @{$question->[1]}));