line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Simpler::Aoh; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
400717
|
use Moo; |
|
6
|
|
|
|
|
68891
|
|
|
6
|
|
|
|
|
27
|
|
4
|
6
|
|
|
6
|
|
11887
|
use MooX::LazierAttributes; |
|
6
|
|
|
|
|
108459
|
|
|
6
|
|
|
|
|
25
|
|
5
|
6
|
|
|
6
|
|
4779
|
use Types::Standard qw/Str ArrayRef HashRef Bool/; |
|
6
|
|
|
|
|
452371
|
|
|
6
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Pod::Simple'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
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
|
|
|
|
|
|
|
split_content => [ rw, Bool, { clr } ] |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _build_pod_elements { |
20
|
|
|
|
|
|
|
return { |
21
|
9
|
|
|
9
|
|
455
|
Document => 'skip', |
22
|
|
|
|
|
|
|
head1 => 'title', |
23
|
|
|
|
|
|
|
head2 => 'title', |
24
|
|
|
|
|
|
|
head2 => 'title', |
25
|
|
|
|
|
|
|
head4 => 'title', |
26
|
|
|
|
|
|
|
Para => 'content', |
27
|
|
|
|
|
|
|
'item-text' => 'content', |
28
|
|
|
|
|
|
|
'over-text' => 'content', |
29
|
|
|
|
|
|
|
'over-bullet' => 'content', |
30
|
|
|
|
|
|
|
'item-bullet' => 'content', |
31
|
|
|
|
|
|
|
Verbatim => 'content', |
32
|
|
|
|
|
|
|
Data => 'content', |
33
|
|
|
|
|
|
|
C => 'content', |
34
|
|
|
|
|
|
|
L => 'content', |
35
|
|
|
|
|
|
|
B => 'content', |
36
|
|
|
|
|
|
|
I => 'content', |
37
|
|
|
|
|
|
|
E => 'content', |
38
|
|
|
|
|
|
|
F => 'content', |
39
|
|
|
|
|
|
|
S => 'content', |
40
|
|
|
|
|
|
|
X => 'content', |
41
|
|
|
|
|
|
|
join => 'content', |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
for (qw/parse_file parse_from_file parse_string_document/) { |
46
|
|
|
|
|
|
|
around $_ => sub { |
47
|
|
|
|
|
|
|
my ( $orig, $self, $args ) = @_; |
48
|
|
|
|
|
|
|
$self->clear_pod; |
49
|
|
|
|
|
|
|
$self->$orig($args); |
50
|
|
|
|
|
|
|
return $self->pod; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub find { |
55
|
1
|
|
|
1
|
1
|
21
|
my @sections; |
56
|
1
|
|
|
|
|
9
|
for ($_[0]->aoh) { |
57
|
35
|
100
|
|
|
|
200
|
push @sections, $_ if $_->{$_[1]} =~ m/$_[2]/i; |
58
|
|
|
|
|
|
|
} |
59
|
1
|
50
|
|
|
|
10
|
return wantarray ? @sections : $sections[0]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get { |
63
|
8
|
|
|
8
|
1
|
233
|
return $_[0]->pod->[ $_[1] ]; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub aoh { |
67
|
1
|
|
|
1
|
1
|
3
|
return @{ $_[0]->pod }; |
|
1
|
|
|
|
|
19
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _handle_element_start { |
71
|
1259
|
|
|
1259
|
|
377979
|
$_[0]->element_name( $_[1] ); |
72
|
1259
|
100
|
|
|
|
54656
|
if ( $_[0]->pod_elements->{ $_[1] } eq 'title' ) { |
73
|
|
|
|
|
|
|
$_[0]->section->{title} && $_[0]->section->{identifier} |
74
|
169
|
50
|
66
|
|
|
3928
|
and $_[0]->_insert_pod; |
75
|
|
|
|
|
|
|
not $_[0]->section->{identifier} |
76
|
169
|
50
|
|
|
|
3749
|
and $_[0]->section->{identifier} = $_[1]; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _handle_text { |
81
|
1499
|
|
100
|
1499
|
|
54275
|
my $el_name = $_[0]->element_name || 'join'; |
82
|
1499
|
|
|
|
|
32492
|
$_[0]->clear_element_name; |
83
|
1499
|
|
|
|
|
28307
|
my $pel = $_[0]->pod_elements->{$el_name}; |
84
|
1499
|
100
|
|
|
|
12435
|
if ($pel =~ m#content#) { |
|
|
50
|
|
|
|
|
|
85
|
1330
|
|
|
|
|
3850
|
my $el_args = { |
86
|
|
|
|
|
|
|
text => $_[1], |
87
|
|
|
|
|
|
|
element_name => $el_name, |
88
|
|
|
|
|
|
|
}; |
89
|
1330
|
50
|
|
|
|
21709
|
if ($_[0]->split_content) { |
90
|
0
|
|
|
|
|
0
|
$el_args->{content} = delete $el_args->{text}; |
91
|
0
|
|
|
|
|
0
|
push @{$_[0]->section->{content}}, $el_args; |
|
0
|
|
|
|
|
0
|
|
92
|
|
|
|
|
|
|
} else { |
93
|
1330
|
|
|
|
|
27121
|
$el_args->{content} = $_[0]->section->{content}; |
94
|
|
|
|
|
|
|
$_[0]->section->{content} = |
95
|
1330
|
|
|
|
|
10197
|
$_[0]->_parse_text( 'content', $el_args ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
elsif ($pel =~ m!title!) { |
99
|
169
|
|
|
|
|
2702
|
$_[0]->section->{title} = $_[1]; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub _handle_element_end { |
104
|
1259
|
100
|
|
1259
|
|
18752
|
if ( $_[0]->source_dead ) { |
105
|
|
|
|
|
|
|
$_[0]->_insert_pod |
106
|
|
|
|
|
|
|
if $_[0]->section->{title} |
107
|
18
|
50
|
66
|
|
|
457
|
&& $_[0]->section->{identifier}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _insert_pod { |
112
|
169
|
|
|
169
|
|
4946
|
push @{ $_[0]->pod }, $_[0]->section; |
|
169
|
|
|
|
|
2877
|
|
113
|
169
|
|
|
|
|
7037
|
return $_[0]->clear_section; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _parse_text { |
117
|
1330
|
|
100
|
1330
|
|
4587
|
my $content = $_[2]->{$_[1]} || ''; |
118
|
1330
|
100
|
|
|
|
5672
|
if ( $_[2]->{element_name} =~ m{item-text|over-text} ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
119
|
117
|
|
|
|
|
2715
|
return sprintf "%s\n\n%s\n\n", $content, $_[2]->{text}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
# expecting a code example |
122
|
|
|
|
|
|
|
elsif ( $_[2]->{element_name} =~ m/Verbatim/ ) { |
123
|
77
|
100
|
|
|
|
1839
|
return $content ? sprintf "%s\n\n%s\n\n", $content, $_[2]->{text} : sprintf("%s\n\n", $_[2]->{text}); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
elsif ( $content =~ /[\;\.\:\*]$/ ) { |
126
|
205
|
|
|
|
|
4773
|
return sprintf "%s\n\n%s", $content, $_[2]->{text}; |
127
|
|
|
|
|
|
|
} |
128
|
931
|
100
|
|
|
|
19456
|
return $content ? sprintf "%s%s", $content, $_[2]->{text} : $_[2]->{text}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |