HTML::HTML5::ToText::Trait::RenderTables - render tables
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...
<caption>
<thead>
<tbody>
<tfoot>
<tr>
<th>
<td>
<colgroup>
<col>
span
align
colspan
rowspan
valign
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=HTML-HTML5-ToText.
HTML::HTML5::ToText.
Toby Inkster <tobyink@cpan.org>.
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.
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.
To install HTML::HTML5::ToText, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::HTML5::ToText
CPAN shell
perl -MCPAN -e shell install HTML::HTML5::ToText
For more information on module installation, please visit the detailed CPAN module installation guide.