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