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 # pod::xhtml fails on begin/end blocks
82 # print $fh "=begin xhtml\n\n";
84 print $fh "=for html <table>";
85 print $fh map "<tr><td>" . +(join "</td><td>", htmlfcodes @$_) . "</td></tr>", @$table;
86 print $fh "</table>\n\n";
88 # print $fh "\n=end xhtml\n\n";
92 __PACKAGE__->new->parse_from_filehandle;