1*b39c5158Smillert# Testing HTML paragraphs 2*b39c5158Smillert 3*b39c5158SmillertBEGIN { 4*b39c5158Smillert if($ENV{PERL_CORE}) { 5*b39c5158Smillert chdir 't'; 6*b39c5158Smillert @INC = '../lib'; 7*b39c5158Smillert } 8*b39c5158Smillert} 9*b39c5158Smillert 10*b39c5158Smillertuse strict; 11*b39c5158Smillertuse Test; 12*b39c5158SmillertBEGIN { plan tests => 11 }; 13*b39c5158Smillert 14*b39c5158Smillert#use Pod::Simple::Debug (10); 15*b39c5158Smillert 16*b39c5158Smillertuse Pod::Simple::HTML; 17*b39c5158Smillert 18*b39c5158Smillertsub x ($;&) { 19*b39c5158Smillert my $code = $_[1]; 20*b39c5158Smillert Pod::Simple::HTML->_out( 21*b39c5158Smillert sub{ $_[0]->bare_output(1); $code->($_[0]) if $code }, 22*b39c5158Smillert "=pod\n\n$_[0]", 23*b39c5158Smillert) } 24*b39c5158Smillert 25*b39c5158Smillertok( x( 26*b39c5158Smillertq{ 27*b39c5158Smillert=pod 28*b39c5158Smillert 29*b39c5158SmillertThis is a paragraph 30*b39c5158Smillert 31*b39c5158Smillert=cut 32*b39c5158Smillert}), 33*b39c5158Smillert qq{\n<p>This is a paragraph</p>\n}, 34*b39c5158Smillert "paragraph building" 35*b39c5158Smillert); 36*b39c5158Smillert 37*b39c5158Smillert 38*b39c5158Smillertok( x(qq{=pod\n\nThis is a paragraph}), 39*b39c5158Smillert qq{\n<p>This is a paragraph</p>\n}, 40*b39c5158Smillert "paragraph building" 41*b39c5158Smillert); 42*b39c5158Smillert 43*b39c5158Smillert 44*b39c5158Smillertok( x(qq{This is a paragraph}), 45*b39c5158Smillert qq{\n<p>This is a paragraph</p>\n}, 46*b39c5158Smillert "paragraph building" 47*b39c5158Smillert); 48*b39c5158Smillert 49*b39c5158Smillert 50*b39c5158Smillert 51*b39c5158Smillertok(x( 52*b39c5158Smillert'=head1 This is a heading') 53*b39c5158Smillert => q{/\s*<h1><a[^<>]+>This\s+is\s+a\s+heading</a></h1>\s*$/}, 54*b39c5158Smillert "heading building" 55*b39c5158Smillert); 56*b39c5158Smillert 57*b39c5158Smillertok(x('=head1 This is a heading', sub { $_[0]->html_h_level(2) }) 58*b39c5158Smillert => q{/\s*<h2><a[^<>]+>This\s+is\s+a\s+heading</a></h2>\s*$/}, 59*b39c5158Smillert "heading building" 60*b39c5158Smillert); 61*b39c5158Smillert 62*b39c5158Smillertok(x( 63*b39c5158Smillert'=head2 This is a heading too') 64*b39c5158Smillert => q{/\s*<h2><a[^<>]+>This\s+is\s+a\s+heading\s+too</a></h2>\s*$/}, 65*b39c5158Smillert "heading building" 66*b39c5158Smillert); 67*b39c5158Smillert 68*b39c5158Smillertok(x( 69*b39c5158Smillert'=head3 Also, this is a heading') 70*b39c5158Smillert => q{/\s*<h3><a[^<>]+>Also,\s+this\s+is\s+a\s+heading</a></h3>\s*$/}, 71*b39c5158Smillert "heading building" 72*b39c5158Smillert); 73*b39c5158Smillert 74*b39c5158Smillert 75*b39c5158Smillertok(x( 76*b39c5158Smillert'=head4 This, too, is a heading') 77*b39c5158Smillert => q{/\s*<h4><a[^<>]+>This,\s+too,\s+is\s+a\s+heading</a></h4>\s*$/}, 78*b39c5158Smillert "heading building" 79*b39c5158Smillert); 80*b39c5158Smillert 81*b39c5158Smillertok( 82*b39c5158Smillert x("=over 4\n\n=item one\n\n=item two\n\nHello\n\n=back\n"), 83*b39c5158Smillert q{ 84*b39c5158Smillert<dl> 85*b39c5158Smillert<dt><a name="one" 86*b39c5158Smillert>one</a></dt> 87*b39c5158Smillert 88*b39c5158Smillert<dd> 89*b39c5158Smillert<dt><a name="two" 90*b39c5158Smillert>two</a></dt> 91*b39c5158Smillert 92*b39c5158Smillert<dd> 93*b39c5158Smillert<p>Hello</p> 94*b39c5158Smillert</dd> 95*b39c5158Smillert</dl> 96*b39c5158Smillert} 97*b39c5158Smillert); 98*b39c5158Smillert 99*b39c5158Smillert# Check subclass. 100*b39c5158SmillertSUBCLASS: { 101*b39c5158Smillert package My::Pod::HTML; 102*b39c5158Smillert use vars '@ISA', '$VERSION'; 103*b39c5158Smillert @ISA = ('Pod::Simple::HTML'); 104*b39c5158Smillert $VERSION = '0.01'; 105*b39c5158Smillert sub do_section { 'howdy' } 106*b39c5158Smillert} 107*b39c5158Smillert 108*b39c5158Smillertok( 109*b39c5158Smillert My::Pod::HTML->_out( 110*b39c5158Smillert sub{ $_[0]->bare_output(1) }, 111*b39c5158Smillert "=pod\n\n=over\n\n=item Foo\n\n", 112*b39c5158Smillert ), 113*b39c5158Smillert "\n<dl>\n<dt><a name=\"howdy\"\n>Foo</a></dt>\n</dl>\n", 114*b39c5158Smillert); 115*b39c5158Smillert 116*b39c5158Smillertprint "# And one for the road...\n"; 117*b39c5158Smillertok 1; 118*b39c5158Smillert 119