3 #use Test::More tests => 2;
4 use Test::More 'no_plan';
7 use_ok( 'Blog::Parse::BBCode' );
10 my $bbc = Blog::Parse::BBCode->new();
12 is( $bbc->render('1 > 1'), '<p>1 > 1</p>', 'Escaping' );
14 is( $bbc->render('1 & 1'), '<p>1 & 1</p>', 'Escaping' );
16 is( $bbc->render( '[i]italic[/i]' ), '<p><i>italic</i></p>', 'Italic' );
18 is( $bbc->render( '[b]bold[/b]' ), '<p><b>bold</b></p>', 'Bold' );
20 is( $bbc->render( '[u]underlined[/u]' ),
21 '<p><span style="text-decoration:underline">underlined</span></p>',
24 is( $bbc->render( '[s]strike[/s]' ), '<p><s>strike</s></p>', 'Strike' );
26 is( $bbc->render( '[i][u][s][b]mixing up[/b][/s][/u][/i]' ),
27 '<p><i><span style="text-decoration:underline"><s><b>mixing up</b></s></span></i></p>'
30 is( $bbc->render( '[hr]' ), '<p><hr /></p>', 'Hr' );
32 is( $bbc->render( '[url]http://foo.com[/url]' ),
33 '<p><a href="http://foo.com" rel="nofollow">http://foo.com</a></p>', 'Url' );
35 is( $bbc->render( '[url=http://foo.com]Foo[/url]' ),
36 '<p><a href="http://foo.com" rel="nofollow">Foo</a></p>', 'Url' );
38 is( $bbc->render( '[img]http://foo.com/bar.jpg[/img]' ),
39 '<p><img src="http://foo.com/bar.jpg" alt="[http://foo.com/bar.jpg]" title="http://foo.com/bar.jpg" /></p>', 'Image' );
41 is( $bbc->render( '[url=http://foo.com][img]http://foo.com/bar.jpg[/img][/url]'),
42 '<p><a href="http://foo.com" rel="nofollow"><img src="http://foo.com/bar.jpg" alt="[http://foo.com/bar.jpg]" title="http://foo.com/bar.jpg" /></a></p>',
45 is( $bbc->render( '[code=html][b]bold[/b][/code]' ),
46 '<p><pre><code class="html">[b]bold[/b]</code></pre></p>', 'Code' );
48 is( $bbc->render( '[list][*]one[*]two[/list]' ),
49 '<p><ul><li>one</li><li>two</li></ul></p>', 'List' );
51 #is( $bbc->render( '[left]foo[/left]' ),
52 # '<p><div style="text-align:left">foo</div></p>', 'Left aligned text' );
54 #is( $bbc->render( '[center]foo[/center]' ),
55 # '<p><div style="text-align:center">foo</div></p>', 'Center aligned text' );
57 #is( $bbc->render( '[right]foo[/right]' ),
58 # '<p><div style="text-align:right">foo</div></p>', 'Right aligned text' );
60 #is( $bbc->render( '[float=left][img]http://foo.com/bar.jpg[/img][/float]' ),
61 # '<p><div class="float-left"><img src="http://foo.com/bar.jpg" alt="" /></div></p>', 'Floating left image' );
63 is( $bbc->render( '[color=red]red[/color]' ), '<p><span style="color: red">red</span></p>', 'Color');
65 is( $bbc->render("text\n\nwith\nbr"), '<p>text</p><p>with<br />br</p>' );
67 is( $bbc->render('http://example.com?q=abc&action=add'),
68 '<p><a href="http://example.com?q=abc&action=add" rel="nofollow">http://example.com?q=abc&action=add</a></p>' );
70 is( $bbc->render('ftp://ftp.example.com')
71 , '<p><a href="ftp://ftp.example.com" rel="nofollow">ftp://ftp.example.com</a></p>');
73 is( $bbc->render('[cut]'), '<p></p>');
77 is($bbc->render('[b=foo]'), '<p>[b=foo]</p>');
79 is($bbc->render('[url]abc'), '<p>[url]abc</p>');