xref: /openbsd-src/gnu/usr.bin/perl/cpan/Pod-Simple/t/xhtml05.t (revision 5486feefcc8cb79b19e014ab332cc5dfd05b3b33)
1# t/xhtml05.t - check block output from Pod::Simple::XHTML
2use strict;
3use warnings;
4use Test::More tests => 6;
5
6use_ok('Pod::Simple::XHTML') or exit;
7
8my $parser = Pod::Simple::XHTML->new ();
9isa_ok ($parser, 'Pod::Simple::XHTML');
10
11my $results;
12initialize($parser, $results);
13$parser->accept_targets_as_text( 'comment' );
14$parser->parse_string_document(<<'EOPOD');
15=for comment
16This is an ordinary for block.
17
18EOPOD
19
20is($results, <<'EOHTML', "a for block");
21<div class="comment">
22
23<p>This is an ordinary for block.</p>
24
25</div>
26
27EOHTML
28
29foreach my $target (qw(note tip warning)) {
30  initialize($parser, $results);
31  $parser->accept_targets_as_text( $target );
32  $parser->parse_string_document(<<"EOPOD");
33=begin $target
34
35This is a $target.
36
37=end $target
38EOPOD
39
40  is($results, <<"EOHTML", "allow $target blocks");
41<div class="$target">
42
43<p>This is a $target.</p>
44
45</div>
46
47EOHTML
48
49}
50
51######################################
52
53sub initialize {
54    $_[0] = Pod::Simple::XHTML->new ();
55        $_[0]->html_header("");
56        $_[0]->html_footer("");
57    $_[0]->output_string( \$results ); # Send the resulting output to a string
58    $_[1] = '';
59    return;
60}
61