3 package Pod::Simple::Text;
6 use Pod::Simple::Methody ();
8 use vars qw( @ISA $VERSION $FREAKYMODE);
10 @ISA = ('Pod::Simple::Methody');
11 BEGIN { *DEBUG = defined(&Pod::Simple::DEBUG)
12 ? \&Pod::Simple::DEBUG
16 use Text::Wrap 98.112902 ();
17 $Text::Wrap::wrap = 'overflow';
18 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 my $new = $self->SUPER::new(@_);
23 $new->{'output_fh'} ||= *STDOUT{IO};
24 $new->accept_target_as_text(qw( text plaintext plain ));
27 $new->{'Thispara'} = '';
29 $new->{'Indentstring'} = ' ';
33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 sub handle_text { $_[0]{'Thispara'} .= $_[1] }
37 sub start_Para { $_[0]{'Thispara'} = '' }
38 sub start_head1 { $_[0]{'Thispara'} = '' }
39 sub start_head2 { $_[0]{'Thispara'} = '' }
40 sub start_head3 { $_[0]{'Thispara'} = '' }
41 sub start_head4 { $_[0]{'Thispara'} = '' }
43 sub start_Verbatim { $_[0]{'Thispara'} = '' }
44 sub start_item_bullet { $_[0]{'Thispara'} = $FREAKYMODE ? '' : '* ' }
45 sub start_item_number { $_[0]{'Thispara'} = $FREAKYMODE ? '' : "$_[1]{'number'}. " }
46 sub start_item_text { $_[0]{'Thispara'} = '' }
48 sub start_over_bullet { ++$_[0]{'Indent'} }
49 sub start_over_number { ++$_[0]{'Indent'} }
50 sub start_over_text { ++$_[0]{'Indent'} }
51 sub start_over_block { ++$_[0]{'Indent'} }
53 sub end_over_bullet { --$_[0]{'Indent'} }
54 sub end_over_number { --$_[0]{'Indent'} }
55 sub end_over_text { --$_[0]{'Indent'} }
56 sub end_over_block { --$_[0]{'Indent'} }
59 # . . . . . Now the actual formatters:
61 sub end_head1 { $_[0]->emit_par(-4) }
62 sub end_head2 { $_[0]->emit_par(-3) }
63 sub end_head3 { $_[0]->emit_par(-2) }
64 sub end_head4 { $_[0]->emit_par(-1) }
65 sub end_Para { $_[0]->emit_par( 0) }
66 sub end_item_bullet { $_[0]->emit_par( 0) }
67 sub end_item_number { $_[0]->emit_par( 0) }
68 sub end_item_text { $_[0]->emit_par(-2) }
71 my($self, $tweak_indent) = splice(@_,0,2);
72 my $indent = ' ' x ( 2 * $self->{'Indent'} + 4 + ($tweak_indent||0) );
73 # Yes, 'STRING' x NEGATIVE gives '', same as 'STRING' x 0
75 $self->{'Thispara'} =~ tr{\xAD}{}d if Pod::Simple::ASCII;
76 my $out = Text::Wrap::wrap($indent, $indent, $self->{'Thispara'} .= "\n");
77 $out =~ tr{\xA0}{ } if Pod::Simple::ASCII;
78 print {$self->{'output_fh'}} $out, "\n";
79 $self->{'Thispara'} = '';
84 # . . . . . . . . . . And then off by its lonesome:
88 if(Pod::Simple::ASCII) {
89 $self->{'Thispara'} =~ tr{\xA0}{ };
90 $self->{'Thispara'} =~ tr{\xAD}{}d;
93 my $i = ' ' x ( 2 * $self->{'Indent'} + 4);
94 #my $i = ' ' x (4 + $self->{'Indent'});
96 $self->{'Thispara'} =~ s/^/$i/mg;
98 print { $self->{'output_fh'} } '',
102 $self->{'Thispara'} = '';
106 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
114 Pod::Simple::Text -- format Pod as plaintext
118 perl -MPod::Simple::Text -e \
119 "exit Pod::Simple::Text->filter(shift)->any_errata_seen" \
124 This class is a formatter that takes Pod and renders it as
127 Its wrapping is done by L<Text::Wrap>, so you can change
128 C<$Text::Wrap::columns> as you like.
130 This is a subclass of L<Pod::Simple> and inherits all its methods.
134 L<Pod::Simple>, L<Pod::Simple::TextContent>, L<Pod::Text>
136 =head1 COPYRIGHT AND DISCLAIMERS
138 Copyright (c) 2002 Sean M. Burke. All rights reserved.
140 This library is free software; you can redistribute it and/or modify it
141 under the same terms as Perl itself.
143 This program is distributed in the hope that it will be useful, but
144 without any warranty; without even the implied warranty of
145 merchantability or fitness for a particular purpose.
149 Sean M. Burke C<sburke@cpan.org>