Fix a bug where html2text dropped the last word. Added tests.

This commit is contained in:
Colin Kuskie 2009-04-25 05:41:24 +00:00
parent c452f92224
commit 3535e8ddb4
3 changed files with 29 additions and 3 deletions

View file

@ -1,6 +1,6 @@
7.7.5
- Adding StoryManager.
- fixed #10223: Calendar List View Ignores Event Permissions (dhelsten)
- fixed #10226: html2text dropping text
7.7.4
- rfe: Extend DateTime for Week-Nrs (#9151)

View file

@ -227,7 +227,7 @@ my $text = "";
my $inside = {};
sub html2text {
my $html = shift;
my $html = shift . " ";
$text = "";
$inside = {};
my $tagHandler = sub {

View file

@ -96,7 +96,28 @@ my @macroParamSets = (
},
);
my $numTests = scalar @filterSets + scalar @macroParamSets;
my @htmlTextSets = (
{
inputText => q|I wish I could tell you that Andy fought the good fight.|,
output => q|I wish I could tell you that Andy fought the good fight.|,
comment => 'bare text',
},
{
inputText => q|The man likes to play chess; let's get him some rocks. |,
output => q|The man likes to play chess; let's get him some rocks.|,
comment => 'bare text with ending space has that space removed',
},
{
inputText => q|<p>Do you enjoy working in the laundry?</p>|,
output => qq|\nDo you enjoy working in the laundry?\n|,
comment => 'text in paragraph tag nested inside newlines',
},
);
my $numTests = scalar @filterSets
+ scalar @macroParamSets
+ scalar @htmlTextSets
;
plan tests => $numTests;
@ -109,3 +130,8 @@ foreach my $testSet (@macroParamSets) {
WebGUI::HTML::makeParameterSafe(\$testSet->{inputText});
is($testSet->{inputText}, $testSet->{output}, $testSet->{comment});
}
foreach my $testSet (@htmlTextSets) {
my $text = WebGUI::HTML::html2text($testSet->{inputText});
is($text, $testSet->{output}, $testSet->{comment});
}