line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Simpler::Aoh; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
324720
|
use Moo; |
|
6
|
|
|
|
|
55096
|
|
|
6
|
|
|
|
|
25
|
|
4
|
6
|
|
|
6
|
|
9476
|
use MooX::LazierAttributes; |
|
6
|
|
|
|
|
86623
|
|
|
6
|
|
|
|
|
22
|
|
5
|
6
|
|
|
6
|
|
3747
|
use Types::Standard qw/Str ArrayRef HashRef/; |
|
6
|
|
|
|
|
367736
|
|
|
6
|
|
|
|
|
46
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Pod::Simple'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
attributes( |
12
|
|
|
|
|
|
|
pod => [ rw, ArrayRef, { lzy_array, clr } ], |
13
|
|
|
|
|
|
|
section => [ rw, HashRef, { lzy_hash, clr } ], |
14
|
|
|
|
|
|
|
pod_elements => [ HashRef, { lzy, bld } ], |
15
|
|
|
|
|
|
|
element_name => [ rw, Str, { clr } ], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_pod_elements { |
19
|
|
|
|
|
|
|
return { |
20
|
9
|
|
|
9
|
|
290
|
Document => 'skip', |
21
|
|
|
|
|
|
|
head1 => 'title', |
22
|
|
|
|
|
|
|
head2 => 'title', |
23
|
|
|
|
|
|
|
head2 => 'title', |
24
|
|
|
|
|
|
|
head4 => 'title', |
25
|
|
|
|
|
|
|
Para => 'content', |
26
|
|
|
|
|
|
|
'item-text' => 'content', |
27
|
|
|
|
|
|
|
'over-text' => 'content', |
28
|
|
|
|
|
|
|
Verbatim => 'content', |
29
|
|
|
|
|
|
|
Data => 'content', |
30
|
|
|
|
|
|
|
C => 'content', |
31
|
|
|
|
|
|
|
L => 'content', |
32
|
|
|
|
|
|
|
B => 'content', |
33
|
|
|
|
|
|
|
I => 'content', |
34
|
|
|
|
|
|
|
E => 'content', |
35
|
|
|
|
|
|
|
F => 'content', |
36
|
|
|
|
|
|
|
S => 'content', |
37
|
|
|
|
|
|
|
X => 'content', |
38
|
|
|
|
|
|
|
join => 'content', |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
for (qw/parse_file parse_from_file parse_string_document/) { |
43
|
|
|
|
|
|
|
around $_ => sub { |
44
|
|
|
|
|
|
|
my ( $orig, $self, $args ) = @_; |
45
|
|
|
|
|
|
|
$self->clear_pod; |
46
|
|
|
|
|
|
|
$self->$orig($args); |
47
|
|
|
|
|
|
|
return $self->pod; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub find { |
52
|
1
|
|
|
1
|
1
|
15
|
my @sections; |
53
|
1
|
|
|
|
|
5
|
for ($_[0]->aoh) { |
54
|
35
|
100
|
|
|
|
87
|
push @sections, $_ if $_->{$_[1]} =~ m/$_[2]/i; |
55
|
|
|
|
|
|
|
} |
56
|
1
|
50
|
|
|
|
5
|
return wantarray ? @sections : $sections[0]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get { |
60
|
8
|
|
|
8
|
1
|
181
|
return $_[0]->pod->[ $_[1] ]; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub aoh { |
64
|
1
|
|
|
1
|
1
|
2
|
return @{ $_[0]->pod }; |
|
1
|
|
|
|
|
16
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _handle_element_start { |
68
|
1259
|
|
|
1259
|
|
303952
|
$_[0]->element_name( $_[1] ); |
69
|
1259
|
100
|
|
|
|
44147
|
if ( $_[0]->pod_elements->{ $_[1] } eq 'title' ) { |
70
|
|
|
|
|
|
|
$_[0]->section->{title} && $_[0]->section->{identifier} |
71
|
169
|
50
|
66
|
|
|
3197
|
and $_[0]->_insert_pod; |
72
|
|
|
|
|
|
|
not $_[0]->section->{identifier} |
73
|
169
|
50
|
|
|
|
2976
|
and $_[0]->section->{identifier} = $_[1]; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _handle_text { |
78
|
1499
|
|
100
|
1499
|
|
44395
|
my $el_name = $_[0]->element_name || 'join'; |
79
|
1499
|
|
|
|
|
26875
|
$_[0]->clear_element_name; |
80
|
1499
|
|
|
|
|
23255
|
my $pel = $_[0]->pod_elements->{$el_name}; |
81
|
1499
|
100
|
|
|
|
10122
|
if ($pel =~ m#content#) { |
|
|
50
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $el_args = { |
83
|
|
|
|
|
|
|
text => $_[1], |
84
|
|
|
|
|
|
|
element_name => $el_name, |
85
|
|
|
|
|
|
|
content => $_[0]->section->{content}, |
86
|
1330
|
|
|
|
|
17684
|
}; |
87
|
|
|
|
|
|
|
$_[0]->section->{content} = |
88
|
1330
|
|
|
|
|
9450
|
$_[0]->_parse_text( 'content', $el_args ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
elsif ($pel =~ m!title!) { |
91
|
169
|
|
|
|
|
2239
|
$_[0]->section->{title} = $_[1]; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _handle_element_end { |
96
|
1259
|
100
|
|
1259
|
|
15205
|
if ( $_[0]->source_dead ) { |
97
|
|
|
|
|
|
|
$_[0]->_insert_pod |
98
|
|
|
|
|
|
|
if $_[0]->section->{title} |
99
|
18
|
50
|
66
|
|
|
338
|
&& $_[0]->section->{identifier}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub _insert_pod { |
104
|
169
|
|
|
169
|
|
4003
|
push @{ $_[0]->pod }, $_[0]->section; |
|
169
|
|
|
|
|
2278
|
|
105
|
169
|
|
|
|
|
6044
|
return $_[0]->clear_section; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _parse_text { |
109
|
1330
|
|
100
|
1330
|
|
3624
|
my $content = $_[2]->{$_[1]} || ''; |
110
|
1330
|
100
|
|
|
|
4819
|
if ( $_[2]->{element_name} =~ m{item-text|over-text} ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
111
|
117
|
|
|
|
|
2371
|
return sprintf "%s\n\n%s\n\n", $content, $_[2]->{text}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
# expecting a code example |
114
|
|
|
|
|
|
|
elsif ( $_[2]->{element_name} =~ m/Verbatim/ ) { |
115
|
77
|
100
|
|
|
|
1524
|
return $content ? sprintf "%s\n\n%s\n\n", $content, $_[2]->{text} : sprintf("%s\n\n", $_[2]->{text}); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
elsif ( $content =~ /[\;\.\:\*]$/ ) { |
118
|
205
|
|
|
|
|
3812
|
return sprintf "%s\n\n%s", $content, $_[2]->{text}; |
119
|
|
|
|
|
|
|
} |
120
|
931
|
100
|
|
|
|
15964
|
return $content ? sprintf "%s%s", $content, $_[2]->{text} : $_[2]->{text}; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |