Changeset 1623
- Timestamp:
- 08/29/06 07:55:32
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/hackathon-summary/plagger/lib/Plagger/Plugin/Summary/Simple.pm
r1618 r1623 19 19 if ($text->is_html) { 20 20 # HTML: grab first block paragraph, or until first <br /> 21 local $HTML::Tagset::isBodyElement{div} = 0; 21 22 my $html = $text->data; 22 if ($html =~ m|^\s*<(\w*)\s*[^>]*>(.*?)</\1>|s && $HTML::Tagset::isBodyElement{lc($1)}) { 23 return "<$1>$2</$1>"; 24 } elsif ($html =~ m!^(.*?)<br\s*/?>!s) { 23 while ($html =~ s|^\s*<(\w*)\s*[^>]*>(.*?)</\1>|$2|gs) { 24 if ($HTML::Tagset::isBodyElement{lc($1)}) { 25 return "<$1>$2</$1>"; 26 } 27 } 28 29 if ($text->data =~ m!^(.*?)<br\s*/?>!s) { 25 30 return $1; 26 31 } else { 27 return $ html;32 return $text->data; 28 33 } 29 34 } else { branches/hackathon-summary/plagger/t/plugins/Summary-Simple/base.t
r1618 r1623 68 68 --- expected 69 69 Foo Bar Baz 70 71 === Deal with <div>. nasty hack 72 --- input 73 <div class="foo"><p>First paragraph</p><p>Second paragraph</p></div> 74 --- expected 75 <p>First paragraph</p> 76 77 === Deal with <div>. nasty hack 78 --- input 79 "<div class=\"foo\">\n<p>First paragraph</p><p>Second paragraph</p></div>" 80 --- expected 81 <p>First paragraph</p>
