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
\ntwo
], 'lines did' ); $t2h = HTML::FromText->new({lines => 1,spaces => 1}); $html = $t2h->parse( "one\n two" ); cmp_ok( $html, 'eq', qq[
one
\n two
], 'lines and spaces did' ); $t2h = HTML::FromText->new({paras => 1}); $html = $t2h->parse( <<__TEXT__ ); One __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'one paragraph' );

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' ); __HTML__ $t2h = HTML::FromText->new({paras => 1, bullets => 1}); $html = $t2h->parse( <<__TEXT__ ); - One - Half - Two __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'nested bullet list' ); __HTML__ $t2h = HTML::FromText->new({paras => 1, bullets => 1, bold => 1}); $html = $t2h->parse( <<__TEXT__ ); * One * Half * Whole * Shabang Dude * Two *Normal* Text __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'nested bullets and normal paragraph' );

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' );
  1. One
    1. Half
    2. Whole
      1. Shabang Dude
  2. Two

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' );

1. One

Normal Text

1.1. Sub section

2. Second Top

__HTML__ $t2h = HTML::FromText->new({paras => 1, title => 1}); $html = $t2h->parse( <<__TEXT__ ); Title Normal Text __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'title' );

Title

Normal Text

__HTML__ $t2h = HTML::FromText->new({paras => 1, blockparas => 1}); $html = $t2h->parse( <<__TEXT__ ); Test __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'blockparas' );

Test

__HTML__ $t2h = HTML::FromText->new({paras => 1, blockquotes => 1}); $html = $t2h->parse( <<__TEXT__ ); Test This __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'blockquotes' );
Test
This
__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 Please
__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' );
Casey WestDaddy
Chastity WestMommy
Evelina WestBaby
__HTML__ $t2h = HTML::FromText->new({paras => 1, tables => 1}); $html = $t2h->parse( <<__TEXT__ ); Chastity West Mommy Casey West Daddy __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'indented tables' );
Chastity WestMommy
Casey WestDaddy
__HTML__ $t2h = HTML::FromText->new({paras => 1, tables => 1}); $html = $t2h->parse( <<__TEXT__ ); Chastity West Mommy Casey West Daddy __TEXT__ cmp_ok( $html, 'eq', <<__HTML__, 'should not be table' );

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 WestDaddyTall
Chastity WestMommyShort

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.orgPerl Mongers
http://perl.comO'Reilly Perl Center
http://lists.perl.orgList of Mailing Lists
http://use.perl.orgPerl News and Community Journals
http://perl.apache.orgmod_perl
http://theperlreview.comThe Perl Review
__HTML__