From: Gurusamy Sarathy Date: Wed, 8 Mar 2000 12:41:38 +0000 (+0000) Subject: shore up pod2latex shortcomings, and a Pod::Parser fix (from X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d23ed1f2ad4fab0ab337e1558f4157d663b72860;p=p5sagit%2Fp5-mst-13.2.git shore up pod2latex shortcomings, and a Pod::Parser fix (from Robin Barker) p4raw-id: //depot/perl@5612 --- diff --git a/MANIFEST b/MANIFEST index 3701f0c..f8ea07a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -641,6 +641,7 @@ lib/Pod/InputObjects.pm Pod-Parser - define objects for input streams lib/Pod/Man.pm Convert POD data to *roff lib/Pod/ParseUtils.pm Pod-Parser - pod utility functions lib/Pod/Parser.pm Pod-Parser - define base class for parsing POD +lib/Pod/Plainer.pm Pod migration utility module lib/Pod/Select.pm Pod-Parser - select portions of POD docs lib/Pod/Text.pm Pod-Parser - convert POD data to formatted ASCII text lib/Pod/Text/Color.pm Convert POD data to color ASCII text diff --git a/lib/Pod/Parser.pm b/lib/Pod/Parser.pm index 9ad5d16..88d9aa7 100644 --- a/lib/Pod/Parser.pm +++ b/lib/Pod/Parser.pm @@ -956,8 +956,7 @@ sub parse_paragraph { ## and whatever sequence of characters was used to separate them $pfx = $1; $_ = substr($text, length $pfx); - $sep = /(\s+)(?=\S)/ ? $1 : ''; - ($cmd, $text) = split(" ", $_, 2); + ($cmd, $sep, $text) = split /(\s+)/, $_, 2; ## If this is a "cut" directive then we dont need to do anything ## except return to "cutting" mode. if ($cmd eq 'cut') { diff --git a/lib/Pod/Plainer.pm b/lib/Pod/Plainer.pm new file mode 100644 index 0000000..373e8d0 --- /dev/null +++ b/lib/Pod/Plainer.pm @@ -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) +'CEE .. EE' constructs +and returns the old(er) style with just 'CEE'; +'<' and '>' are replaced by 'EEltE' and 'EEgtE'. + +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. + +=cut + diff --git a/pod/pod2latex.PL b/pod/pod2latex.PL index feed98e..71115f3 100644 --- a/pod/pod2latex.PL +++ b/pod/pod2latex.PL @@ -101,7 +101,6 @@ print OUT <<'!NO!SUBS!'; # Translation of HTML escapes of various European accents might be wrong. -$/ = ""; # record separator is blank lines # TeX special characters. ##$tt_ables = "!@*()-=+|;:'\"`,./?<>"; $backslash_escapables = "#\$%&{}_"; @@ -119,13 +118,16 @@ $indent = 0; # 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(); $cutting = 1; $begun = ""; +$/ = ""; # record separator is blank lines while () { if ($cutting) { next unless /^=/; @@ -314,6 +316,8 @@ while () { } }gex; + s/X<([^<>]*)>/\\index{$1}/g; + s/Z<>/\\&/g; # the "don't format me" thing # comes last because not subject to reprocessing @@ -416,7 +420,7 @@ while () { } print LATEX "\n\\begin{$listingcmd}\n"; push(@listingcmd,$listingcmd); - } elsif ($lastcmd ne 'item') { + } elsif ( !@listingcmd ) { warn "Illegal '=item' command without preceding 'over':"; warn "=item $bareitem"; }