Changeset 1560

Show
Ignore:
Timestamp:
08/21/06 18:44:04
Author:
miyagawa
Message:

check if we have known tags more than unknown, in which case it dectes as html

Files:

Legend:

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

    r1549 r1560  
    2121 
    2222    my @tags = $text =~ m!<(\w+)\s?/?>!g; 
     23    my @unknown = grep !$HTML::Tagset::isKnown{$_}, @tags; 
    2324    my $type; 
    24     if (grep !$HTML::Tagset::isKnown{$_}, @tags) { 
     25    if (@unknown > @tags / 2) { 
    2526        $type = 'text'; 
    2627    } elsif (@tags || $text =~ m!&(?:amp|gt|lt|quot);!) { 
  • branches/hackathon-summary/plagger/t/core/text.t

    r1549 r1560  
    8080html: "&lt;foo&gt;Hello&lt;/foo&gt;" 
    8181 
     82=== Unknown Tags ... but lots of known tags 
     83--- input 
     84<p>Foo Bar <foo /></p> 
     85--- expected 
     86type: html 
     87plaintext: Foo Bar 
     88html: <p>Foo Bar <foo /></p> 
    8289 
     90