diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-09-28 16:01:01 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-09-29 11:12:38 +0100 |
commit | ea6a18807a96ca23333934a286429145ae29eea4 (patch) | |
tree | 702872b60c6cc84f9b39c6ae95a340666aee32c4 /dist | |
parent | 1996665eb2c109625e05a30baf70adf11570e7e1 (diff) | |
download | perl-ea6a18807a96ca23333934a286429145ae29eea4.tar.gz |
Move Pod::Plainer from ext/ to dist/
Diffstat (limited to 'dist')
-rw-r--r-- | dist/Pod-Plainer/Plainer.pm | 70 | ||||
-rw-r--r-- | dist/Pod-Plainer/t/plainer.t | 55 |
2 files changed, 125 insertions, 0 deletions
diff --git a/dist/Pod-Plainer/Plainer.pm b/dist/Pod-Plainer/Plainer.pm new file mode 100644 index 0000000000..f64eb601ed --- /dev/null +++ b/dist/Pod-Plainer/Plainer.pm @@ -0,0 +1,70 @@ +package Pod::Plainer; +use strict; +use if $] >= 5.011, 'deprecate'; +use Pod::Parser; +our @ISA = qw(Pod::Parser); +our $VERSION = '1.00'; + +our %E = qw( < lt > gt ); + +sub escape_ltgt { + (undef, my $text) = @_; + $text =~ s/([<>])/E<$E{$1}>/g; + $text +} + +sub simple_delimiters { + (undef, my $seq) = @_; + $seq -> left_delimiter( '<' ); + $seq -> right_delimiter( '>' ); + $seq; +} + +sub textblock { + my($parser,$text,$line) = @_; + print {$parser->output_handle()} + $parser->parse_text( + { -expand_text => q(escape_ltgt), + -expand_seq => q(simple_delimiters) }, + $text, $line ) -> raw_text(); +} + +1; + +__END__ + +=head1 NAME + +Pod::Plainer - Perl extension for converting Pod to old-style Pod. + +=head1 SYNOPSIS + + use Pod::Plainer; + + my $parser = Pod::Plainer -> new (); + $parser -> parse_from_filehandle(\*STDIN); + +=head1 DESCRIPTION + +Pod::Plainer uses Pod::Parser which takes Pod with the (new) +'CE<lt>E<lt> .. E<gt>E<gt>' constructs +and returns the old(er) style with just 'CE<lt>E<gt>'; +'<' and '>' are replaced by 'EE<lt>ltE<gt>' and 'EE<lt>gtE<gt>'. + +This can be used to pre-process Pod before using tools which do not +recognise the new style Pods. + +=head2 EXPORT + +None by default. + +=head1 AUTHOR + +Robin Barker, rmb1@npl.co.uk + +=head1 SEE ALSO + +See L<Pod::Parser>. + +=cut + diff --git a/dist/Pod-Plainer/t/plainer.t b/dist/Pod-Plainer/t/plainer.t new file mode 100644 index 0000000000..c6f178a253 --- /dev/null +++ b/dist/Pod-Plainer/t/plainer.t @@ -0,0 +1,55 @@ +#!./perl + +use Pod::Plainer; +my $parser = Pod::Plainer->new(); +my $header = "=pod\n\n"; +my $input = 'plnr_in.pod'; +my $output = 'plnr_out.pod'; + +my $test = 0; +print "1..7\n"; +while( <DATA> ) { + my $expected = $header.<DATA>; + + open(IN, '>', $input) or die $!; + print IN $header, $_; + close IN or die $!; + + open IN, '<', $input or die $!; + open OUT, '>', $output or die $!; + $parser->parse_from_filehandle(\*IN,\*OUT); + + open OUT, '<', $output or die $!; + my $returned; { local $/; $returned = <OUT>; } + + unless( $returned eq $expected ) { + print map { s/^/\#/mg; $_; } + map {+$_} # to avoid readonly values + "EXPECTED:\n", $expected, "GOT:\n", $returned; + print "not "; + } + printf "ok %d\n", ++$test; + close OUT; + close IN; +} + +END { + 1 while unlink $input; + 1 while unlink $output; +} + +__END__ +=head <> now reads in records +=head E<lt>E<gt> now reads in records +=item C<-T> and C<-B> not implemented on filehandles +=item C<-T> and C<-B> not implemented on filehandles +e.g. C<< Foo->bar() >> or C<< $obj->bar() >> +e.g. C<Foo-E<gt>bar()> or C<$obj-E<gt>bar()> +The C<< => >> operator is mostly just a more visually distinctive +The C<=E<gt>> operator is mostly just a more visually distinctive +C<uv < 0x80> in which case you can use C<*s = uv>. +C<uv E<lt> 0x80> in which case you can use C<*s = uv>. +C<time ^ ($$ + ($$ << 15))>), but that isn't necessary any more. +C<time ^ ($$ + ($$ E<lt>E<lt> 15))>), but that isn't necessary any more. +The bitwise operation C<<< >> >>> +The bitwise operation C<E<gt>E<gt>> |