develooper Front page | perl.perl5.porters | Postings from March 2000

[PATCH perl-5.5.670/pod/pod2latex.PL] using new style pod

From:
Robin Barker
Date:
March 6, 2000 12:13
Subject:
[PATCH perl-5.5.670/pod/pod2latex.PL] using new style pod
Message ID:
200003061943.TAA23892@tempest.npl.co.uk
Not sure if this the right approach but here goes.

pod/pod2latex does not recognise new style C<<...>> pod stuff.

I can't see how to update it, so I used Pod::Parser to convert
new style pod to old style pod.  I have created a module 
Pod::Plainer to do this, because it might be generally useful;
otherwise lib/Pod/Plainer.pm could be included in pod/pod2latex.

Robin

--- pod/pod2latex.PL	2000/03/06 19:09:34	1.1
+++ pod/pod2latex.PL	2000/03/06 19:35:10	1.2
@@ -119,7 +119,9 @@
 
 # parse the pods, produce LaTeX.
 
-open(POD,"<$ARGV[0]") || die "cant open $ARGV[0]";
+use Pod::Plainer;
+open(POD,"-|") or Pod::Plainer -> new() -> parse_from_file($ARGV[0]), exit;
+
 ($pod=$ARGV[0]) =~ s/\.pod$//;
 open(LATEX,">$pod.tex");
 &do_hdr();
--- lib/Pod/Plainer.pm	2000/03/06 19:10:06	1.1
+++ lib/Pod/Plainer.pm	2000/03/06 19:35:10	1.2
@@ -0,0 +1,69 @@
+package Pod::Plainer;
+use strict;
+use Pod::Parser;
+our @ISA = qw(Pod::Parser);
+our $VERSION = '0.01';
+
+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@cise.npl.co.uk
+
+=head1 SEE ALSO
+
+See L<Pod::Parser>.
+
+=cut
+

-- 
Robin Barker                        | Eail:  Robin.Barker@npl.co.uk
CISE, Building 10,                  | Phone: +44 (0) 20 8943 7090
National Physical Laboratory,       | Fax:   +44 (0) 20 8977 7091
Teddington, Middlesex, UK. TW11 OLW | WWW:   http://www.npl.co.uk



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About