1# Testing HTML paragraphs 2 3BEGIN { 4 if($ENV{PERL_CORE}) { 5 chdir 't'; 6 @INC = '../lib'; 7 } 8} 9 10use strict; 11use warnings; 12use Test; 13BEGIN { plan tests => 16 }; 14 15#use Pod::Simple::Debug (10); 16 17use Pod::Simple::HTML; 18 19sub x { 20 my $code = $_[1]; 21 Pod::Simple::HTML->_out( 22 sub{ $_[0]->bare_output(1); $code->($_[0]) if $code }, 23 "=pod\n\n$_[0]", 24) } 25 26ok( x( 27q{ 28=pod 29 30This is a paragraph 31 32=cut 33}), 34 qq{\n<p>This is a paragraph</p>\n}, 35 "paragraph building" 36); 37 38 39ok( x(qq{=pod\n\nThis is a paragraph}), 40 qq{\n<p>This is a paragraph</p>\n}, 41 "paragraph building" 42); 43 44 45ok( x(qq{This is a paragraph}), 46 qq{\n<p>This is a paragraph</p>\n}, 47 "paragraph building" 48); 49 50 51 52ok(x( 53'=head1 This is a heading') 54 => q{/\s*<h1><a[^<>]+>This\s+is\s+a\s+heading</a></h1>\s*$/}, 55 "heading building" 56); 57 58ok(x('=head1 This is a heading', sub { $_[0]->html_h_level(2) }) 59 => q{/\s*<h2><a[^<>]+>This\s+is\s+a\s+heading</a></h2>\s*$/}, 60 "heading building" 61); 62 63ok(x( 64'=head2 This is a heading too') 65 => q{/\s*<h2><a[^<>]+>This\s+is\s+a\s+heading\s+too</a></h2>\s*$/}, 66 "heading building" 67); 68 69ok(x( 70'=head3 Also, this is a heading') 71 => q{/\s*<h3><a[^<>]+>Also,\s+this\s+is\s+a\s+heading</a></h3>\s*$/}, 72 "heading building" 73); 74 75 76ok(x( 77'=head4 This, too, is a heading') 78 => q{/\s*<h4><a[^<>]+>This,\s+too,\s+is\s+a\s+heading</a></h4>\s*$/}, 79 "heading building" 80); 81 82ok(x( 83'=head5 The number of the heading shall be five') 84 => q{/\s*<h5><a[^<>]+>The\s+number\s+of\s+the\s+heading\s+shall\s+be\s+five</a></h5>\s*$/}, 85 "heading building" 86); 87 88ok(x( 89'=head6 The sixth a heading is the perfect heading') 90 => q{/\s*<h6><a[^<>]+>The\s+sixth\s+a\s+heading\s+is\s+the\s+perfect\s+heading</a></h6>\s*$/}, 91 "heading building" 92); 93 94ok(x( 95'=head2 Yada Yada Operator 96X<...> X<... operator> X<yada yada operator>') 97 => q{/name="Yada_Yada_Operator"/}, 98 "heading anchor name" 99); 100 101ok( 102 x("=over 4\n\n=item one\n\n=item two\n\nHello\n\n=back\n"), 103 q{ 104<dl> 105<dt><a name="one" 106>one</a></dt> 107 108<dd> 109<dt><a name="two" 110>two</a></dt> 111 112<dd> 113<p>Hello</p> 114</dd> 115</dl> 116} 117); 118 119my $html = q{<tt> 120<pre> 121#include <stdio.h> 122 123int main(int argc,char *argv[]) { 124 125 printf("Hellow World\n"); 126 return 0; 127 128} 129</pre> 130</tt>}; 131ok( 132 x("=begin html\n\n$html\n\n=end html\n"), 133 "$html\n\n" 134); 135 136# Check subclass. 137SUBCLASS: { 138 package My::Pod::HTML; 139 use vars '@ISA', '$VERSION'; 140 @ISA = ('Pod::Simple::HTML'); 141 $VERSION = '0.01'; 142 sub do_section { 'howdy' } 143} 144 145ok( 146 My::Pod::HTML->_out( 147 sub{ $_[0]->bare_output(1) }, 148 "=pod\n\n=over\n\n=item Foo\n\n=back\n", 149 ), 150 "\n<dl>\n<dt><a name=\"howdy\"\n>Foo</a></dt>\n</dl>\n", 151); 152 153{ # Test that strip_verbatim_indent() works. github issue #i5 154 my $output; 155 156 my $obj = Pod::Simple::HTML->new; 157 $obj->strip_verbatim_indent(" "); 158 $obj->output_string(\$output); 159 $obj->parse_string_document("=pod\n\n First line\n 2nd line\n"); 160 ok($output, qr!<pre>First line\n2nd line</pre>!s); 161} 162 163print "# And one for the road...\n"; 164ok 1; 165 166