updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / perl-html-formattextwithlinksandtables / 0001-Fix-inconsistent-formatting.patch
blobe7d00831b59221a99217116744c09f5a51deaea6
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
7 content is formatted.
8 ---
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
24 $text =~ s/^\s+//s;
25 $text =~ s/\s+\z//s;
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
31 </html>|;
32 my $text = HTML::FormatText::WithLinks::AndTables->convert($html, {rm=>80,cellpadding=>2});
33 my $expected =
34 -q| BIG
35 +q|
39 + BIG
40 ===
42 How's it going?
43 @@ -96,6 +100,30 @@ q| BIG
47 -use Test::More tests=>1;
48 +use Test::More tests=>2;
49 is $text, $expected,
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>
57 + EOT
58 + my $expected = <<' EOT';
59 + Link (http://example.com)
61 + Cell link (http://example.com/foo)
63 + EOT
64 + my $text = HTML::FormatText::WithLinks::AndTables->convert(
65 + $html => {
66 + footnote => '',
67 + after_link => ' (%l)',
68 + before_link => '',
69 + leftmargin => 0,
70 + }
71 + );
73 + is $text, $expected, "Test TD content parsing";
75 --
76 1.7.0.4