Commit | Line | Data |
---|---|---|
0ace302a SH |
1 | #!/usr/bin/perl -w |
2 | ||
3 | # t/xhtml20.t - test subclassing of Pod::Simple::XHTML | |
4 | ||
5 | use strict; | |
6 | use warnings; | |
7 | use Test::More tests => 1; | |
8 | ||
9 | BEGIN { | |
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 | ||
32 | my ($parser, $results); | |
33 | ||
34 | initialize(); | |
35 | $parser->parse_string_document(<<'EOT'); | |
36 | =head1 Foo | |
37 | ||
38 | This is C<$code> and so is: | |
39 | ||
40 | my $foo = 1; | |
41 | ||
42 | Code might even be C<<< nested( B<< C<1> >> ) >>>. | |
43 | EOT | |
44 | ||
45 | is($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 | ||
54 | EOT | |
55 | ||
56 | ||
57 | sub initialize { | |
58 | $parser = MyXHTML->new; | |
59 | $parser->html_header(''); | |
60 | $parser->html_footer(''); | |
61 | $parser->output_string( \$results ); | |
62 | $results = ''; | |
63 | } |