3 package Pod::Simple::DumpAsText;
6 BEGIN {@ISA = ('Pod::Simple')}
12 BEGIN { *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG }
16 my $new = $self->SUPER::new(@_);
17 $new->{'output_fh'} ||= *STDOUT{IO};
18 $new->accept_codes('VerbatimFormatted');
22 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
24 sub _handle_element_start {
25 # ($self, $element_name, $attr_hash_r)
26 my $fh = $_[0]{'output_fh'};
28 DEBUG and print "++ $_[1]\n";
30 print $fh ' ' x ($_[0]{'indent'} || 0), "++", $_[1], "\n";
32 while(($key,$value) = each %{$_[2]}) {
33 unless($key =~ m/^~/s) {
34 next if $key eq 'start_line' and $_[0]{'hide_line_numbers'};
36 _perly_escape($value);
37 printf $fh qq{%s \\ "%s" => "%s"\n},
38 ' ' x ($_[0]{'indent'} || 0), $key, $value;
45 DEBUG and print "== \"$_[1]\"\n";
48 my $indent = ' ' x $_[0]{'indent'};
51 $text =~ # A not-totally-brilliant wrapping algorithm:
53 [^\n]{55} # Snare some characters from a line
54 [^\n\ ]{0,50} # and finish any current word
56 \x20{1,10}(?!\n) # capture some spaces not at line-end
57 /$1"\n$indent . "/gx # => line-break here
60 print {$_[0]{'output_fh'}} $indent, '* "', $text, "\"\n";
65 sub _handle_element_end {
66 DEBUG and print "-- $_[1]\n";
67 print {$_[0]{'output_fh'}}
68 ' ' x --$_[0]{'indent'}, "--", $_[1], "\n";
72 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
76 $x =~ s/([^\x00-\xFF])/sprintf'\x{%X}',ord($1)/eg;
77 # Escape things very cautiously:
78 $x =~ s/([^-\n\t \&\<\>\'!\#\%\(\)\*\+,\.\/\:\;=\?\~\[\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/sprintf'\x%02X',ord($1)/eg;
83 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
91 Pod::Simple::DumpAsText -- dump Pod-parsing events as text
95 perl -MPod::Simple::DumpAsText -e \
96 "exit Pod::Simple::DumpAsText->filter(shift)->any_errata_seen" \
101 This class is for dumping, as text, the events gotten from parsing a Pod
102 document. This class is of interest to people writing Pod formatters
103 based on Pod::Simple. It is useful for seeing exactly what events you
104 get out of some Pod that you feed in.
106 This is a subclass of L<Pod::Simple> and inherits all its methods.
110 L<Pod::Simple::DumpAsXML>
114 =head1 COPYRIGHT AND DISCLAIMERS
116 Copyright (c) 2002 Sean M. Burke. All rights reserved.
118 This library is free software; you can redistribute it and/or modify it
119 under the same terms as Perl itself.
121 This program is distributed in the hope that it will be useful, but
122 without any warranty; without even the implied warranty of
123 merchantability or fitness for a particular purpose.
127 Sean M. Burke C<sburke@cpan.org>