<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package DhMakePerl::PodParser;

use strict;
use warnings;

our $VERSION = '0.51';

use base qw(Pod::Parser);

=head1 NAME

DhMakePerl::PodParser - internal helper module for DhMakePerl

=head1 SYNOPSIS

DhMakePerl::PodParser is used by DhMakePerl to extract some
information from the module-to-be-packaged. It sub-classes from
L&lt;Pod::Parser&gt; - Please refer to it for further documentation.

=head1 METHODS

=over

=item set_names

Defines the names of the sections that should be fetched from the POD

=cut

sub set_names {
    my ( $parser, @names ) = @_;
    foreach my $n (@names) {
        $parser-&gt;{_deb_}-&gt;{$n} = undef;
    }
}

=item get

Gets the contents for the specified POD section. The single argument should be
one of the values given to L&lt;/set_names&gt;.

=cut

sub get {
    my ( $parser, $name ) = @_;
    $parser-&gt;{_deb_}-&gt;{$name};
}

=item cleanup

Empties the information held by the parser object

=cut

sub cleanup {
    my $parser = shift;
    delete $parser-&gt;{_current_};
    foreach my $k ( keys %{ $parser-&gt;{_deb_} } ) {
        $parser-&gt;{_deb_}-&gt;{$k} = undef;
    }
}

=item command

Overrides base class' L&lt;Pod::Parser&gt; L&lt;command|Pod::Parser/command&gt; method.

Gets each of the POD's commands
(sections), and defines how it should react to each of them. In this
particular implementation, it basically filters out anything except
for the C&lt;=head&gt; sections defined in L&lt;/set_names&gt;.

=cut

sub command {
    my ( $parser, $command, $paragraph, $line_num ) = @_;
    $paragraph =~ s/\s+$//s;
    if ( $command =~ /head/ &amp;&amp; exists( $parser-&gt;{_deb_}-&gt;{$paragraph} ) ) {
        $parser-&gt;{_current_} = $paragraph;
        $parser-&gt;{_lineno_}  = $line_num;
    }
    else {
        delete $parser-&gt;{_current_};
    }

    #print "GOT: $command -&gt; $paragraph\n";
}

=item add_text

Hands back the text it received as it occurred in the input stream (see the
L&lt;Pod::Parser&gt;'s documentation for L&lt;verbatim|Pod::Parser/verbatim&gt;,
L&lt;textblock|Pod::Parser/textblock&gt; and
L&lt;interior_sequence|Pod::Parser/interior_sequence&gt;).

Content is ignored if more than 15 lines away from the section start.

=cut

sub add_text {
    my ( $parser, $paragraph, $line_num ) = @_;
    return unless exists $parser-&gt;{_current_};
    return if ( $line_num - $parser-&gt;{_lineno_} &gt; 15 );
    $paragraph =~ s/^\s+//s;
    $paragraph =~ s/\s+$//s;
    $paragraph = $parser-&gt;interpolate( $paragraph, $line_num );
    $parser-&gt;{_deb_}-&gt;{ $parser-&gt;{_current_} } .= "\n\n" . $paragraph;

    #print "GOT: $paragraph'\n";
}

=item verbatim

Called by L&lt;Pod::Parser&gt; for verbatim paragraphs. Redirected to L&lt;/add_text&gt;.

=cut

sub verbatim { shift-&gt;add_text(@_) }

=item textblock

Called by L&lt;Pod::Parser&gt; for ordinary text paragraphs. Redirected to
L&lt;/add_text&gt;.

=cut

sub textblock { shift-&gt;add_text(@_) }

=item interior_sequence

L&lt;interior_sequence()|Pod::Parser/interior_sequence()&gt; is called by
L&lt;Pod::Parser&gt; when, eh, an interior sequence occurs in the text. Interior
sequences are things like IE&lt;lt&gt;...E&lt;gt&gt;.

This implementation decodes C&lt;gt&gt;, C&lt;lt&gt;, C&lt;sol&gt;, C&lt;verbar&gt; and numeric
character codes, all used by C&lt;E&gt; escape.

=cut

sub interior_sequence {
    my ( $parser, $seq_command, $seq_argument ) = @_;
    if ( $seq_command eq 'E' ) {
        my %map = ( 'gt' =&gt; '&gt;', 'lt' =&gt; '&lt;', 'sol' =&gt; '/', 'verbar' =&gt; '|' );
        return $map{$seq_argument} if exists $map{$seq_argument};
        return chr($seq_argument) if ( $seq_argument =~ /^\d+$/ );

        # html names...
    }
    return $seq_argument;
}

1;

=back

=head1 SEE ALSO

L&lt;Pod::Parser&gt;

=head1 AUTHOR

=over 4

=item Paolo Molaro

=item Documentation added by Gunnar Wolf and Damyan Ivanov

=back

=head1 COPYRIGHT &amp; LICENSE

=over 4

=item Copyright (C) 2001, Paolo Molaro &lt;lupus@debian.org&gt;

=item Copyright (C) 2008, Gunnar Wolf &lt;gwolf@debian.org&gt;

=item Copyright (C) 2008, Damyan Ivanov &lt;dmn@debian.org&gt;

=back

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2 as published by the Free
Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301 USA.

=cut
</pre></body></html>