File: xhtml20.t

package info (click to toggle)
perl 5.20.2-3%2Bdeb8u11
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 102,964 kB
  • sloc: perl: 555,553; ansic: 214,041; sh: 38,121; pascal: 8,783; cpp: 3,895; makefile: 2,393; xml: 2,325; yacc: 1,741
file content (63 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl -w

# t/xhtml20.t - test subclassing of Pod::Simple::XHTML

use strict;
use warnings;
use Test::More tests => 1;

BEGIN {
    package MyXHTML;
    use base 'Pod::Simple::XHTML';

    sub handle_code {
	my($self, $code, $kind) = @_;
	$code = $kind . "[$code]";
	$self->SUPER::handle_code($code);
    }

    sub start_code {
	my($self, $kind) = @_;
	$self->{scratch} .= "<code class=\"$kind\">";
    }

    sub end_code {
	my($self, $kind) = @_;
	$self->{scratch} .= "</code><!-- $kind -->";
    }
}



my ($parser, $results);

initialize();
$parser->parse_string_document(<<'EOT');
=head1 Foo

This is C<$code> and so is:

  my $foo = 1;

Code might even be C<<< nested( B<< C<1> >> ) >>>.
EOT

is($results, <<'EOT');
<h1 id="Foo">Foo</h1>

<p>This is <code class="C">C[$code]</code><!-- C --> and so is:</p>

<pre><code class="Verbatim">Verbatim[  my $foo = 1;]</code><!-- Verbatim --></pre>

<p>Code might even be <code class="C">C[nested( ]<b><code class="C">C[1]</code><!-- C --></b>C[ )]</code><!-- C -->.</p>

EOT


sub initialize {
    $parser = MyXHTML->new;
    $parser->html_header('');
    $parser->html_footer('');
    $parser->output_string( \$results );
    $results = '';
}