/usr/share/perl5/Pod/Index/Extract.pm is in libpod-index-perl 0.14-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package Pod::Index::Extract;
use 5.008;
$VERSION = '0.14';
use strict;
use warnings;
use base qw(Pod::Parser);
sub begin_input {
my ($self) = @_;
$self->cutting(0); # force parser to notice that it's in POD mode
}
sub verbatim {
my ($self, $text, $line_num, $pod_para) = @_;
# verbatim should't have the X<> attached
return $self->ppi_done unless $self->{ppi_anchor_type};
my $out_fh = $self->output_handle;
print $out_fh $text;
$self->{ppi_textblock_count}++;
}
sub textblock {
my ($self, $text, $line_num, $pod_para) = @_;
# should sanity check that the X<> is really here...
#print "<<<$text>>>\n";
my $out_fh = $self->output_handle;
unless ($self->{ppi_anchor_type}) {
$self->{ppi_anchor_type} = 'textblock';
$self->ppi_start;
}
# only print the first paragraph if in textblock mode
return $self->ppi_done if $self->{ppi_anchor_type} eq 'textblock'
and $self->{ppi_textblock_count};
print $out_fh $text;
$self->{ppi_textblock_count}++;
}
sub command {
my ($self, $cmd, $text, $line_num, $pod_para) = @_;
# should sanity check that the X<> is really here...
my $out_fh = $self->output_handle;
unless ($self->{ppi_anchor_type}) {
$self->{ppi_anchor_type} = 'command';
$self->{ppi_command} = $cmd;
$self->ppi_start;
if ($cmd eq 'item') {
print $out_fh "=over\n\n";
}
}
return $self->ppi_done unless $self->{ppi_anchor_type} eq 'command';
my $ppi_cmd = $self->{ppi_command};
return $self->ppi_done unless $ppi_cmd =~ /^(?:head|item)/; # XXX
# check if we are out of scope
if ($self->{ppi_textblock_count}) {
if ($ppi_cmd =~ /^head(\d)/) {
my $initial_level = $1;
if ($cmd =~ /^head(\d)/) {
my $current_level = $1;
return $self->ppi_done if $current_level <= $initial_level;
}
} elsif ($ppi_cmd =~ /^item/) {
if ($cmd =~ /item|back/ and !$self->{ppi_depth}) {
return $self->ppi_done;
} elsif ($cmd eq 'over') {
$self->{ppi_depth}++;
} elsif ($cmd eq 'back') {
$self->{ppi_depth}--;
}
} else {
die "shouldn't be here ";
}
}
print $out_fh $pod_para->raw_text;
}
sub ppi_start {
my ($self) = @_;
}
sub ppi_done {
my ($self) = @_;
my $out_fh = $self->output_handle;
if ($self->{ppi_command} and $self->{ppi_command} eq 'item') {
print $out_fh "=back\n\n";
}
my $fh = $self->input_handle;
seek $fh, 0, 2; # EOF
}
1;
__END__
=head1 NAME
Pod::Index::Extract - Extracts a "pod scope"
=head1 SYNOPSIS
use Pod::Index::Extract;
my $parser = Pod::Index::Extract->new;
# [...] get $fh_in to the desired position
$parser->parse_from_filehandle($fh_in, $fh_out);
=head1 DESCRIPTION
This module is a subclass of L<Pod::Parser>. It outputs POD without any
transformation; however, it only outputs the POD that is "in scope" as
defined in L<Pod::Index>.
To use this module, you first need to position a filehandle at the beginning of
the desired scope, and then call C<parse_from_filehandle> with that filehandle
for input. It will just print the POD until it reaches the end of the
scope, after which it will jump to the end of the file.
If the scope starts with an C<=item>, it will wrap it with an C<=over> and
a C<=back>, so it can be used as valid POD in isolation.
=head1 VERSION
0.14
=head1 SEE ALSO
L<Pod::Index>,
L<Pod::Index::Entry>,
L<Pod::Parser>
=head1 AUTHOR
Ivan Tubert-Brohman E<lt>itub@cpan.orgE<gt>
=head1 COPYRIGHT
Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same terms as
Perl itself.
=cut
|