Changeset 323
- Timestamp:
- 10/27/06 15:53:08 (2 years ago)
- Files:
-
- library/perl/trunk/Text-Trac/Changes (modified) (1 diff)
- library/perl/trunk/Text-Trac/Makefile.PL (modified) (1 diff)
- library/perl/trunk/Text-Trac/lib/Text/Trac/BlockquoteNode.pm (modified) (2 diffs)
- library/perl/trunk/Text-Trac/lib/Text/Trac/Context.pm (modified) (1 diff)
- library/perl/trunk/Text-Trac/lib/Text/Trac/OlNode.pm (modified) (4 diffs)
- library/perl/trunk/Text-Trac/lib/Text/Trac/UlNode.pm (modified) (2 diffs)
- library/perl/trunk/Text-Trac/t/01-text-trac.t (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
library/perl/trunk/Text-Trac/Changes
r321 r323 2 2 3 3 0.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. 5 6 http://rt.cpan.org/Ticket/Display.html?id=21431 6 7 Thanks to Andrew Sterling Hanenkamp and Graham TerMarsch. library/perl/trunk/Text-Trac/Makefile.PL
r177 r323 10 10 PL_FILES => {}, 11 11 PREREQ_PM => { 12 'Test:: More' => 0,12 'Test::Base' => 0, 13 13 'UNIVERSAL::require' => 0, 14 14 'Class::Accessor::Fast' => 0, library/perl/trunk/Text-Trac/lib/Text/Trac/BlockquoteNode.pm
r321 r323 6 6 sub init { 7 7 my $self = shift; 8 $self->pattern(qr/^\s \s([^\s*].+)$/);8 $self->pattern(qr/^\s+([^\s\*\daiAI].+)$/); 9 9 $self->block_nodes([ qw( heading p ul ol ) ]); 10 10 } … … 14 14 my $c = $self->{context}; 15 15 my $pattern = $self->pattern; 16 #$l =~ $pattern or return $l;16 return if $l =~ /::$/; 17 17 18 18 $c->htmllines('<blockquote>'); library/perl/trunk/Text-Trac/lib/Text/Trac/Context.pm
r176 r323 3 3 use base qw (Class::Accessor::Fast); 4 4 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 ) ); 6 6 7 7 my %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 => [], 15 15 ); 16 16 library/perl/trunk/Text-Trac/lib/Text/Trac/OlNode.pm
r176 r323 15 15 my $pattern = $self->pattern; 16 16 $l =~ $pattern or return $l; 17 my $ol_level = ( length($1) + 1 ) / 2;18 17 my $type = $2; 18 19 my $space = length($1); 20 my $level = $c->ol->{level}; 21 $c->ol->{space} ||= 0; 19 22 20 23 my $start_tag; … … 35 38 } 36 39 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++; 41 43 } 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--; 46 47 } 47 48 48 $c-> current_ol_level($ol_level);49 $c->ol({level => $level, space => $space }); 49 50 50 51 $l =~ s{ $pattern }{<li>$3</li>}xmsg; … … 54 55 } 55 56 else { 56 for ( 1 .. $c-> current_ol_level($ol_level)){57 for ( 1 .. $c->ol->{level} ){ 57 58 $l .= '</ol>'; 58 59 } 59 $c-> current_ol_level(0);60 $c->ol->{level} = 0; 60 61 } 61 62 … … 67 68 68 69 $c->htmllines($l); 70 71 return; 69 72 } 70 73 library/perl/trunk/Text-Trac/lib/Text/Trac/UlNode.pm
r321 r323 14 14 my $pattern = $self->pattern; 15 15 $l =~ $pattern or return $l; 16 my $ul_level = ( length($1) + 1 ) / 2;17 16 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++; 22 24 } 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--; 27 28 } 28 29 29 $c-> current_ul_level($ul_level);30 $c->ul({level => $level, space => $space }); 30 31 31 32 $l =~ s{ $pattern }{<li>$2</li>}xmsg; … … 35 36 } 36 37 else { 37 for ( 1 .. $c-> current_ul_level($ul_level)){38 for ( 1 .. $c->ul->{level} ){ 38 39 $l .= '</ul>'; 39 40 } 40 $c-> current_ul_level(0);41 $c->ul->{level} = 0; 41 42 } 42 43 library/perl/trunk/Text-Trac/t/01-text-trac.t
r321 r323 2 2 3 3 use strict; 4 use Test::More tests => 28; 5 BEGIN { use_ok('Text::Trac') }; 4 use Test::Base; 5 use Text::Trac; 6 7 delimiters('###'); 8 9 plan tests => 1 * blocks; 6 10 7 11 my $p = Text::Trac->new(); 8 12 9 isa_ok($p, 'Text::Trac'); 10 11 my ($text, $html, $generated_html); 12 13 ### h1 test ### 14 $text =<<txt; 13 sub parse { 14 local $_ = shift; 15 $p->parse($_); 16 $p->html; 17 } 18 19 filters { input => 'parse', expected => 'chomp' }; 20 run_is 'input' => 'expected'; 21 22 __DATA__ 23 ### h1 test 24 --- input 15 25 = heading 1 = 16 txt 17 18 $html =<<html; 26 --- expected 19 27 <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 28 31 == heading 2 == 29 txt 30 31 $html =<<html; 32 --- expected 32 33 <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 41 37 === heading 3 === 42 txt 43 44 $html =<<html; 38 --- expected 45 39 <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 54 43 ==== heading 4 ==== 55 txt 56 57 $html =<<html; 44 --- expected 58 45 <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 67 49 ===== heading 5 ===== 68 txt 69 70 $html =<<html; 50 --- expected 71 51 <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 80 55 '''bold''' '''bold''' 81 txt 82 83 $html =<<html; 56 --- expected 84 57 <p> 85 58 <strong>bold</strong> <strong>bold</strong> 86 59 </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 95 63 ''italic'' ''italic'' 96 txt 97 98 $html =<<html; 64 --- expected 99 65 <p> 100 66 <i>italic</i> <i>italic</i> 101 67 </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 110 71 '''''bolditalic''''' '''''bolditalic''''' 111 txt 112 113 $html =<<html; 72 --- expected 114 73 <p> 115 74 <strong><i>bolditalic</i></strong> <strong><i>bolditalic</i></strong> 116 75 </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 125 79 __underline__ __underline__ 126 txt 127 128 $html =<<html; 80 --- expected 129 81 <p> 130 82 <span class="underline">underline</span> <span class="underline">underline</span> 131 83 </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 140 87 `monospace` {{{monospace}}} 141 txt 142 143 $html =<<html; 88 --- expected 144 89 <p> 145 90 <tt>monospace</tt> <tt>monospace</tt> 146 91 </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 155 95 ~~strike~~ ~~strike~~ 156 txt 157 158 $html =<<html; 96 --- expected 159 97 <p> 160 98 <del>strike</del> <del>strike</del> 161 99 </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 170 103 ^sup^ ^sup^ 171 txt 172 173 $html =<<html; 104 --- expected 174 105 <p> 175 106 <sup>sup</sup> <sup>sup</sup> 176 107 </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 185 111 ,,sub,, ,,sub,, 186 txt 187 188 $html =<<html; 112 --- expected 189 113 <p> 190 114 <sub>sub</sub> <sub>sub</sub> 191 115 </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 200 119 line1[[BR]]line2 201 TXT 202 203 $html =<<HTML; 120 --- expected 204 121 <p> 205 122 line1<br />line2 206 123 </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 216 127 test 217 128 test 218 TXT 219 220 $html =<<HTML; 129 --- expected 221 130 <p> 222 131 test 223 132 test 224 133 </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 233 137 * list 1-1 234 138 * list 1-2 235 139 * list 2-1 236 140 * list 2-2 237 TXT 238 239 $html =<<HTML; 141 --- expected 240 142 <ul><li>list 1-1</li> 241 143 <li>list 1-2</li> 242 144 <ul><li>list 2-1</li> 243 145 <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 271 149 1. list 1-1 272 150 1. list 1-2 273 151 a. list a-1 274 152 a. list a-2 275 TXT 276 277 $html =<<HTML; 153 --- expected 278 154 <ol start="1"><li>list 1-1</li> 279 155 <li>list 1-2</li> 280 156 <ol class="loweralpha"><li>list a-1</li> 281 157 <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 290 161 This text is a quote from someone else. 291 TXT 292 293 $html =<<HTML; 162 --- expected 294 163 <blockquote> 295 164 <p> … … 297 166 </p> 298 167 </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 307 171 {{{ 308 172 This is pre-formatted text. 309 173 This also pre-formatted text. 310 174 }}} 311 TXT 312 313 $html =<<HTML; 175 --- expected 314 176 <pre class="wiki"> 315 177 This is pre-formatted text. 316 178 This also pre-formatted text. 317 179 </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 326 183 ||Cell 1||Cell 2||Cell 3|| 327 184 ||Cell 4||Cell 5||Cell 6|| 328 TXT 329 330 $html =<<HTML; 185 --- expected 331 186 <table> 332 187 <tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr> 333 188 <tr><td>Cell 4</td><td>Cell 5</td><td>Cell 6</td></tr> 334 189 </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 343 193 line1 344 194 ==== 345 195 line2 346 TXT 347 348 $html =<<HTML; 196 --- expected 349 197 <p> 350 198 line1 … … 354 202 line2 355 203 </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 364 207 title1:: 365 208 content 1-1 … … 369 212 content 2-2 370 213 content 2-3 371 TXT 372 373 $html =<<HTML; 214 --- expected 374 215 <dl> 375 216 <dt>title1</dt> … … 385 226 </dd> 386 227 </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 396 231 http://mizzy.org/ 397 232 [http://mizzy.org/ Title] 398 TXT 399 400 $html =<<HTML; 233 --- expected 401 234 <p> 402 235 <a class="ext-link" href="http://mizzy.org/">http://mizzy.org/</a> 403 236 <a class="ext-link" href="http://mizzy.org/">Title</a> 404 237 </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 414 241 http://mizzy.org/test.png 415 242 [http://mizzy.org/test.png Image] 416 TXT 417 418 $html =<<HTML; 243 --- expected 419 244 <p> 420 245 <img src="http://mizzy.org/test.png" alt="http://mizzy.org/test.png" /> 421 246 <img src="http://mizzy.org/test.png" alt="Image" /> 422 247 </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> 309 indent title 310 single space 311 </dd> 312 <dt>title2</dt> 313 <dd> 314 indent content 315 double 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> 331 indent title 332 double space 333 </dd> 334 <dt>title2</dt> 335 <dd> 336 indent content 337 double space 338 </dd> 339 </dl>
