4 use List::Util qw(max);
9 # strip formatting codes, dumb version
11 s/[IBCLFSXZ]<< (.*?) >>/$1/gs;
12 s/[IBCLFSXZ]<(.*?)>/$1/gs;
24 S => "nobr", # non-std
28 # strip formatting codes, dumb version
30 s/([IBCLFSXZ])<< (.*?) >>/<$tag{$1}>$2<\/$tag{$1}>/gs;
31 s/([IBCLFSXZ])<(.*?)>/<$tag{$1}>$2<\/$tag{$1}>/gs;
37 my ($self, $command, $paragraph) = @_;
39 if ($command eq "begin" && $paragraph =~ /^\s*table\s*$/s) {
41 } elsif ($command eq "end" && $paragraph =~ /^\s*table\s*$/s) {
45 return $self->SUPER::command (@_);
50 my ($self, $para) = @_;
53 return $self->SUPER::verbatim (@_) unless $table;
55 my $table = [ map [$_ =~ /\t([^\t]*)/g], split /\n/, $para ];
56 my $cols = max map scalar @$_, @$table;
58 my $fh = $self->output_handle;
62 print $fh "=begin text\n\n";
65 print $fh " ", (map +(sprintf "%-15s ", $_), stripfcodes @$_), "\n";
68 print $fh "\n=end text\n\n";
72 print $fh "=begin roff\n\n";
74 print $fh ".TS\n" . ("l " x $cols) . ".\n";
75 print $fh map +(join "\t", stripfcodes @$_) . "\n", @$table;
78 print $fh "\n=end roff\n\n";
81 print $fh "=begin html\n\n";
83 print $fh "<table>\n";
84 print $fh map "<tr><td>" . +(join "</td><td>", htmlfcodes @$_) . "</td></tr>\n", @$table;
85 print $fh "</table>\n";
87 print $fh "\n=end html\n\n";
91 __PACKAGE__->new->parse_from_filehandle;