Changeset 1623

Show
Ignore:
Timestamp:
08/29/06 07:55:32
Author:
miyagawa
Message:

Summary::Simple: Fixed summary generator to skip div ... not sure if this is the right thing.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/hackathon-summary/plagger/lib/Plagger/Plugin/Summary/Simple.pm

    r1618 r1623  
    1919    if ($text->is_html) { 
    2020        # HTML: grab first block paragraph, or until first <br /> 
     21        local $HTML::Tagset::isBodyElement{div} = 0; 
    2122        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) { 
    2530            return $1; 
    2631        } else { 
    27             return $html
     32            return $text->data
    2833        } 
    2934    } else { 
  • branches/hackathon-summary/plagger/t/plugins/Summary-Simple/base.t

    r1618 r1623  
    6868--- expected 
    6969Foo 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>