This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: savepv() of getenv()
[perl5.git] / cpan / Pod-Simple / t / xhtml20.t
CommitLineData
0ace302a
SH
1#!/usr/bin/perl -w
2
3# t/xhtml20.t - test subclassing of Pod::Simple::XHTML
4
5use strict;
6use warnings;
7use Test::More tests => 1;
8
9BEGIN {
10 package MyXHTML;
11 use base 'Pod::Simple::XHTML';
12
13 sub handle_code {
14 my($self, $code, $kind) = @_;
9dd0d393 15 $code = $kind . "[$code]";
0ace302a
SH
16 $self->SUPER::handle_code($code);
17 }
18
19 sub start_code {
20 my($self, $kind) = @_;
21 $self->{scratch} .= "<code class=\"$kind\">";
22 }
23
24 sub end_code {
25 my($self, $kind) = @_;
26 $self->{scratch} .= "</code><!-- $kind -->";
27 }
28}
29
30
31
32my ($parser, $results);
33
34initialize();
35$parser->parse_string_document(<<'EOT');
36=head1 Foo
37
38This is C<$code> and so is:
39
40 my $foo = 1;
41
42Code might even be C<<< nested( B<< C<1> >> ) >>>.
43EOT
44
45is($results, <<'EOT');
46<h1 id="Foo">Foo</h1>
47
48<p>This is <code class="C">C[$code]</code><!-- C --> and so is:</p>
49
50<pre><code class="Verbatim">Verbatim[ my $foo = 1;]</code><!-- Verbatim --></pre>
51
52<p>Code might even be <code class="C">C[nested( ]<b><code class="C">C[1]</code><!-- C --></b>C[ )]</code><!-- C -->.</p>
53
54EOT
55
56
57sub initialize {
58 $parser = MyXHTML->new;
59 $parser->html_header('');
60 $parser->html_footer('');
61 $parser->output_string( \$results );
62 $results = '';
63}