line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1055166
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
3
|
|
|
|
|
|
|
package Pod::Elemental::Transformer::Verbatim; # git description: 8baf5a3 |
4
|
|
|
|
|
|
|
# ABSTRACT: Transform :verbatim regions into verbatim paragraphs |
5
|
|
|
|
|
|
|
# KEYWORDS: pod transformer verbatim literal indent code text |
6
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 tw=115 et : |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
with 'Pod::Elemental::Transformer' => { -version => '0.101620' }; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5669
|
use Pod::Elemental::Types 'FormatName'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
14
|
1
|
|
|
1
|
|
899
|
use Pod::Elemental::Element::Pod5::Verbatim; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
15
|
1
|
|
|
1
|
|
5
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has format_name => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => FormatName, |
20
|
|
|
|
|
|
|
default => 'verbatim', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
## TODO? customize the number of columns used for indenting |
24
|
4
|
|
|
4
|
0
|
120
|
sub indent_level { 4 } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub transform_node |
27
|
|
|
|
|
|
|
{ |
28
|
2
|
|
|
2
|
1
|
26313
|
my ($self, $node) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# why do we process in reverse? it should make no difference |
31
|
2
|
|
|
|
|
6
|
for my $i (reverse(0 .. $#{ $node->children })) { |
|
2
|
|
|
|
|
58
|
|
32
|
10
|
|
|
|
|
447
|
my $para = $node->children->[ $i ]; |
33
|
10
|
100
|
|
|
|
56
|
next unless $self->__is_xformable($para); |
34
|
2
|
|
|
|
|
8
|
my @replacements = $self->_make_verbatim( $para ); |
35
|
2
|
|
|
|
|
263
|
splice @{ $node->children }, $i, 1, @replacements; |
|
2
|
|
|
|
|
56
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
4
|
return $node; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _make_verbatim |
42
|
|
|
|
|
|
|
{ |
43
|
2
|
|
|
2
|
|
3
|
my ($self, $parent) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return map { |
46
|
3
|
|
|
|
|
170
|
my $para = $_; |
47
|
|
|
|
|
|
|
!$para->isa('Pod::Elemental::Element::Pod5::Ordinary') |
48
|
|
|
|
|
|
|
? ($self->__is_xformable($para) ? $self->_make_verbatim($para) : $para) |
49
|
|
|
|
|
|
|
: length $para->content |
50
|
|
|
|
|
|
|
? Pod::Elemental::Element::Pod5::Verbatim->new({ |
51
|
3
|
0
|
|
|
|
109
|
content => join("\n", map { ' ' x $self->indent_level . $_ } split(/\n/, $para->content)), |
|
4
|
50
|
|
|
|
138
|
|
|
|
50
|
|
|
|
|
|
52
|
|
|
|
|
|
|
}) |
53
|
|
|
|
|
|
|
: (); |
54
|
2
|
|
|
|
|
4
|
} @{ $parent->children }; |
|
2
|
|
|
|
|
60
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# from ::List |
58
|
|
|
|
|
|
|
sub __is_xformable |
59
|
|
|
|
|
|
|
{ |
60
|
10
|
|
|
10
|
|
12
|
my ($self, $para) = @_; |
61
|
|
|
|
|
|
|
|
62
|
10
|
100
|
66
|
|
|
132
|
return unless $para->isa('Pod::Elemental::Element::Pod5::Region') |
63
|
|
|
|
|
|
|
and $para->format_name eq $self->format_name; |
64
|
|
|
|
|
|
|
|
65
|
2
|
50
|
|
|
|
65
|
confess('verbatim regions must be pod (=begin :' . $self->format_name . ')') |
66
|
|
|
|
|
|
|
unless $para->is_pod; |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
16
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=pod |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=encoding UTF-8 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 NAME |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Pod::Elemental::Transformer::Verbatim - Transform :verbatim regions into verbatim paragraphs |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 VERSION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
version 0.001 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
In your F<weaver.ini>: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
[-Transformer / Verbatim] |
92
|
|
|
|
|
|
|
transformer = Verbatim |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Or in a plugin bundle: |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub mvp_bundle_config { |
97
|
|
|
|
|
|
|
return ( |
98
|
|
|
|
|
|
|
... |
99
|
|
|
|
|
|
|
[ '@Author::YOU/Verbatim', _exp('-Transformer'), { 'transformer' => 'Verbatim' } ], |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 DESCRIPTION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This module acts as a L<pod transformer|Pod::Elemental::Transformer>, using |
106
|
|
|
|
|
|
|
C<:verbatim> regions to mark sections of text for treatment as if they were |
107
|
|
|
|
|
|
|
verbatim paragraphs. The transformer indents the contained text by four |
108
|
|
|
|
|
|
|
columns, allowing the pod parser to treat them properly; see |
109
|
|
|
|
|
|
|
L<perlpod/"Verbatim Paragraph">. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
That is, this pod: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=begin :verbatim |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Here is some text. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=end :verbatim |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Is transformed to: |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Here is some text |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Note that a single paragraph can be simply noted with C<=for :verbatim> rather |
124
|
|
|
|
|
|
|
than using C<=begin :verbatim> and C<=end :verbatim> lines. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 format_name |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This attribute (defaulting to C<verbatim>) is the region format that will be |
131
|
|
|
|
|
|
|
processed by this transformer. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 METHODS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 transform_node |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Given a pod document object, returns the object with all its children with |
138
|
|
|
|
|
|
|
C<:verbatim> directives removed and appropriate content replaced with |
139
|
|
|
|
|
|
|
L<Pod::Elemental::Element::Pod5::Verbatim> objects. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=for Pod::Coverage indent_level |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SUPPORT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=for stopwords irc |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Pod-Elemental-Transformer-Verbatim> |
148
|
|
|
|
|
|
|
(or L<bug-Pod-Elemental-Transformer-Verbatim@rt.cpan.org|mailto:bug-Pod-Elemental-Transformer-Verbatim@rt.cpan.org>). |
149
|
|
|
|
|
|
|
I am also usually active on irc, as 'ether' at C<irc.perl.org>. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SEE ALSO |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over 4 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L<Pod::Weaver> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 AUTHOR |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Karen Etheridge. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
170
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |