Acme-AsciiArt2HtmlTable
view release on metacpan or search on metacpan
..::Acme::AsciiArt2HtmlTable version 0.01
=========================================
=head1 NAME
Acme::AsciiArt2HtmlTable - Converts Ascii art to an HTML table
=head1 VERSION
Version 0.01
=head1 SYNOPSIS
use Acme::AsciiArt2HtmlTable;
my $table = "ggggggggrrrrrrrrrrrrrr\n" .
"ggggggggrrrrrrrrrrrrrr\n" .
"ggggggggrrrrrrrrrrrrrr\n" .
"ggggggggrrrrrrrrrrrrrr\n" .
"ggggggyyyyrrrrrrrrrrrr\n" .
"ggggggyyyyrrrrrrrrrrrr\n" .
"gggggyyyyyyrrrrrrrrrrr\n" .
"gggggyyyyyyrrrrrrrrrrr\n" .
"ggggggyyyyrrrrrrrrrrrr\n" .
"ggggggyyyyrrrrrrrrrrrr\n" .
"ggggggggrrrrrrrrrrrrrr\n" .
"ggggggggrrrrrrrrrrrrrr\n" .
"ggggggggrrrrrrrrrrrrrr\n" .
"ggggggggrrrrrrrrrrrrrr\n" ;
my $html = aa2ht( { td => { width => 3 , height => 3 } } , $table);
# $html now holds a table with a color representation of your
# ascii art. In this case, the Portuguese flag.
=head1 FUNCTIONS
=head2 aa2ht
Gets ascii text and converts it to an HTML table. This is how it works:
=over 4
=item * each line is a C<tr> element
=item * each letter is a C<td> element
=item * each C<td> has background of a specific color, which is
defined by the letter that created it
=back
=head3 OPTIONS
You can pass a reference to a hash before the text you want to
convert.
=head4 id
In order to save space in the output, C<td> and C<tr> elements'
attributes are not in each element, but rather in a C<style> element.
This causes a problem if you want to put two different outputs with
different attributes on the same page.
To solve this problem: C<id>.
When creating a table, use the parameter C<id> to make sure it doesn't
end up mixed up with something else.
my $html = aa2ht( { 'id' => 'special' } $ascii );
The result will be something like this:
<style>
.special td { width:1; height:1; }
.special tr { }
</style>
<table class="special" cellspacing="0" cellpadding="0" border="0">
=head4 use-default-colors
If set to a false value, no default mappings are used.
my $html = aa2ht( { 'use-default-colors' => 0 }, $ascii);
Behind the curtains, there is still a mapping: the default mapping to
white.
=head4 colors
You can override color definitions or specify your own.
my $html = aa2ht( { 'colors' => { '@' => 'ffddee',
'g' => '00ffff' } }, $ascii);
=head4 randomize-new-colors
If set to a true value, letters with no mappings are assigned a
random one.
my $html = aa2ht( { 'randomize-new-colors' => 1 }, $ascii);
You might want to remove the default mappings if you're really
interested in a completely random effect:
my $html = aa2ht( { 'use-default-colors' => 0,
'randomize-new-colors' => 1 }, $ascii);
( run in 0.964 second using v1.01-cache-2.11-cpan-d8267643d1d )