this very sloppy debugging code shows:
1) line_count() returns lines 2 greater than the lines in the
actual file... why why why? The Pod::Simple::Subclassing docs
aren't exactly finished, and they mention a start_line
attribute that simply isn't passed to the handlers -- among
other caveats. Curious, ucky, etc.
If these wrong line numbers are consistent between versions,
they should be sorta usable. Odd. Rather than subtracting
two, though, I'm going to store the line_count of the
document. Maybe that'll help?
Pfft, there's no point really. All the .pods and .pms in this
distribution seem to show the same off-by-two line_count().
Weird.
2) we should whine in the text handler when {to} (from start)
doesn't match text; resetting the "state" in the end handler.
Paul Miller
14 years ago
1 | 1 |
use base 'Pod::Simple';
|
2 | 2 |
use strict;
|
3 | 3 |
|
|
4 |
open our $debug, ">", "notes.txt";
|
|
5 |
|
4 | 6 |
sub _handle_element_start {
|
5 | 7 |
my($parser, $element_name, $attr_hash_r) = @_;
|
|
8 |
my $line = $parser->line_count -2;
|
|
9 |
|
|
10 |
# Curiously, Pod::Simple supports L<text|scheme:...> rather well.
|
|
11 |
if( $element_name eq "L" ) {
|
|
12 |
print $debug "<$element_name href='$attr_hash_r->{to}' type='$attr_hash_r->{type}'> ($line)\n" if $debug;
|
|
13 |
|
|
14 |
# if( $attr_hash_r->{type} eq "url" ) {
|
|
15 |
# $parser->whine($parser->line_count(), "L<text|scheme:...> is invalid according to perlpod");
|
|
16 |
# }
|
|
17 |
}
|
|
18 |
|
|
19 |
else {
|
|
20 |
print $debug "<$element_name> ($line)\n" if $debug;
|
|
21 |
}
|
6 | 22 |
|
7 | 23 |
return $parser->SUPER::_handle_element_start(@_);
|
8 | 24 |
}
|
9 | 25 |
|
10 | 26 |
sub _handle_element_end {
|
11 | 27 |
my($parser, $element_name) = @_;
|
|
28 |
my $line = $parser->line_count -2;
|
|
29 |
|
|
30 |
print $debug "</$element_name> ($line)\n" if $debug;
|
12 | 31 |
|
13 | 32 |
return $parser->SUPER::_handle_element_end(@_);
|
|
33 |
}
|
|
34 |
|
|
35 |
sub _handle_text {
|
|
36 |
my($parser, $text) = @_;
|
|
37 |
my $line = $parser->line_count -2;
|
|
38 |
|
|
39 |
print $debug "$text ($line)\n" if $debug;
|
|
40 |
|
|
41 |
return $parser->SUPER::_handle_text(@_);
|
14 | 42 |
}
|
15 | 43 |
|
16 | 44 |
1;
|
|
0 |
|
0 | 1 |
=head1 COPYRIGHT
|
1 | 2 |
|
2 | 3 |
Copyright 2009, Paul Miller C<< <jettero@cpan.org> >>
|
3 | 4 |
|
|
5 |
|
|
6 |
... test text, please ignore
|
|
7 |
|
4 | 8 |
=head1 SEE ALSO
|
|
9 |
|
|
10 |
... test text, please ignore
|
5 | 11 |
|
6 | 12 |
Invalid according to L<perlpod/Formatting Codes>:
|
7 | 13 |
|
8 | 14 |
L<Paul's Perl Modules|http://voltar.org/perl>
|
9 | 15 |
|
|
16 |
|
|
17 |
This should be OK:
|
|
18 |
|
|
19 |
L<Paul's Perl Modules|http://voltar.org/perl>
|
|
20 |
|
|
21 |
This should also be OK: L<http://voltar.org/perl>
|
|
22 |
|
|
23 |
... test text, please ignore
|
|
24 |
|
10 | 25 |
=cut
|
11 | 26 |
|