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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
#!/usr/bin/perl -w # -*- perl -*-
use strict;
use utf8;
use lib qw( ./lib ../lib );
use Encode;
use Pod::POM;
use Pod::POM::View::HTML;
use Pod::POM::Test;
ntests(2);
$Pod::POM::DEFAULT_VIEW = 'Pod::POM::View::HTML';
my $text;
{ local $/ = undef;
$text = <DATA>;
Encode::_utf8_on($text);
}
my ($test, $expect) = split(/\s*-------+\s*/, $text);
my $parser = Pod::POM->new();
my $pom = $parser->parse_text($test);
assert( $pom );
my $result = "$pom";
for ($result, $expect) {
s/^\s*//;
s/\s*$//;
}
#match($result, $expect);
use constant HAS_TEXT_DIFF => eval { require Text::Diff};
if (HAS_TEXT_DIFF) {
diff($expect, $result, 2);
} else {
match($result, $expect);
}
sub diff {
my($expect, $result, $tnum) = @_;
my $diff = Text::Diff::diff(\$expect, \$result, {STYLE=> "Unified"});
if ($diff) {
print "not ok $tnum\n";
print $diff;
}
else {
print "ok $tnum\n";
}
}
#print $pom;
__DATA__
=encoding utf8
=head1 NAME
Test
=head1 SYNOPSIS
use My::Module;
my $module = My::Module->new();
=head1 DESCRIPTION
This is the description.
Here is a verbatim section.
And we ♥ utf-8 here.
This is some more regular text.
Here is some B<bold> text, some I<italic> and something that looks
like an E<lt>htmlE<gt> tag. This is some C<$code($arg1)>.
This C<text contains embedded B<bold> and I<italic> tags>. These can
be nested, allowing B<bold and I<bold E<amp> italic> text>. The module also
supports the extended B<< syntax >> and permits I<< nested tags E<amp>
other B<<< cool >>> stuff >>
=head1 METHODS =E<gt> OTHER STUFF
Here is a list of methods
=head2 new()
Constructor method. Accepts the following config options:
=over 4
=item foo
The foo item.
=item bar
The bar item.
=over 4
This is a list within a list
=item *
The wiz item.
=item *
The waz item.
=back
=item baz
The baz item.
=back
Title on the same line as the =item + * bullets
=over
=item * C<Black> Cat
=item * Sat S<I<on> the>
=item * MatE<lt>!E<gt>
=back
Title on the same line as the =item + numerical bullets
=over
=item 1 Cat
=item 2 Sat
=item 3 Mat
=back
No bullets, no title
=over
=item
Cat
=item
Sat
=item
Mat
=back
=head2 old()
Destructor method
=head1 TESTING FOR AND BEGIN
=for html <br>
<p>
blah blah
</p>
intermediate text
=begin html
<more>
HTML
</more>
some text
=end
=head1 TESTING URLs hyperlinking
This is an href link1: http://example.com
This is an href link2: http://example.com/foo/bar.html
This is an email link: mailto:foo@bar.com
=head1 SEE ALSO
See also L<Test Page 2|pod2>, the L<Your::Module> and L<Their::Module>
manpages and the other interesting file F</usr/local/my/module/rocks>
as well.
=cut
------------------------------------------------------------------------
<html>
<body bgcolor="#ffffff">
<h1>NAME</h1>
<p>Test</p>
<h1>SYNOPSIS</h1>
<pre> use My::Module;
my $module = My::Module->new();</pre>
<h1>DESCRIPTION</h1>
<p>This is the description.</p>
<pre> Here is a verbatim section.
And we ♥ utf-8 here.</pre>
<p>This is some more regular text.</p>
<p>Here is some <b>bold</b> text, some <i>italic</i> and something that looks
like an <html> tag. This is some <code>$code($arg1)</code>.</p>
<p>This <code>text contains embedded <b>bold</b> and <i>italic</i> tags</code>. These can
be nested, allowing <b>bold and <i>bold & italic</i> text</b>. The module also
supports the extended <b>syntax</b> and permits <i>nested tags &
other <b>cool</b> stuff</i></p>
<h1>METHODS => OTHER STUFF</h1>
<p>Here is a list of methods</p>
<h2>new()</h2>
<p>Constructor method. Accepts the following config options:</p>
<ul>
<li><a name="item_foo"></a><b>foo</b>
<p>The foo item.</p>
</li>
<li><a name="item_bar"></a><b>bar</b>
<p>The bar item.</p>
<ul>
<p>This is a list within a list</p>
<li>
<p>The wiz item.</p>
</li>
<li>
<p>The waz item.</p>
</li>
</ul>
</li>
<li><a name="item_baz"></a><b>baz</b>
<p>The baz item.</p>
</li>
</ul>
<p>Title on the same line as the =item + * bullets</p>
<ul>
<li><a name="item__code_Black__code__Cat"></a><b><code>Black</code> Cat</b>
</li>
<li><a name="item_Sat__i_on__i__nbsp_the"></a><b>Sat <i>on</i> the</b>
</li>
<li><a name="item_Mat_lt___gt_"></a><b>Mat<!></b>
</li>
</ul>
<p>Title on the same line as the =item + numerical bullets</p>
<ol>
<li><a name="item_Cat"></a><b>Cat</b>
</li>
<li><a name="item_Sat"></a><b>Sat</b>
</li>
<li><a name="item_Mat"></a><b>Mat</b>
</li>
</ol>
<p>No bullets, no title</p>
<ul>
<li>
<p>Cat</p>
</li>
<li>
<p>Sat</p>
</li>
<li>
<p>Mat</p>
</li>
</ul>
<h2>old()</h2>
<p>Destructor method</p>
<h1>TESTING FOR AND BEGIN</h1>
<br>
<p>
blah blah
</p>
<p>intermediate text</p>
<more>
HTML
</more>
some text
<h1>TESTING URLs hyperlinking</h1>
<p>This is an href link1: <a href="http://example.com">http://example.com</a></p>
<p>This is an href link2: <a href="http://example.com/foo/bar.html">http://example.com/foo/bar.html</a></p>
<p>This is an email link: <a href="mailto:foo@bar.com">mailto:foo@bar.com</a></p>
<h1>SEE ALSO</h1>
<p>See also <i>Test Page 2</i>, the <i>Your::Module</i> and <i>Their::Module</i>
manpages and the other interesting file <i>/usr/local/my/module/rocks</i>
as well.</p>
</body>
</html>
|