/usr/share/perl5/Pod/Elemental/Element/Pod5/Region.pm is in libpod-elemental-perl 0.102361-1.
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 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 | package Pod::Elemental::Element::Pod5::Region;
{
$Pod::Elemental::Element::Pod5::Region::VERSION = '0.102361';
}
# ABSTRACT: a region of Pod (this role likely to be removed)
use Moose;
with qw(
Pod::Elemental::Paragraph
Pod::Elemental::Node
Pod::Elemental::Command
);
use Moose::Autobox;
use Pod::Elemental::Types qw(FormatName);
use MooseX::Types::Moose qw(Bool);
has format_name => (is => 'ro', isa => FormatName, required => 1);
has is_pod => (is => 'ro', isa => Bool, required => 1, default => 1);
sub command { 'begin' }
sub closing_command { 'end' }
sub _display_as_for {
my ($self) = @_;
# Everything after "=for target" becomes the lone child paragraph, so there
# is nowhere to put the (technically illegal) content. -- rjbs, 2009-11-24
return if $self->content =~ /\S/;
# We can't have more than one paragraph, because there'd be a blank, so we
# couldn't round trip. -- rjbs, 2009-11-24
return if $self->children->length != 1;
my $child = $self->children->[0];
return if $child->content =~ m{^\s*$}m;
my $base = 'Pod::Elemental::Element::Pod5::';
return 1 if $self->is_pod and $child->isa("${base}Ordinary");
return 1 if ! $self->is_pod and $child->isa("${base}Data");
return;
}
sub as_pod_string {
my ($self) = @_;
my $string;
if ($self->_display_as_for) {
$string = $self->__as_pod_string_for($self);
} else {
$string = $self->__as_pod_string_begin($self);
}
$string =~ s/\n*\z//g;
return $string;
}
sub __as_pod_string_begin {
my ($self) = @_;
my $content = $self->content;
my $colon = $self->is_pod ? ':' : '';
my $string = sprintf "=%s %s%s\n",
$self->command,
$colon . $self->format_name,
($content =~ /\S/ ? " $content\n" : "\n");
$string .= $self->children->map(sub { $_->as_pod_string })->join(q{});
$string .= "\n\n"
if $self->children->length
and $self->children->[-1]->isa( 'Pod::Elemental::Element::Pod5::Data');
# Pod5::$self->is_pod; # XXX: HACK!! -- rjbs, 2009-10-21
$string .= sprintf "=%s %s",
$self->closing_command,
$colon . $self->format_name;
return $string;
}
sub __as_pod_string_for {
my ($self) = @_;
my $content = $self->content;
my $colon = $self->is_pod ? ':' : '';
my $string = sprintf "=for %s %s",
$colon . $self->format_name,
$self->children->[0]->as_pod_string;
return $string;
}
sub as_debug_string {
my ($self) = @_;
my $colon = $self->is_pod ? ':' : '';
my $string = sprintf "=%s %s",
$self->command,
$colon . $self->format_name;
return $string;
}
with 'Pod::Elemental::Autoblank';
with 'Pod::Elemental::Autochomp';
# BEGIN Autochomp Replacement
use Pod::Elemental::Types qw(ChompedString);
has '+content' => (coerce => 1, isa => ChompedString);
# END Autochomp Replacement
no Moose;
1;
__END__
=pod
=head1 NAME
Pod::Elemental::Element::Pod5::Region - a region of Pod (this role likely to be removed)
=head1 VERSION
version 0.102361
=head1 OVERVIEW
A Pod5::Region element represents a region marked by a C<=for> command or a
pair of C<=begin> and C<=end> commands. It may have content of its own as well
as child paragraphs.
Its C<as_pod_string> method will emit either a C<=begin/=end>-enclosed string
or a C<=for> command, based on whichever is permissible.
=head1 ATTRIBUTES
=head2 format_name
This is the format to which the region was targeted.
B<Note!> The format name should I<not> include the leading colon to indicate a
pod paragraph. For that, see C<L</is_pod>>.
=head2 is_pod
If true, this region contains pod (ordinary or verbatim) paragraphs, as opposed
to data paragraphs. This will generally result from the document originating
in a C<=begin> block with a colon-prefixed target identifier:
=begin :html
This is still a verbatim paragraph.
=end :html
=head1 WARNING
This class is somewhat sketchy and may be refactored somewhat in the future,
specifically to refactor its similarities to
L<Pod::Elemental::Element::Nested>.
=head1 AUTHOR
Ricardo SIGNES <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|