2 # A quite dimwitted pod2plaintext that need only know how to format whatever
3 # text comes out of Pod::BlackBox's _gen_errata
6 package Pod::Simple::Checker;
9 use Pod::Simple::Methody ();
11 use vars qw( @ISA $VERSION );
13 @ISA = ('Pod::Simple::Methody');
14 BEGIN { *DEBUG = defined(&Pod::Simple::DEBUG)
15 ? \&Pod::Simple::DEBUG
19 use Text::Wrap 98.112902 (); # was 2001.0131, but I don't think we need that
20 $Text::Wrap::wrap = 'overflow';
21 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 sub any_errata_seen { # read-only accessor
24 return $_[1]->{'Errata_seen'};
29 my $new = $self->SUPER::new(@_);
30 $new->{'output_fh'} ||= *STDOUT{IO};
33 $new->{'Thispara'} = '';
35 $new->{'Indentstring'} = ' ';
36 $new->{'Errata_seen'} = 0;
40 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42 sub handle_text { $_[0]{'Errata_seen'} and $_[0]{'Thispara'} .= $_[1] }
44 sub start_Para { $_[0]{'Thispara'} = '' }
47 if($_[0]{'Errata_seen'}) {
48 $_[0]{'Thispara'} = '';
50 if($_[1]{'errata'}) { # start of errata!
51 $_[0]{'Errata_seen'} = 1;
52 $_[0]{'Thispara'} = $_[0]{'source_filename'} ?
53 "$_[0]{'source_filename'} -- " : ''
57 sub start_head2 { $_[0]{'Thispara'} = '' }
58 sub start_head3 { $_[0]{'Thispara'} = '' }
59 sub start_head4 { $_[0]{'Thispara'} = '' }
61 sub start_Verbatim { $_[0]{'Thispara'} = '' }
62 sub start_item_bullet { $_[0]{'Thispara'} = '* ' }
63 sub start_item_number { $_[0]{'Thispara'} = "$_[1]{'number'}. " }
64 sub start_item_text { $_[0]{'Thispara'} = '' }
66 sub start_over_bullet { ++$_[0]{'Indent'} }
67 sub start_over_number { ++$_[0]{'Indent'} }
68 sub start_over_text { ++$_[0]{'Indent'} }
69 sub start_over_block { ++$_[0]{'Indent'} }
71 sub end_over_bullet { --$_[0]{'Indent'} }
72 sub end_over_number { --$_[0]{'Indent'} }
73 sub end_over_text { --$_[0]{'Indent'} }
74 sub end_over_block { --$_[0]{'Indent'} }
77 # . . . . . Now the actual formatters:
79 sub end_head1 { $_[0]->emit_par(-4) }
80 sub end_head2 { $_[0]->emit_par(-3) }
81 sub end_head3 { $_[0]->emit_par(-2) }
82 sub end_head4 { $_[0]->emit_par(-1) }
83 sub end_Para { $_[0]->emit_par( 0) }
84 sub end_item_bullet { $_[0]->emit_par( 0) }
85 sub end_item_number { $_[0]->emit_par( 0) }
86 sub end_item_text { $_[0]->emit_par(-2) }
89 return unless $_[0]{'Errata_seen'};
90 my($self, $tweak_indent) = splice(@_,0,2);
91 my $indent = ' ' x ( 2 * $self->{'Indent'} + ($tweak_indent||0) );
92 # Yes, 'STRING' x NEGATIVE gives '', same as 'STRING' x 0
94 $self->{'Thispara'} =~ tr{\xAD}{}d if Pod::Simple::ASCII;
95 my $out = Text::Wrap::wrap($indent, $indent, $self->{'Thispara'} .= "\n");
96 $out =~ tr{\xA0}{ } if Pod::Simple::ASCII;
97 print {$self->{'output_fh'}} $out,
100 $self->{'Thispara'} = '';
105 # . . . . . . . . . . And then off by its lonesome:
108 return unless $_[0]{'Errata_seen'};
110 if(Pod::Simple::ASCII) {
111 $self->{'Thispara'} =~ tr{\xA0}{ };
112 $self->{'Thispara'} =~ tr{\xAD}{}d;
115 my $i = ' ' x ( 2 * $self->{'Indent'} + 4);
117 $self->{'Thispara'} =~ s/^/$i/mg;
119 print { $self->{'output_fh'} } '',
123 $self->{'Thispara'} = '';
127 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
134 Pod::Simple::Checker -- check the Pod syntax of a document
138 perl -MPod::Simple::Checker -e \
139 "exit Pod::Simple::Checker->filter(shift)->any_errata_seen" \
144 This class is for checking the syntactic validity of Pod.
145 It works by basically acting like a simple-minded version of
146 L<Pod::Simple::Text> that formats only the "Pod Errors" section
147 (if Pod::Simple even generates one for the given document).
149 This is a subclass of L<Pod::Simple> and inherits all its methods.
153 L<Pod::Simple>, L<Pod::Simple::Text>, L<Pod::Checker>
155 =head1 COPYRIGHT AND DISCLAIMERS
157 Copyright (c) 2002 Sean M. Burke. All rights reserved.
159 This library is free software; you can redistribute it and/or modify it
160 under the same terms as Perl itself.
162 This program is distributed in the hope that it will be useful, but
163 without any warranty; without even the implied warranty of
164 merchantability or fitness for a particular purpose.
168 Sean M. Burke C<sburke@cpan.org>