BEGIN { use Test::More qw[no_plan]; use_ok 'HTML::FromText'; } use strict; use warnings; my $t2h = HTML::FromText->new; isa_ok( $t2h, 'HTML::FromText', 'default' ); my $html = $t2h->parse( '<>' ); cmp_ok( $html, 'eq', '<>', 'metachars encoded <> correctly' ); $t2h = HTML::FromText->new({underline => 1}); $html = $t2h->parse( '_underline_' ); cmp_ok( $html, 'eq', 'underline', 'underline did' ); $t2h = HTML::FromText->new({underline => 1}); $html = $t2h->parse( "_should\nnot_" ); cmp_ok( $html, 'eq', "_should\nnot_", 'underline should not across lines' ); $t2h = HTML::FromText->new({bold => 1}); $html = $t2h->parse( '*bold*' ); cmp_ok( $html, 'eq', 'bold', 'bold did' ); $t2h = HTML::FromText->new({urls => 1}); $html = $t2h->parse( 'http://example.com' ); cmp_ok( $html, 'eq', 'http://example.com', 'urls did' ); $t2h = HTML::FromText->new({urls => 1}); $html = $t2h->parse( 'http://example.com/?foo=bar&baz=quux' ); cmp_ok( $html, 'eq', 'http://example.com/?foo=bar&baz=quux', 'urls and metachars did' ); $t2h = HTML::FromText->new({email => 1}); $html = $t2h->parse( 'casey@geeknest.com' ); cmp_ok( $html, 'eq', 'casey@geeknest.com', 'email did' ); $t2h = HTML::FromText->new({pre => 1}); $html = $t2h->parse( 'pre' ); cmp_ok( $html, 'eq', '
pre', 'pre did' ); $t2h = HTML::FromText->new({lines => 1}); $html = $t2h->parse( "one\ntwo" ); cmp_ok( $html, 'eq', qq[
One
__HTML__ $t2h = HTML::FromText->new({paras => 1}); $html = $t2h->parse( <<__TEXT__ ); One Two __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'two paragraphs' );One
Two
__HTML__ $t2h = HTML::FromText->new({paras => 1, bullets => 1}); $html = $t2h->parse( <<__TEXT__ ); * One * Two __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'single bullet list' );Normal Text
__HTML__ $t2h = HTML::FromText->new({paras => 1, numbers => 1}); $html = $t2h->parse( <<__TEXT__ ); 1 One 1 Half 2 Whole 1 Shabang Dude 2 Two Normal Text __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'nested numbers and normal paragraph' );Normal Text
__HTML__ $t2h = HTML::FromText->new({paras => 1, headings => 1}); $html = $t2h->parse( <<__TEXT__ ); 1. One Normal Text 1.1. Sub section 2. Second Top __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'headings' );Normal Text
Normal Text
__HTML__ $t2h = HTML::FromText->new({paras => 1, blockparas => 1}); $html = $t2h->parse( <<__TEXT__ ); Test __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'blockparas' );__HTML__ $t2h = HTML::FromText->new({paras => 1, blockquotes => 1}); $html = $t2h->parse( <<__TEXT__ ); Test This __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'blockquotes' );Test
__HTML__ $t2h = HTML::FromText->new({paras => 1, blockcode => 1}); $html = $t2h->parse( <<__TEXT__ ); Test This Please __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'blockcode' );Test
This
__HTML__ $t2h = HTML::FromText->new({paras => 1, tables => 1}); $html = $t2h->parse( <<__TEXT__ ); Casey West Daddy Chastity West Mommy Evelina West Baby __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'tables' );Test This Please
| Casey West | Daddy |
| Chastity West | Mommy |
| Evelina West | Baby |
| Chastity West | Mommy |
| Casey West | Daddy |
Chastity West Mommy Casey West Daddy
__HTML__ $t2h = HTML::FromText->new({paras => 1, tables => 1}); $html = $t2h->parse( <<__TEXT__ ); Casey West Daddy Tall Chastity West Mommy Short Normal Text. __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'indented tables with normal para' );| Casey West | Daddy | Tall |
| Chastity West | Mommy | Short |
Normal Text.
__HTML__ $t2h = HTML::FromText->new({paras => 1, tables => 1}); $html = $t2h->parse( <<__TEXT__ ); http://www.pm.org Perl Mongers http://perl.com O'Reilly Perl Center http://lists.perl.org List of Mailing Lists http://use.perl.org Perl News and Community Journals http://perl.apache.org mod_perl http://theperlreview.com The Perl Review __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'indented tables with normal para' );| http://www.pm.org | Perl Mongers |
| http://perl.com | O'Reilly Perl Center |
| http://lists.perl.org | List of Mailing Lists |
| http://use.perl.org | Perl News and Community Journals |
| http://perl.apache.org | mod_perl |
| http://theperlreview.com | The Perl Review |