Acme-AsciiArt2HtmlTable
view release on metacpan or search on metacpan
lib/Acme/AsciiArt2HtmlTable.pm view on Meta::CPAN
my %area_width;
for ( $line .. $#lines ) {
my $min = _min( @we_could_have{$line .. $_} );
$area{$_} = (1 + $_ - $line) * $min;
$area_width{$_} = $min;
#$debug .="\nwe could make an area of $area{$_} up to line $_, with a maximum of $area_width{$_} cells per line";
}
# check which is the line that maximizes optimization
my $max_area = _max(values %area);
my $best_line = _max(grep { $area{$_} == $max_area } keys %area);
#$debug .= "\nour best choice seem to be using line $best_line";
# check the are width
my $width = $cell + $area_width{$best_line} - 1;
# clean everything in the area we're about to optimize
#$debug .= "\nwe want to clean everything from lines $line to $best_line and cells $cell to $width";
for my $l ( $line .. $best_line ) {
for my $c ( $cell .. $width ) {
next if ( $l == $line and $c == $cell );
$lines[$l]->[$c] = '';
}
}
# optimize
my $rowspan = $best_line - $line + 1;
my $colspan = $area_width{$best_line};
if ( $rowspan > 1 ) { $optimization .= " rowspan=\"$rowspan\"" }
if ( $colspan > 1 ) { $optimization .= " colspan=\"$colspan\"" }
#$debug .= "\n";
}
$lines[$line]->[$cell] = "<td$optimization bgcolor=\"" .
( $config{'colors'}{ $lines[$line]->[$cell] } ||
$config{'colors'}{'default'} ) .
( run in 0.371 second using v1.01-cache-2.11-cpan-4e96b696675 )