-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add select method compatible with Pod::Select
- Loading branch information
1 parent
01b24a5
commit b0458ac
Showing
4 changed files
with
286 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
use Pod::Simple::XHTML; | ||
|
||
sub convert { | ||
my ($pod, $select) = @_; | ||
|
||
my $out = ''; | ||
my $parser = Pod::Simple::XHTML->new; | ||
$parser->html_header(''); | ||
$parser->html_footer(''); | ||
$parser->output_string(\$out); | ||
$parser->select(@$select); | ||
|
||
$parser->parse_string_document($pod); | ||
return $out; | ||
} | ||
|
||
sub compare { | ||
my ($in, $want, $select, $name) = @_; | ||
for my $pod ($in, $want) { | ||
if ($pod =~ /\A([\t ]+)/) { | ||
my $prefix = $1; | ||
$pod =~ s{^$prefix}{}gm; | ||
} | ||
} | ||
my $got = convert($in, $select); | ||
local $Test::Builder::Level = $Test::Builder::Level + 1; | ||
is $got, $want, $name; | ||
} | ||
|
||
compare <<'END_POD', <<'END_HTML', [ 'DESCRIPTION/guff' ]; | ||
=head1 NAME | ||
NAME content | ||
=head2 welp | ||
welp content | ||
=head3 hork | ||
hork content | ||
=head1 DESCRIPTION | ||
DESCRIPTION content | ||
=head2 guff | ||
guff content | ||
=cut | ||
END_POD | ||
<h2 id="guff">guff</h2> | ||
|
||
<p>guff content</p> | ||
|
||
END_HTML | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use Pod::Simple::JustPod; | ||
|
||
sub convert { | ||
my ($pod, $select) = @_; | ||
|
||
my $out = ''; | ||
my $parser = Pod::Simple::JustPod->new; | ||
$parser->output_string(\$out); | ||
$parser->select(@$select); | ||
|
||
$parser->parse_string_document($pod); | ||
return $out; | ||
} | ||
|
||
sub compare { | ||
my ($in, $want, $select, $name) = @_; | ||
for my $pod ($in, $want) { | ||
if ($pod =~ /\A([\t ]+)/) { | ||
my $prefix = $1; | ||
$pod =~ s{^$prefix}{}gm; | ||
} | ||
} | ||
my $got = convert($in, $select); | ||
$got =~ s/\A=pod\n\n//; | ||
local $Test::Builder::Level = $Test::Builder::Level + 1; | ||
is $got, $want, $name; | ||
} | ||
|
||
compare <<'END_IN_POD', <<'END_OUT_POD', [ 'DESCRIPTION/guff' ]; | ||
=head1 NAME | ||
NAME content | ||
=head2 welp | ||
welp content | ||
=head3 hork | ||
hork content | ||
=head1 DESCRIPTION | ||
DESCRIPTION content | ||
=head2 guff | ||
guff content | ||
=cut | ||
END_IN_POD | ||
=head2 guff | ||
|
||
guff content | ||
|
||
=cut | ||
END_OUT_POD | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters