Pod::Abstract::Filter::add_podcmds - paf command to insert explict =pod


Pod-Abstract documentation Contained in the Pod-Abstract distribution.

Index


Code Index:

NAME

Top

Pod::Abstract::Filter::add_podcmds - paf command to insert explict =pod commands before each Pod block in a document.

METHODS

Top

filter

Add a =pod command after each block of cut nodes. This will cause explicit pod declarations wherever they are currently implicit.

AUTHOR

Top

Ben Lilburne <bnej@mac.com>

COPYRIGHT AND LICENSE

Top


Pod-Abstract documentation Contained in the Pod-Abstract distribution.
package Pod::Abstract::Filter::add_podcmds;
use strict;

use base qw(Pod::Abstract::Filter);
use Pod::Abstract::BuildNode qw(node);

our $VERSION = '0.20';

sub filter {
    my $self = shift;
    my $pa = shift;

    my @cut_finals = $pa->select(
        "//#cut[!>>#cut][!>>pod]"
        );

    # If the document ends with a cut, we don't want a new Pod section
    # - but if it ends with a pod, we do.
    my $last_cut = pop @cut_finals;
    my $ignore_last = 1;
    my $p = $last_cut;
    $ignore_last = 0 if $p->next;
    while($p && ($p = $p->parent) && $ignore_last) {
        $ignore_last = 0 if $p->next;
    }
    push @cut_finals, $last_cut unless $ignore_last;

    foreach my $n (@cut_finals) {
        node->pod->insert_after($n);
    }

    return $pa;
}

1;