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