Changeset 323

Show
Ignore:
Timestamp:
10/27/06 15:53:08 (2 years ago)
Author:
miya
Message:

Text::Trac: another fix of bugs reported on rt.cpan.org ticket #21431.
using Test::Base instead of Text::More.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • library/perl/trunk/Text-Trac/Changes

    r321 r323  
    22 
    330.05    Fri Oct 27 
    4         Fix the ticket #21431 on rt.cpan.org. 
     4        Using Test::Base instead of Test::More in 01-text-trac.t. 
     5        Fix the bug reported on rt.cpan.org ticket #21431. 
    56        http://rt.cpan.org/Ticket/Display.html?id=21431 
    67        Thanks to Andrew Sterling Hanenkamp and Graham TerMarsch. 
  • library/perl/trunk/Text-Trac/Makefile.PL

    r177 r323  
    1010    PL_FILES            => {}, 
    1111    PREREQ_PM => { 
    12         'Test::More'               => 0, 
     12        'Test::Base'               => 0, 
    1313        'UNIVERSAL::require'       => 0, 
    1414        'Class::Accessor::Fast'    => 0, 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/BlockquoteNode.pm

    r321 r323  
    66sub init { 
    77    my $self = shift; 
    8     $self->pattern(qr/^\s\s([^\s*].+)$/); 
     8    $self->pattern(qr/^\s+([^\s\*\daiAI].+)$/); 
    99    $self->block_nodes([ qw( heading p ul ol ) ]); 
    1010} 
     
    1414    my $c = $self->{context}; 
    1515    my $pattern = $self->pattern; 
    16     #$l =~ $pattern or return $l
     16    return if $l =~ /::$/
    1717 
    1818    $c->htmllines('<blockquote>'); 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/Context.pm

    r176 r323  
    33use base qw (Class::Accessor::Fast); 
    44 
    5 __PACKAGE__->mk_accessors( qw( current_ul_level current_ol_level min_heading_level permalink in_block_of ) ); 
     5__PACKAGE__->mk_accessors( qw( ul ol min_heading_level permalink in_block_of ) ); 
    66 
    77my %Defaults = ( 
    8         text               => '', 
    9         html               => '', 
    10         htmllines          => [], 
    11         current_ul_level   => 0
    12         current_ol_level   => 0
    13         shift_count        => 0, 
    14         in_block_of        => [], 
     8        text        => '', 
     9        html        => '', 
     10        htmllines   => [], 
     11        ul          => {}
     12        ol          => {}
     13        shift_count => 0, 
     14        in_block_of => [], 
    1515); 
    1616 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/OlNode.pm

    r176 r323  
    1515    my $pattern = $self->pattern; 
    1616    $l =~ $pattern or return $l; 
    17     my $ol_level = ( length($1) + 1 ) / 2; 
    1817    my $type  = $2; 
     18 
     19    my $space = length($1); 
     20    my $level = $c->ol->{level}; 
     21    $c->ol->{space} ||= 0; 
    1922 
    2023    my $start_tag; 
     
    3538    } 
    3639 
    37     if ( $ol_level > $c->current_ol_level ){ 
    38         for ( 1 .. $ol_level - $c->current_ol_level ){ 
    39             $l = $start_tag . $l; 
    40         } 
     40    if ( $space > $c->ol->{space} ){ 
     41        $l = $start_tag . $l; 
     42        $level++; 
    4143    } 
    42     elsif ( $ol_level < $c->current_ol_level ){ 
    43         for ( 1 .. $c->current_ol_level - $ol_level ){ 
    44             $l = '</ol>' . $l; 
    45         } 
     44    elsif ( $space < $c->ol->{space} ){ 
     45        $l = '</ol>' . $l; 
     46        $level--; 
    4647    } 
    4748 
    48     $c->current_ol_level($ol_level); 
     49    $c->ol({level => $level, space => $space }); 
    4950 
    5051    $l =~ s{ $pattern }{<li>$3</li>}xmsg; 
     
    5455    } 
    5556    else { 
    56         for ( 1 .. $c->current_ol_level($ol_level) ){ 
     57        for ( 1 .. $c->ol->{level} ){ 
    5758            $l .= '</ol>'; 
    5859        } 
    59         $c->current_ol_level(0)
     60        $c->ol->{level} = 0
    6061    } 
    6162 
     
    6768 
    6869    $c->htmllines($l); 
     70 
     71    return; 
    6972} 
    7073 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/UlNode.pm

    r321 r323  
    1414    my $pattern = $self->pattern; 
    1515    $l =~ $pattern or return $l; 
    16     my $ul_level = ( length($1) + 1 ) / 2; 
    1716 
    18     if ( $ul_level > $c->current_ul_level ){ 
    19         for ( 1 .. $ul_level - $c->current_ul_level ){ 
    20             $l = '<ul>' . $l; 
    21         } 
     17    my $space = length($1); 
     18    my $level = $c->ul->{level}; 
     19    $c->ul->{space} ||= 0; 
     20 
     21    if ( $space > $c->ul->{space} ) { 
     22        $l = '<ul>' . $l; 
     23        $level++; 
    2224    } 
    23     elsif ( $ul_level < $c->current_ul_level ){ 
    24         for ( 1 .. $c->current_ul_level - $ul_level ){ 
    25             $l = '</ul>' . $l; 
    26         } 
     25    elsif ( $space < $c->ul->{space} ) { 
     26        $l = '</ul>' . $l; 
     27        $level--; 
    2728    } 
    2829 
    29     $c->current_ul_level($ul_level); 
     30    $c->ul({level => $level, space => $space }); 
    3031 
    3132    $l =~ s{ $pattern }{<li>$2</li>}xmsg; 
     
    3536    } 
    3637    else { 
    37         for ( 1 .. $c->current_ul_level($ul_level) ){ 
     38        for ( 1 .. $c->ul->{level} ){ 
    3839            $l .= '</ul>'; 
    3940        } 
    40         $c->current_ul_level(0)
     41        $c->ul->{level} = 0
    4142    } 
    4243 
  • library/perl/trunk/Text-Trac/t/01-text-trac.t

    r321 r323  
    22 
    33use strict; 
    4 use Test::More tests => 28; 
    5 BEGIN { use_ok('Text::Trac') }; 
     4use Test::Base; 
     5use Text::Trac; 
     6 
     7delimiters('###'); 
     8 
     9plan tests => 1 * blocks; 
    610 
    711my $p = Text::Trac->new(); 
    812 
    9 isa_ok($p, 'Text::Trac'); 
    10  
    11 my ($text, $html, $generated_html); 
    12  
    13 ### h1 test ### 
    14 $text =<<txt; 
     13sub parse { 
     14    local $_ = shift; 
     15    $p->parse($_); 
     16    $p->html; 
     17
     18 
     19filters { input => 'parse', expected => 'chomp' }; 
     20run_is 'input' => 'expected'; 
     21 
     22__DATA__ 
     23### h1 test 
     24--- input 
    1525= heading 1 = 
    16 txt 
    17  
    18 $html =<<html; 
     26--- expected 
    1927<h1 id="heading1">heading 1</h1> 
    20 html 
    21  
    22 $p->parse($text); 
    23 chomp($html); 
    24 is( $p->html, $html ); 
    25  
    26 ### h2 test ### 
    27 $text =<<txt; 
     28 
     29### h2 test 
     30--- input 
    2831== heading 2 == 
    29 txt 
    30  
    31 $html =<<html; 
     32--- expected 
    3233<h2 id="heading2">heading 2</h2> 
    33 html 
    34  
    35 $p->parse($text); 
    36 chomp($html); 
    37 is( $p->html, $html ); 
    38  
    39 ### h3 test ### 
    40 $text =<<txt; 
     34 
     35### h3 test 
     36--- input 
    4137=== heading 3 === 
    42 txt 
    43  
    44 $html =<<html; 
     38--- expected 
    4539<h3 id="heading3">heading 3</h3> 
    46 html 
    47  
    48 $p->parse($text); 
    49 chomp($html); 
    50 is( $p->html, $html ); 
    51  
    52 ### h4 test ### 
    53 $text =<<txt; 
     40 
     41### h4 test 
     42--- input 
    5443==== heading 4 ==== 
    55 txt 
    56  
    57 $html =<<html; 
     44--- expected 
    5845<h4 id="heading4">heading 4</h4> 
    59 html 
    60  
    61 $p->parse($text); 
    62 chomp($html); 
    63 is( $p->html, $html ); 
    64  
    65 ### h5 test ### 
    66 $text =<<txt; 
     46 
     47### h5 test 
     48--- input 
    6749===== heading 5 ===== 
    68 txt 
    69  
    70 $html =<<html; 
     50--- expected 
    7151<h5 id="heading5">heading 5</h5> 
    72 html 
    73  
    74 $p->parse($text); 
    75 chomp($html); 
    76 is( $p->html, $html ); 
    77  
    78 ### bold test ### 
    79 $text =<<txt; 
     52 
     53### bold test 
     54--- input 
    8055'''bold''' '''bold''' 
    81 txt 
    82  
    83 $html =<<html; 
     56--- expected 
    8457<p> 
    8558<strong>bold</strong> <strong>bold</strong> 
    8659</p> 
    87 html 
    88  
    89 $p->parse($text); 
    90 chomp($html); 
    91 is( $p->html, $html ); 
    92  
    93 ### italic test ### 
    94 $text =<<txt; 
     60 
     61### italic test 
     62--- input 
    9563''italic'' ''italic'' 
    96 txt 
    97  
    98 $html =<<html; 
     64--- expected 
    9965<p> 
    10066<i>italic</i> <i>italic</i> 
    10167</p> 
    102 html 
    103  
    104 $p->parse($text); 
    105 chomp($html); 
    106 is( $p->html, $html ); 
    107  
    108 ### bolditalic test ### 
    109 $text =<<txt; 
     68 
     69### bolditalic test 
     70--- input 
    11071'''''bolditalic''''' '''''bolditalic''''' 
    111 txt 
    112  
    113 $html =<<html; 
     72--- expected 
    11473<p> 
    11574<strong><i>bolditalic</i></strong> <strong><i>bolditalic</i></strong> 
    11675</p> 
    117 html 
    118  
    119 $p->parse($text); 
    120 chomp($html); 
    121 is( $p->html, $html ); 
    122  
    123 ### underline test ### 
    124 $text =<<txt; 
     76 
     77### underline test 
     78--- input 
    12579__underline__ __underline__ 
    126 txt 
    127  
    128 $html =<<html; 
     80--- expected 
    12981<p> 
    13082<span class="underline">underline</span> <span class="underline">underline</span> 
    13183</p> 
    132 html 
    133  
    134 $p->parse($text); 
    135 chomp($html); 
    136 is( $p->html, $html ); 
    137  
    138 ### monospace test ### 
    139 $text =<<txt; 
     84 
     85### monospace test 
     86--- input 
    14087`monospace` {{{monospace}}} 
    141 txt 
    142  
    143 $html =<<html; 
     88--- expected 
    14489<p> 
    14590<tt>monospace</tt> <tt>monospace</tt> 
    14691</p> 
    147 html 
    148  
    149 $p->parse($text); 
    150 chomp($html); 
    151 is( $p->html, $html ); 
    152  
    153 ### strike test ### 
    154 $text =<<txt; 
     92 
     93### strike test 
     94--- input 
    15595~~strike~~ ~~strike~~ 
    156 txt 
    157  
    158 $html =<<html; 
     96--- expected 
    15997<p> 
    16098<del>strike</del> <del>strike</del> 
    16199</p> 
    162 html 
    163  
    164 $p->parse($text); 
    165 chomp($html); 
    166 is( $p->html, $html ); 
    167  
    168 ### sup test ### 
    169 $text =<<txt; 
     100 
     101### sup test 
     102--- input 
    170103^sup^ ^sup^ 
    171 txt 
    172  
    173 $html =<<html; 
     104--- expected 
    174105<p> 
    175106<sup>sup</sup> <sup>sup</sup> 
    176107</p> 
    177 html 
    178  
    179 $p->parse($text); 
    180 chomp($html); 
    181 is( $p->html, $html ); 
    182  
    183 ### sub test ### 
    184 $text =<<txt; 
     108 
     109### sub test 
     110--- input 
    185111,,sub,, ,,sub,, 
    186 txt 
    187  
    188 $html =<<html; 
     112--- expected 
    189113<p> 
    190114<sub>sub</sub> <sub>sub</sub> 
    191115</p> 
    192 html 
    193  
    194 $p->parse($text); 
    195 chomp($html); 
    196 is( $p->html, $html ); 
    197  
    198 ### br test ### 
    199 $text =<<TXT; 
     116 
     117### br test 
     118--- input 
    200119line1[[BR]]line2 
    201 TXT 
    202  
    203 $html =<<HTML; 
     120--- expected 
    204121<p> 
    205122line1<br />line2 
    206123</p> 
    207 HTML 
    208  
    209 $p->parse($text); 
    210 chomp($html); 
    211 is( $p->html, $html ); 
    212  
    213  
    214 ### p test ### 
    215 $text =<<TXT; 
     124 
     125### p test 
     126--- input 
    216127test 
    217128test 
    218 TXT 
    219  
    220 $html =<<HTML; 
     129--- expected 
    221130<p> 
    222131test 
    223132test 
    224133</p> 
    225 HTML 
    226  
    227 $p->parse($text); 
    228 chomp($html); 
    229 is( $p->html, $html ); 
    230  
    231 ### ul test ### 
    232 $text =<<TXT; 
     134 
     135### ul test 
     136--- input 
    233137 * list 1-1 
    234138 * list 1-2 
    235139   * list 2-1 
    236140   * list 2-2 
    237 TXT 
    238  
    239 $html =<<HTML; 
     141--- expected 
    240142<ul><li>list 1-1</li> 
    241143<li>list 1-2</li> 
    242144<ul><li>list 2-1</li> 
    243145<li>list 2-2</li></ul></ul> 
    244 HTML 
    245  
    246 $p->parse($text); 
    247 chomp($html); 
    248 is( $p->html, $html ); 
    249  
    250 ### ul test ### 
    251 $text =<<TXT; 
    252  * list 1-1 
    253  * list 1-2 
    254    * list 2-1 
    255    * list 2-2 
    256 TXT 
    257  
    258 $html =<<HTML; 
    259 <ul><li>list 1-1</li> 
    260 <li>list 1-2</li> 
    261 <ul><li>list 2-1</li> 
    262 <li>list 2-2</li></ul></ul> 
    263 HTML 
    264  
    265 $p->parse($text); 
    266 chomp($html); 
    267 is( $p->html, $html ); 
    268  
    269 ### ol test ### 
    270 $text =<<TXT; 
     146 
     147### ol test 
     148--- input 
    271149 1. list 1-1 
    272150 1. list 1-2 
    273151   a. list a-1 
    274152   a. list a-2 
    275 TXT 
    276  
    277 $html =<<HTML; 
     153--- expected 
    278154<ol start="1"><li>list 1-1</li> 
    279155<li>list 1-2</li> 
    280156<ol class="loweralpha"><li>list a-1</li> 
    281157<li>list a-2</li></ol></ol> 
    282 HTML 
    283  
    284 $p->parse($text); 
    285 chomp($html); 
    286 is( $p->html, $html ); 
    287  
    288 ### blockauote test ### 
    289 $text =<<TXT; 
     158 
     159### blockauote test 
     160--- input 
    290161  This text is a quote from someone else. 
    291 TXT 
    292  
    293 $html =<<HTML; 
     162--- expected 
    294163<blockquote> 
    295164<p> 
     
    297166</p> 
    298167</blockquote> 
    299 HTML 
    300  
    301 $p->process($text); 
    302 chomp($html); 
    303 is( $p->html, $html ); 
    304  
    305 ### pre test ### 
    306 $text =<<TXT; 
     168 
     169### pre test 
     170--- input 
    307171{{{ 
    308172  This is pre-formatted text. 
    309173  This also pre-formatted text. 
    310174}}} 
    311 TXT 
    312  
    313 $html =<<HTML; 
     175--- expected 
    314176<pre class="wiki"> 
    315177  This is pre-formatted text. 
    316178  This also pre-formatted text. 
    317179</pre> 
    318 HTML 
    319  
    320 $p->parse($text); 
    321 chomp($html); 
    322 is( $p->html, $html ); 
    323  
    324 ### table test ### 
    325 $text =<<TXT; 
     180 
     181### table test 
     182--- input 
    326183||Cell 1||Cell 2||Cell 3|| 
    327184||Cell 4||Cell 5||Cell 6|| 
    328 TXT 
    329  
    330 $html =<<HTML; 
     185--- expected 
    331186<table> 
    332187<tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr> 
    333188<tr><td>Cell 4</td><td>Cell 5</td><td>Cell 6</td></tr> 
    334189</table> 
    335 HTML 
    336  
    337 $p->parse($text); 
    338 chomp($html); 
    339 is( $p->html, $html ); 
    340  
    341 ### hr test ### 
    342 $text =<<TXT; 
     190 
     191### hr test 
     192--- input 
    343193line1 
    344194==== 
    345195line2 
    346 TXT 
    347  
    348 $html =<<HTML; 
     196--- expected 
    349197<p> 
    350198line1 
     
    354202line2 
    355203</p> 
    356 HTML 
    357  
    358 $p->parse($text); 
    359 chomp($html); 
    360 is( $p->html, $html ); 
    361  
    362 ### dl test ### 
    363 $text =<<TXT; 
     204 
     205### dl test 
     206--- input 
    364207 title1:: 
    365208  content 1-1 
     
    369212  content 2-2 
    370213  content 2-3 
    371 TXT 
    372  
    373 $html =<<HTML; 
     214--- expected 
    374215<dl> 
    375216<dt>title1</dt> 
     
    385226</dd> 
    386227</dl> 
    387 HTML 
    388  
    389 $p->parse($text); 
    390 chomp($html); 
    391 is( $p->html, $html ); 
    392  
    393 ### autolink test ### 
    394  
    395 $text =<<TXT; 
     228 
     229### autolink test 
     230--- input 
    396231http://mizzy.org/ 
    397232[http://mizzy.org/ Title] 
    398 TXT 
    399  
    400 $html =<<HTML; 
     233--- expected 
    401234<p> 
    402235<a class="ext-link" href="http://mizzy.org/">http://mizzy.org/</a> 
    403236<a class="ext-link" href="http://mizzy.org/">Title</a> 
    404237</p> 
    405 HTML 
    406  
    407 $p->parse($text); 
    408 chomp($html); 
    409 is( $p->html, $html ); 
    410  
    411 ### auto image link test ### 
    412  
    413 $text =<<TXT; 
     238 
     239### auto image link test 
     240--- input 
    414241http://mizzy.org/test.png 
    415242[http://mizzy.org/test.png Image] 
    416 TXT 
    417  
    418 $html =<<HTML; 
     243--- expected 
    419244<p> 
    420245<img src="http://mizzy.org/test.png" alt="http://mizzy.org/test.png" /> 
    421246<img src="http://mizzy.org/test.png" alt="Image" /> 
    422247</p> 
    423 HTML 
    424  
    425 $p->parse($text); 
    426 chomp($html); 
    427 is( $p->html, $html ); 
    428  
    429 ### test for fix of ticket #21431 on rt.cpan.org 
    430  
    431 $text =<<TXT; 
    432   * list 1-1 
    433   * list 1-2 
    434     * list 2-1 
    435     * list 2-2 
    436 TXT 
    437  
    438 $html =<<HTML; 
    439 <ul><li>list 1-1</li> 
    440 <li>list 1-2</li> 
    441 <ul><li>list 2-1</li> 
    442 <li>list 2-2</li></ul></ul> 
    443 HTML 
    444  
    445 $p->parse($text); 
    446 chomp($html); 
    447 is( $p->html, $html ); 
     248 
     249### ul node with single space 
     250--- input 
     251 * indent with 
     252 * single space 
     253   * sublist with 
     254   * two spaces 
     255--- expected 
     256<ul><li>indent with</li> 
     257<li>single space</li> 
     258<ul><li>sublist with</li> 
     259<li>two spaces</li></ul></ul> 
     260 
     261### ul node with double space 
     262--- input 
     263  * indent with 
     264  * two spaces 
     265    * sublist with 
     266    * two spaces 
     267--- expected 
     268<ul><li>indent with</li> 
     269<li>two spaces</li> 
     270<ul><li>sublist with</li> 
     271<li>two spaces</li></ul></ul> 
     272 
     273### ol node with single space 
     274--- input 
     275 1. indent with 
     276 1. single space 
     277   a. sublist with 
     278   a. two spaces 
     279--- expected 
     280<ol start="1"><li>indent with</li> 
     281<li>single space</li> 
     282<ol class="loweralpha"><li>sublist with</li> 
     283<li>two spaces</li></ol></ol> 
     284 
     285### ol node with double space 
     286--- input 
     287  1. indent with 
     288  1. two spaces 
     289    a. sublist with 
     290    a. two spaces 
     291--- expected 
     292<ol start="1"><li>indent with</li> 
     293<li>two spaces</li> 
     294<ol class="loweralpha"><li>sublist with</li> 
     295<li>two spaces</li></ol></ol> 
     296 
     297### dl node with single space 
     298--- input 
     299 title1:: 
     300   indent title 
     301   single space 
     302 title2:: 
     303   indent content 
     304   double space 
     305--- expected 
     306<dl> 
     307<dt>title1</dt> 
     308<dd> 
     309indent title 
     310single space 
     311</dd> 
     312<dt>title2</dt> 
     313<dd> 
     314indent content 
     315double space 
     316</dd> 
     317</dl> 
     318 
     319### dl node with double space 
     320--- input 
     321  title1:: 
     322    indent title 
     323    double space 
     324  title2:: 
     325    indent content 
     326    double space 
     327--- expected 
     328<dl> 
     329<dt>title1</dt> 
     330<dd> 
     331indent title 
     332double space 
     333</dd> 
     334<dt>title2</dt> 
     335<dd> 
     336indent content 
     337double space 
     338</dd> 
     339</dl>