| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 2010, 2011, 2012, 2013, 2016 Kevin Ryde |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of PodLinkCheck. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# PodLinkCheck is free software; you can redistribute it and/or modify it |
|
6
|
|
|
|
|
|
|
# under the terms of the GNU General Public License as published by the Free |
|
7
|
|
|
|
|
|
|
# Software Foundation; either version 3, or (at your option) any later |
|
8
|
|
|
|
|
|
|
# version. |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# PodLinkCheck is distributed in the hope that it will be useful, but |
|
11
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
12
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13
|
|
|
|
|
|
|
# for more details. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
|
16
|
|
|
|
|
|
|
# with PodLinkCheck. If not, see . |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package App::PodLinkCheck::ParseSections; |
|
19
|
1
|
|
|
1
|
|
403
|
use 5.006; |
|
|
1
|
|
|
|
|
3
|
|
|
20
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
15
|
|
|
21
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
22
|
|
|
22
|
1
|
|
|
1
|
|
4
|
use base 'Pod::Simple'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
554
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
35597
|
use vars '$VERSION'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
824
|
|
|
25
|
|
|
|
|
|
|
$VERSION = 15; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
|
28
|
|
|
|
|
|
|
# use Smart::Comments; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
|
31
|
7
|
|
|
7
|
1
|
8689
|
my ($class, $plc) = @_; |
|
32
|
7
|
|
|
|
|
37
|
my $self = $class->SUPER::new; |
|
33
|
7
|
|
|
|
|
150
|
$self->{(__PACKAGE__)}->{'sections'} = {}; |
|
34
|
7
|
|
|
|
|
28
|
$self->no_errata_section(1); |
|
35
|
7
|
|
|
|
|
62
|
$self->preserve_whitespace(1); |
|
36
|
7
|
50
|
|
|
|
52
|
if (! $plc->{'verbose'}) { |
|
37
|
7
|
|
|
|
|
20
|
$self->no_whining(1); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
7
|
|
|
|
|
48
|
return $self; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub sections_hashref { |
|
43
|
6
|
|
|
6
|
1
|
77
|
my ($self) = @_; |
|
44
|
6
|
|
|
|
|
13
|
return $self->{(__PACKAGE__)}->{'sections'}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _handle_element_start { |
|
48
|
18
|
|
|
18
|
|
3351
|
my ($self, $ename, $attr) = @_; |
|
49
|
|
|
|
|
|
|
### _handle_element_start(): $ename, $attr |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Any of head1 |
|
52
|
|
|
|
|
|
|
# head2 |
|
53
|
|
|
|
|
|
|
# head3 |
|
54
|
|
|
|
|
|
|
# head4 |
|
55
|
|
|
|
|
|
|
# item-text |
|
56
|
|
|
|
|
|
|
# item-bullet |
|
57
|
|
|
|
|
|
|
# item-number |
|
58
|
18
|
100
|
|
|
|
64
|
if ($ename =~ /^(head|item)/) { |
|
59
|
6
|
|
|
|
|
16
|
$self->{(__PACKAGE__)}->{'item_text'} = ''; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# in_X is true when within an X<>, possibly a nested X c> |
|
63
|
|
|
|
|
|
|
# although that's likely a mistake and probably meaningless |
|
64
|
18
|
|
|
|
|
58
|
$self->{(__PACKAGE__)}->{'in_X'} += ($ename eq 'X'); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
sub _handle_text { |
|
67
|
9
|
|
|
9
|
|
824
|
my ($self, $text) = @_; |
|
68
|
|
|
|
|
|
|
### _handle_text(): $text |
|
69
|
9
|
100
|
66
|
|
|
46
|
if (exists $self->{(__PACKAGE__)}->{'item_text'} |
|
70
|
|
|
|
|
|
|
&& ! $self->{(__PACKAGE__)}->{'in_X'}) { |
|
71
|
6
|
|
|
|
|
20
|
$self->{(__PACKAGE__)}->{'item_text'} .= $text; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
sub _handle_element_end { |
|
75
|
18
|
|
|
18
|
|
582
|
my ($self, $ename) = @_; |
|
76
|
|
|
|
|
|
|
### _handle_element_end(): $ename |
|
77
|
|
|
|
|
|
|
|
|
78
|
18
|
|
|
|
|
33
|
$self->{(__PACKAGE__)}->{'in_X'} -= ($ename eq 'X'); |
|
79
|
|
|
|
|
|
|
|
|
80
|
18
|
100
|
|
|
|
65
|
if ($ename =~ /^(head|item)/) { |
|
81
|
6
|
|
|
|
|
14
|
my $section = delete $self->{(__PACKAGE__)}->{'item_text'}; |
|
82
|
|
|
|
|
|
|
### section: $section |
|
83
|
|
|
|
|
|
|
|
|
84
|
6
|
|
|
|
|
14
|
$section = _collapse_whitespace ($section); |
|
85
|
6
|
|
|
|
|
14
|
$self->{(__PACKAGE__)}->{'sections'}->{$section} = 1; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Like Pod::Checker take the first word, meaning up to the first |
|
88
|
|
|
|
|
|
|
# whitespace, as a section name too, which is much used for |
|
89
|
|
|
|
|
|
|
# cross-references to perlfunc. |
|
90
|
|
|
|
|
|
|
# |
|
91
|
|
|
|
|
|
|
# THINK-ABOUT-ME: CHI.pm is better treated by taking the first \w word |
|
92
|
|
|
|
|
|
|
# so as to exclude parens etc. |
|
93
|
|
|
|
|
|
|
# |
|
94
|
6
|
100
|
|
|
|
22
|
if ($section =~ s/\s.*//) { |
|
95
|
|
|
|
|
|
|
### section one word: $section |
|
96
|
3
|
|
|
|
|
9
|
$self->{(__PACKAGE__)}->{'sections'}->{$section} = 1; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _collapse_whitespace { |
|
102
|
6
|
|
|
6
|
|
13
|
my ($str) = @_; |
|
103
|
6
|
|
|
|
|
20
|
$str =~ s/\s+/ /g; |
|
104
|
6
|
|
|
|
|
13
|
$str =~ s/^\s+//; |
|
105
|
6
|
|
|
|
|
12
|
$str =~ s/\s+$//; |
|
106
|
6
|
|
|
|
|
14
|
return $str; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
|
110
|
|
|
|
|
|
|
__END__ |