1 From c3c87ef92a31fc63d1a9e5cde4b0133c46769827 Mon Sep 17 00:00:00 2001
2 From: Thomas Sibley <trs@bestpractical.com>
3 Date: Thu, 2 Dec 2010 18:31:55 -0500
4 Subject: [PATCH] Parse <td> content with $self rather than a new instantiation
6 This makes sure table cell content is formatted the same way non-table
9 lib/HTML/FormatText/WithLinks/AndTables.pm | 2 +-
10 t/html-formattext-withlinks-andtables.t | 32 ++++++++++++++++++++++++++-
11 2 files changed, 31 insertions(+), 3 deletions(-)
13 diff --git a/lib/HTML/FormatText/WithLinks/AndTables.pm b/lib/HTML/FormatText/WithLinks/AndTables.pm
14 index a0fa60c..be6fa80 100644
15 --- a/lib/HTML/FormatText/WithLinks/AndTables.pm
16 +++ b/lib/HTML/FormatText/WithLinks/AndTables.pm
17 @@ -141,7 +141,7 @@ sub _format_tables {
18 $new_tree->{_content} = [ $td ];
19 # parse the contents of the td into text
20 # this doesn't work well with nested tables...
21 - my $text = __PACKAGE__->new->_parse($new_tree);
22 + my $text = $self->_parse($new_tree);
23 # we don't want leading or tailing whitespace
26 diff --git a/t/html-formattext-withlinks-andtables.t b/t/html-formattext-withlinks-andtables.t
27 index 780799f..8d33d0e 100644
28 --- a/t/html-formattext-withlinks-andtables.t
29 +++ b/t/html-formattext-withlinks-andtables.t
30 @@ -55,7 +55,11 @@ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit venena
32 my $text = HTML::FormatText::WithLinks::AndTables->convert($html, {rm=>80,cellpadding=>2});
43 @@ -96,6 +100,30 @@ q| BIG
47 -use Test::More tests=>1;
48 +use Test::More tests=>2;
50 'HTML::FormatText::WithLinks::AndTables->convert($html,{rm=>80,cellpadding=>2})';
52 +# Test the parsing of TD content
54 + my $html = <<' EOT';
55 +<a href="http://example.com">Link</a>
56 +<table><tr><td><a href="http://example.com/foo">Cell link</a></td></tr></table>
58 + my $expected = <<' EOT';
59 + Link (http://example.com)
61 + Cell link (http://example.com/foo)
64 + my $text = HTML::FormatText::WithLinks::AndTables->convert(
67 + after_link => ' (%l)',
73 + is $text, $expected, "Test TD content parsing";