# Testing HTML paragraphs
use strict;
use warnings;
use Test::More tests => 15;
#use Pod::Simple::Debug (10);
use Pod::Simple::HTML;
sub x {
my $code = $_[1];
Pod::Simple::HTML->_out(
sub{ $_[0]->bare_output(1); $code->($_[0]) if $code },
"=pod\n\n$_[0]",
) }
is( x(
q{
=pod
This is a paragraph
=cut
}),
qq{\n
This is a paragraph
\n},
"paragraph building"
);
is( x(qq{=pod\n\nThis is a paragraph}),
qq{\nThis is a paragraph
\n},
"paragraph building"
);
is( x(qq{This is a paragraph}),
qq{\nThis is a paragraph
\n},
"paragraph building"
);
like(x(
'=head1 This is a heading')
=> qr{\s*\s*$},
"heading building"
);
like(x('=head1 This is a heading', sub { $_[0]->html_h_level(2) })
=> qr{\s*\s*$},
"heading building"
);
like(x(
'=head2 This is a heading too')
=> qr{\s*\s*$},
"heading building"
);
like(x(
'=head3 Also, this is a heading')
=> qr{\s*\s*$},
"heading building"
);
like(x(
'=head4 This, too, is a heading')
=> qr{\s*\s*$},
"heading building"
);
like(x(
'=head5 The number of the heading shall be five')
=> qr{\s*\s*$},
"heading building"
);
like(x(
'=head6 The sixth a heading is the perfect heading')
=> qr{\s*\s*$},
"heading building"
);
like(x(
'=head2 Yada Yada Operator
X<...> X<... operator> X')
=> qr{name="Yada_Yada_Operator"},
"heading anchor name"
);
is(
x("=over 4\n\n=item one\n\n=item two\n\nHello\n\n=back\n"),
q{
- one
-
- two
-
Hello
}
);
my $html = q{
#include <stdio.h>
int main(int argc,char *argv[]) {
printf("Hellow World\n");
return 0;
}
};
is(
x("=begin html\n\n$html\n\n=end html\n"),
"$html\n\n"
);
# Check subclass.
SUBCLASS: {
package My::Pod::HTML;
use vars '@ISA', '$VERSION';
@ISA = ('Pod::Simple::HTML');
$VERSION = '0.01';
sub do_section { 'howdy' }
}
is(
My::Pod::HTML->_out(
sub{ $_[0]->bare_output(1) },
"=pod\n\n=over\n\n=item Foo\n\n=back\n",
),
"\n\n- Foo
\n
\n",
);
{ # Test that strip_verbatim_indent() works. github issue #i5
my $output;
my $obj = Pod::Simple::HTML->new;
$obj->strip_verbatim_indent(" ");
$obj->output_string(\$output);
$obj->parse_string_document("=pod\n\n First line\n 2nd line\n");
like($output, qr!First line\n2nd line
!s);
}