line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Elemental::Transformer::WikiDoc; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
686959
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
with 'Pod::Elemental::Transformer'; |
5
|
|
|
|
|
|
|
# ABSTRACT: a transformer to replace "wikidoc" data regions with Pod5 elements |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.093004'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
10
|
|
|
|
|
|
|
#pod |
11
|
|
|
|
|
|
|
#pod my $document = Pod::Elemental->read_string( $string ); |
12
|
|
|
|
|
|
|
#pod Pod::Elemental::Transformer::Pod5->new->transform_node( $document ); |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod Pod::Elemental::Transformer::WikiDoc->new->transform_node( $document ); |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod ...and if you had a section like this: |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod =begin wikidoc |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod == Look, a header! |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod * Foo |
23
|
|
|
|
|
|
|
#pod * Bar |
24
|
|
|
|
|
|
|
#pod * Baz |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod =end wikidoc |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod ...you now have something more like this: |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod =head2 Look, a header! |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =over 4 |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod =item Foo |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =item Bar |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod =item Baz |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =back |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod For complete documentation on this dialect, see L<Pod::WikiDoc>. |
43
|
|
|
|
|
|
|
#pod |
44
|
|
|
|
|
|
|
#pod Possibly the most succinct, powerful use case is this: |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod =head2 some_method |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod This B<public> method takes the following arguments: |
49
|
|
|
|
|
|
|
#pod |
50
|
|
|
|
|
|
|
#pod =for wikidoc |
51
|
|
|
|
|
|
|
#pod * name |
52
|
|
|
|
|
|
|
#pod * rank |
53
|
|
|
|
|
|
|
#pod * serial_number |
54
|
|
|
|
|
|
|
#pod |
55
|
|
|
|
|
|
|
#pod =cut |
56
|
|
|
|
|
|
|
#pod |
57
|
|
|
|
|
|
|
#pod =cut |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
1
|
|
3714
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
1
|
|
51
|
use Pod::Elemental::Types qw(FormatName); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
62
|
1
|
|
|
1
|
|
1031
|
use Pod::WikiDoc; |
|
1
|
|
|
|
|
56488
|
|
|
1
|
|
|
|
|
249
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#pod =attr format_name |
65
|
|
|
|
|
|
|
#pod |
66
|
|
|
|
|
|
|
#pod This attribute indicates the format name of regions to be transformed from |
67
|
|
|
|
|
|
|
#pod WikiDoc. By default, the transformer will look for regions of the format |
68
|
|
|
|
|
|
|
#pod "wikidoc." |
69
|
|
|
|
|
|
|
#pod |
70
|
|
|
|
|
|
|
#pod =cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has format_name => ( |
73
|
|
|
|
|
|
|
is => 'ro', |
74
|
|
|
|
|
|
|
isa => FormatName, |
75
|
|
|
|
|
|
|
default => 'wikidoc', |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#pod =method transform_node |
79
|
|
|
|
|
|
|
#pod |
80
|
|
|
|
|
|
|
#pod =cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub transform_node { |
83
|
1
|
|
|
1
|
1
|
11266
|
my ($self, $node) = @_; |
84
|
1
|
|
|
|
|
20
|
my $children = $node->children; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Note to future hackers. Don't try replacing this with a simple range operator. |
87
|
|
|
|
|
|
|
# $children gets modified on some loops! |
88
|
1
|
|
|
|
|
4
|
PASS: for (my $i = 0; $i < scalar @{ $children }; $i++) { |
|
30
|
|
|
|
|
607
|
|
89
|
29
|
|
|
|
|
21
|
my $para = $children->[$i]; |
90
|
29
|
50
|
66
|
|
|
141
|
next unless $para->isa('Pod::Elemental::Element::Pod5::Region') |
|
|
|
66
|
|
|
|
|
91
|
|
|
|
|
|
|
and ! $para->is_pod |
92
|
|
|
|
|
|
|
and $para->format_name eq $self->format_name; |
93
|
|
|
|
|
|
|
|
94
|
2
|
|
|
|
|
39
|
confess "wikidoc transformer expects wikidoc region to contain 1 Data para" |
95
|
2
|
50
|
33
|
|
|
2
|
unless scalar @{$para->children} == 1 |
96
|
|
|
|
|
|
|
and $para->children->[0]->isa('Pod::Elemental::Element::Pod5::Data'); |
97
|
|
|
|
|
|
|
|
98
|
2
|
|
|
|
|
93
|
my $text = $para->children->[0]->content; |
99
|
2
|
|
|
|
|
56
|
my $parser = Pod::WikiDoc->new; |
100
|
2
|
|
|
|
|
1005
|
my $new_pod = $parser->convert($para->as_pod_string); |
101
|
|
|
|
|
|
|
|
102
|
2
|
|
|
|
|
39829
|
$new_pod =~ s/^# Generated by Pod::WikiDoc version \S+$//sgm; |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
17
|
my $new_doc = Pod::Elemental->read_string($new_pod); |
105
|
2
|
|
|
|
|
10155
|
Pod::Elemental::Transformer::Pod5->transform_node($new_doc); |
106
|
2
|
|
|
|
|
12746
|
shift @{ $new_doc->children } |
|
2
|
|
|
|
|
51
|
|
107
|
|
|
|
|
|
|
while |
108
|
|
|
|
|
|
|
$new_doc->children->[0]->isa('Pod::Elemental::Element::Pod5::Nonpod'); |
109
|
|
|
|
|
|
|
|
110
|
2
|
|
|
|
|
104
|
splice @$children, $i, 1, @{ $new_doc->children }; |
|
2
|
|
|
|
|
37
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
3
|
return $node; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=pod |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=encoding UTF-8 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 NAME |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Pod::Elemental::Transformer::WikiDoc - a transformer to replace "wikidoc" data regions with Pod5 elements |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 VERSION |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
version 0.093004 |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SYNOPSIS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $document = Pod::Elemental->read_string( $string ); |
135
|
|
|
|
|
|
|
Pod::Elemental::Transformer::Pod5->new->transform_node( $document ); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Pod::Elemental::Transformer::WikiDoc->new->transform_node( $document ); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
...and if you had a section like this: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=begin wikidoc |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
== Look, a header! |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
* Foo |
146
|
|
|
|
|
|
|
* Bar |
147
|
|
|
|
|
|
|
* Baz |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=end wikidoc |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
...you now have something more like this: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 Look, a header! |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over 4 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item Foo |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item Bar |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item Baz |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
For complete documentation on this dialect, see L<Pod::WikiDoc>. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Possibly the most succinct, powerful use case is this: |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 some_method |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This B<public> method takes the following arguments: |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=for wikidoc |
174
|
|
|
|
|
|
|
* name |
175
|
|
|
|
|
|
|
* rank |
176
|
|
|
|
|
|
|
* serial_number |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 format_name |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This attribute indicates the format name of regions to be transformed from |
185
|
|
|
|
|
|
|
WikiDoc. By default, the transformer will look for regions of the format |
186
|
|
|
|
|
|
|
"wikidoc." |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 METHODS |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 transform_node |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SUPPORT |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Please report any bugs or feature requests through the issue tracker |
199
|
|
|
|
|
|
|
at L<https://github.com/dagolden/Pod-Elemental-Transformer-WikiDoc/issues>. |
200
|
|
|
|
|
|
|
You will be notified automatically of any progress on your issue. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 Source Code |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This is open source software. The code repository is available for |
205
|
|
|
|
|
|
|
public review and contribution under the terms of the license. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
L<https://github.com/dagolden/Pod-Elemental-Transformer-WikiDoc> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
git clone https://github.com/dagolden/Pod-Elemental-Transformer-WikiDoc.git |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 AUTHOR |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Ricardo SIGNES <rjbs@cpan.org> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=for stopwords David Golden Kent Fredric |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=over 4 |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item * |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
David Golden <dagolden@cpan.org> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Kent Fredric <kentfredric@gmail.com> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=back |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Ricardo SIGNES. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
236
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=cut |