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 => 13 }; 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(x( 82'=head2 Yada Yada Operator 83X<...> X<... operator> X<yada yada operator>') 84 => q{/name="Yada_Yada_Operator"/}, 85 "heading anchor name" 86); 87 88ok( 89 x("=over 4\n\n=item one\n\n=item two\n\nHello\n\n=back\n"), 90 q{ 91<dl> 92<dt><a name="one" 93>one</a></dt> 94 95<dd> 96<dt><a name="two" 97>two</a></dt> 98 99<dd> 100<p>Hello</p> 101</dd> 102</dl> 103} 104); 105 106my $html = q{<tt> 107<pre> 108#include <stdio.h> 109 110int main(int argc,char *argv[]) { 111 112 printf("Hellow World\n"); 113 return 0; 114 115} 116</pre> 117</tt>}; 118ok( 119 x("=begin html\n\n$html\n\n=end html\n"), 120 "$html\n\n" 121); 122 123# Check subclass. 124SUBCLASS: { 125 package My::Pod::HTML; 126 use vars '@ISA', '$VERSION'; 127 @ISA = ('Pod::Simple::HTML'); 128 $VERSION = '0.01'; 129 sub do_section { 'howdy' } 130} 131 132ok( 133 My::Pod::HTML->_out( 134 sub{ $_[0]->bare_output(1) }, 135 "=pod\n\n=over\n\n=item Foo\n\n=back\n", 136 ), 137 "\n<dl>\n<dt><a name=\"howdy\"\n>Foo</a></dt>\n</dl>\n", 138); 139 140print "# And one for the road...\n"; 141ok 1; 142 143