The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::HTML5::ToText::Trait::RenderTables - render tables

DESCRIPTION

This trait performs fancy rendering on HTML tables. It's quite intelligent, but on presentational tables, especially nested ones, doesn't look great. However, it's not smart enough to judge whether or not it will look great. Thus you can provide it with a callback on whether to perform fancy table rendering, or whether to use the default table rendering.

 print HTML::HTML5::ToText
   ->with_traits(qw/RenderTables/)
   ->new(should_render_table => sub
     {
       my ($self, $element) = @_;
       if ($element->getAttribute('class') =~ /layout/i)
       {
         return 1;  # true - fancy rendering
       }
       else
       {
         return;    # false - default rendering
       }
     })
   ->process($dom);

The table rendering engine understands the <caption>, <thead>, <tbody>, <tfoot>, <tr>, <th>, <td>, <colgroup> and <col> elements; and the span, align (values "left", "right" and "center"), colspan and rowspan attributes. It doesn't currently do valign, but maybe one day...

BUGS

Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=HTML-HTML5-ToText.

SEE ALSO

HTML::HTML5::ToText.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2012-2013 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.