1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!perl
use strict;
use warnings;
use Test::More tests => 6;
use_ok( 'Text::WikiFormat' ) or exit;
my $wikitext =<<END_HERE;
* start of list
* second line
* indented list
* now back to the first
END_HERE
my $htmltext = Text::WikiFormat::format( $wikitext );
like( $htmltext, qr|second line<ul>.*?<li>indented|s,
'nested lists should start correctly' );
like( $htmltext, qr|indented list.*?</li>.*?</ul>|s,
'... and end correctly' );
$wikitext =<<END_HERE;
* 1
* 2
* 2.1
* 2.1.1
* 3
* 4
* 4.1
* 4.1.1
* 4.1.2
* 5
END_HERE
$htmltext = Text::WikiFormat::format( $wikitext );
like( $htmltext,
qr|<ul>\s*
<li>1</li>\s*
<li>2<ul>\s*
<li>2\.1<ul>\s*
<li>2\.1\.1</li>\s*
</ul>\s*
</li>\s*
</ul>\s*
</li>\s*
<li>3</li>\s*
</ul>\s*
<ul>\s*
<li>4<ul>\s*
<li>4\.1<ul>\s*
<li>4\.1\.1</li>\s*
<li>4\.1\.2</li>\s*
</ul>\s*
</li>\s*
</ul>\s*
</li>\s*
<li>5</li>\s*
</ul>|sx,
'nesting should be correct for multiple levels' );
like( $htmltext, qr|<li>4<|s,
'spaces should work instead of tabs' );
like( $htmltext,
qr|<li>4<ul>\s*<li>4.1<ul>\s*<li>4.1.1</li>\s*<li>4.1.2</li>\s*</ul>
\s*</li>|sx,
'nesting should be correct for spaces too' );
|