Changeset 1549

Show
Ignore:
Timestamp:
08/21/06 00:26:33
Author:
miyagawa
Message:

added Plagger::Text->html method

Files:

Legend:

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

    r1527 r1549  
    4343} 
    4444 
     45sub html { 
     46    my $self = shift; 
     47    if ($self->is_html) { 
     48        return $self->data; 
     49    } else { 
     50        Plagger::Util::encode_xml($self->data); 
     51    } 
     52} 
     53 
    4554sub plaintext { 
    4655    my $self = shift; 
  • branches/hackathon-summary/plagger/lib/Plagger/Util.pm

    r1547 r1549  
    170170    '<' => '&lt;', 
    171171    '>' => '&gt;', 
    172     "'" => '&quot;', 
     172    '"' => '&quot;', 
     173    "'" => '&apos;', 
    173174); 
    174175 
  • branches/hackathon-summary/plagger/t/core/text.t

    r1544 r1549  
    1010    my $block = shift; 
    1111    my $text = Plagger::Text->new_from_text($block->input); 
    12     my $test = { type => $text->type, plaintext => $text->plaintext }; 
     12    my $test = { type => $text->type, plaintext => $text->plaintext, html => $text->html }; 
    1313    is_deeply $test, $block->expected, $block->name; 
    1414} 
     
    2222type: text 
    2323plaintext: Hello World 
     24html: Hello World 
    2425 
    2526=== &amp; 
     
    2930type: html 
    3031plaintext: Hello & World 
     32html: Hello &amp; World 
    3133 
    3234=== & 
     
    3638type: text 
    3739plaintext: '"The Big & Small"' 
     40html: "&quot;The Big &amp; Small&quot;" 
    3841 
    3942=== quot; 
     
    4245--- expected 
    4346type: html 
    44 plaintext: Foo "baz"  
     47plaintext: Foo "baz" 
     48html: Foo &quot;baz&quot; 
    4549 
    4650=== Tags 
     
    5054type: html 
    5155plaintext: Hello World 
     56html: <p>Hello World</p> 
    5257 
    5358=== XHTML 
     
    5762type: html 
    5863plaintext: "Hello\nWorld" 
     64html: Hello <br /> World 
    5965 
    6066=== <wbr> 
     
    6470type: html 
    6571plaintext: Hello World 
     72html: Hello <wbr> World 
    6673 
    6774=== Unknown Tags 
     
    7178type: text 
    7279plaintext: <foo>Hello</foo> 
     80html: "&lt;foo&gt;Hello&lt;/foo&gt;" 
     81 
     82