| 1 | |||||||||||||
| 2 | # A quite dimwitted pod2plaintext that need only know how to format whatever | ||||||||||||
| 3 | # text comes out of Pod::BlackBox's _gen_errata | ||||||||||||
| 4 | |||||||||||||
| 5 | package Pod::Simple::Checker; | ||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use Carp (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | ▶ | use Pod::Simple::Methody (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 1 | ▶ | use Pod::Simple (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 1 | our $VERSION = '3.48'; | |||||||||||
| 12 | 1 | our @ISA = ('Pod::Simple::Methody'); | |||||||||||
| 13 | 1 | ▶ | BEGIN { *DEBUG = defined(&Pod::Simple::DEBUG) | ||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
| |||||||||||||
| 14 | ? \&Pod::Simple::DEBUG | ||||||||||||
| 15 | : sub() {0} | ||||||||||||
| 16 | 1 | ▶ | } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | |||||||||||||
| 18 | 1 | ▶ | use Text::Wrap 98.112902 (); # was 2001.0131, but I don't think we need that | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||
| 20 | |||||||||||||
| 21 | 0 | ▶ | sub any_errata_seen { # read-only accessor | ||||||||||
|
Subroutine
any_errata_seen: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 22 | 0 | return $_[1]->{'Errata_seen'}; | |||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 26 | 0 | my $self = shift; | |||||||||||
| 27 | 0 | my $new = $self->SUPER::new(@_); | |||||||||||
| 28 | 0 | ▶ | $new->{'output_fh'} ||= *STDOUT{IO}; | ||||||||||
|
Condition0%0/2
$new->{"output_fh"} ||= *STDOUT{"IO"}
MC/DC0%0/1
$new->{"output_fh"} ||= *STDOUT{"IO"}
$new->{"output_fh"}
Truth table0%0/2
A
A= $new->{"output_fh"}
| |||||||||||||
| 29 | 0 | $new->nix_X_codes(1); | |||||||||||
| 30 | 0 | $new->nbsp_for_S(1); | |||||||||||
| 31 | 0 | $new->{'Thispara'} = ''; | |||||||||||
| 32 | 0 | $new->{'Indent'} = 0; | |||||||||||
| 33 | 0 | $new->{'Indentstring'} = ' '; | |||||||||||
| 34 | 0 | $new->{'Errata_seen'} = 0; | |||||||||||
| 35 | 0 | return $new; | |||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||
| 39 | |||||||||||||
| 40 | 0 | ▶ | sub handle_text { $_[0]{'Errata_seen'} and $_[0]{'Thispara'} .= $_[1] } | ||||||||||
|
Subroutine
handle_text: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||
| 41 | |||||||||||||
| 42 | 0 | ▶ | sub start_Para { $_[0]{'Thispara'} = '' } | ||||||||||
|
Subroutine
start_Para: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 43 | |||||||||||||
| 44 | 0 | ▶ | sub start_head1 { | ||||||||||
|
Subroutine
start_head1: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 45 | 0 | ▶ | if($_[0]{'Errata_seen'}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | 0 | $_[0]{'Thispara'} = ''; | |||||||||||
| 47 | } else { | ||||||||||||
| 48 | 0 | ▶ | if($_[1]{'errata'}) { # start of errata! | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | 0 | $_[0]{'Errata_seen'} = 1; | |||||||||||
| 50 | 0 | ▶ | $_[0]{'Thispara'} = $_[0]{'source_filename'} ? | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | "$_[0]{'source_filename'} -- " : '' | ||||||||||||
| 52 | } | ||||||||||||
| 53 | } | ||||||||||||
| 54 | } | ||||||||||||
| 55 | 0 | ▶ | sub start_head2 { $_[0]{'Thispara'} = '' } | ||||||||||
|
Subroutine
start_head2: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 56 | 0 | ▶ | sub start_head3 { $_[0]{'Thispara'} = '' } | ||||||||||
|
Subroutine
start_head3: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 57 | 0 | ▶ | sub start_head4 { $_[0]{'Thispara'} = '' } | ||||||||||
|
Subroutine
start_head4: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 58 | |||||||||||||
| 59 | 0 | ▶ | sub start_Verbatim { $_[0]{'Thispara'} = '' } | ||||||||||
|
Subroutine
start_Verbatim: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 60 | 0 | ▶ | sub start_item_bullet { $_[0]{'Thispara'} = '* ' } | ||||||||||
|
Subroutine
start_item_bullet: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 61 | 0 | ▶ | sub start_item_number { $_[0]{'Thispara'} = "$_[1]{'number'}. " } | ||||||||||
|
Subroutine
start_item_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 62 | 0 | ▶ | sub start_item_text { $_[0]{'Thispara'} = '' } | ||||||||||
|
Subroutine
start_item_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | sub start_over_bullet { ++$_[0]{'Indent'} } | ||||||||||
|
Subroutine
start_over_bullet: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 65 | 0 | ▶ | sub start_over_number { ++$_[0]{'Indent'} } | ||||||||||
|
Subroutine
start_over_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 66 | 0 | ▶ | sub start_over_text { ++$_[0]{'Indent'} } | ||||||||||
|
Subroutine
start_over_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 67 | 0 | ▶ | sub start_over_block { ++$_[0]{'Indent'} } | ||||||||||
|
Subroutine
start_over_block: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 68 | |||||||||||||
| 69 | 0 | ▶ | sub end_over_bullet { --$_[0]{'Indent'} } | ||||||||||
|
Subroutine
end_over_bullet: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 70 | 0 | ▶ | sub end_over_number { --$_[0]{'Indent'} } | ||||||||||
|
Subroutine
end_over_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 71 | 0 | ▶ | sub end_over_text { --$_[0]{'Indent'} } | ||||||||||
|
Subroutine
end_over_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 72 | 0 | ▶ | sub end_over_block { --$_[0]{'Indent'} } | ||||||||||
|
Subroutine
end_over_block: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 73 | |||||||||||||
| 74 | |||||||||||||
| 75 | # . . . . . Now the actual formatters: | ||||||||||||
| 76 | |||||||||||||
| 77 | 0 | ▶ | sub end_head1 { $_[0]->emit_par(-4) } | ||||||||||
|
Subroutine
end_head1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 78 | 0 | ▶ | sub end_head2 { $_[0]->emit_par(-3) } | ||||||||||
|
Subroutine
end_head2: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 79 | 0 | ▶ | sub end_head3 { $_[0]->emit_par(-2) } | ||||||||||
|
Subroutine
end_head3: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 80 | 0 | ▶ | sub end_head4 { $_[0]->emit_par(-1) } | ||||||||||
|
Subroutine
end_head4: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 81 | 0 | ▶ | sub end_Para { $_[0]->emit_par( 0) } | ||||||||||
|
Subroutine
end_Para: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 82 | 0 | ▶ | sub end_item_bullet { $_[0]->emit_par( 0) } | ||||||||||
|
Subroutine
end_item_bullet: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 83 | 0 | ▶ | sub end_item_number { $_[0]->emit_par( 0) } | ||||||||||
|
Subroutine
end_item_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 84 | 0 | ▶ | sub end_item_text { $_[0]->emit_par(-2) } | ||||||||||
|
Subroutine
end_item_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 85 | |||||||||||||
| 86 | 0 | ▶ | sub emit_par { | ||||||||||
|
Subroutine
emit_par: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 87 | 0 | ▶ | return unless $_[0]{'Errata_seen'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 88 | 0 | my($self, $tweak_indent) = splice(@_,0,2); | |||||||||||
| 89 | 0 | ▶ | my $length = 2 * $self->{'Indent'} + ($tweak_indent||0); | ||||||||||
|
Condition0%0/2
$tweak_indent || 0
MC/DC0%0/1
$tweak_indent || 0
$tweak_indent
Truth table0%0/2
A
A= $tweak_indent
| |||||||||||||
| 90 | 0 | ▶ | my $indent = ' ' x ($length > 0 ? $length : 0); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 91 | # Yes, 'STRING' x NEGATIVE gives '', same as 'STRING' x 0 | ||||||||||||
| 92 | # 'Negative repeat count does nothing' since 5.22 | ||||||||||||
| 93 | |||||||||||||
| 94 | 0 | $self->{'Thispara'} =~ s/$Pod::Simple::shy//g; | |||||||||||
| 95 | 0 | local $Text::Wrap::wrap = 'overflow'; | |||||||||||
| 96 | 0 | my $out = Text::Wrap::wrap($indent, $indent, $self->{'Thispara'} .= "\n"); | |||||||||||
| 97 | 0 | $out =~ s/$Pod::Simple::nbsp/ /g; | |||||||||||
| 98 | 0 | print {$self->{'output_fh'}} $out, | |||||||||||
| 99 | #"\n" | ||||||||||||
| 100 | ; | ||||||||||||
| 101 | 0 | $self->{'Thispara'} = ''; | |||||||||||
| 102 | |||||||||||||
| 103 | 0 | return; | |||||||||||
| 104 | } | ||||||||||||
| 105 | |||||||||||||
| 106 | # . . . . . . . . . . And then off by its lonesome: | ||||||||||||
| 107 | |||||||||||||
| 108 | 0 | ▶ | sub end_Verbatim { | ||||||||||
|
Subroutine
end_Verbatim: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 109 | 0 | ▶ | return unless $_[0]{'Errata_seen'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 110 | 0 | my $self = shift; | |||||||||||
| 111 | 0 | $self->{'Thispara'} =~ s/$Pod::Simple::nbsp/ /g; | |||||||||||
| 112 | 0 | $self->{'Thispara'} =~ s/$Pod::Simple::shy//g; | |||||||||||
| 113 | |||||||||||||
| 114 | 0 | my $i = ' ' x ( 2 * $self->{'Indent'} + 4); | |||||||||||
| 115 | |||||||||||||
| 116 | 0 | $self->{'Thispara'} =~ s/^/$i/mg; | |||||||||||
| 117 | |||||||||||||
| 118 | 0 | print { $self->{'output_fh'} } '', | |||||||||||
| 119 | 0 | $self->{'Thispara'}, | |||||||||||
| 120 | "\n\n" | ||||||||||||
| 121 | ; | ||||||||||||
| 122 | 0 | $self->{'Thispara'} = ''; | |||||||||||
| 123 | 0 | return; | |||||||||||
| 124 | } | ||||||||||||
| 125 | |||||||||||||
| 126 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||||||||||
| 127 | 1 | 1; | |||||||||||
| 128 | |||||||||||||
| 129 | __END__ | ||||||||||||