X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fpod2latex.PL;h=3d0b55b32f999ab6afb73126f60535b101ef2cfe;hb=4fc194b2052979cb8d28873cf62c0ce84cd214f5;hp=bd6df71c749d55c2a0e7ec1b203fecb186df73dc;hpb=4633a7c4bad06b471d9310620b7fe8ddd158cccd;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/pod2latex.PL b/pod/pod2latex.PL index bd6df71..3d0b55b 100644 --- a/pod/pod2latex.PL +++ b/pod/pod2latex.PL @@ -12,11 +12,9 @@ use File::Basename qw(&basename &dirname); # This forces PL files to create target in same directory as PL file. # This is so that make depend always knows where to find PL derivatives. -chdir(dirname($0)); -($file = basename($0)) =~ s/\.PL$//; -$file =~ s/\.pl$// - if ($Config{'osname'} eq 'VMS' or - $Config{'osname'} eq 'OS2'); # "case-forgiving" +chdir dirname($0); +$file = basename($0, '.PL'); +$file .= '.com' if $^O eq 'VMS'; open OUT,">$file" or die "Can't create $file: $!"; @@ -26,9 +24,9 @@ print "Extracting $file (with variable substitutions)\n"; # You can use $Config{...} to use Configure variables. print OUT <<"!GROK!THIS!"; -$Config{'startperl'} - eval 'exec perl -S \$0 "\$@"' - if 0; +$Config{startperl} + eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; !GROK!THIS! # In the following, perl variables are not expanded during extraction. @@ -125,11 +123,21 @@ open(LATEX,">$pod.tex"); &do_hdr(); $cutting = 1; +$begun = ""; while () { if ($cutting) { next unless /^=/; $cutting = 0; } + if ($begun) { + if (/^=end\s+$begun/) { + $begun = ""; + } + elsif ($begun =~ /^(tex|latex)$/) { + print LATEX $_; + } + next; + } chop; length || (print LATEX "\n") && next; @@ -147,6 +155,22 @@ while () { next; } + if (/^=for\s+(\S+)\s*/s) { + if ($1 eq "tex" or $1 eq "latex") { + print LATEX $',"\n"; + } else { + # ignore unknown for + } + next; + } + elsif (/^=begin\s+(\S+)\s*/s) { + $begun = $1; + if ($1 eq "tex" or $1 eq "latex") { + print LATEX $'."\n"; + } + next; + } + # preserve '=item' line with pod quotes as they are. if (/^=item/) { ($bareitem = $_) =~ s/^=item\s*//; @@ -501,9 +525,8 @@ sub noremap { } sub init_noremap { - if ( /[\200-\377]/ ) { - warn "hit bit char in input stream"; - } + # escape high bit characters in input stream + s/([\200-\377])/"E<".ord($1).">"/ge; } sub clear_noremap { @@ -514,11 +537,14 @@ sub clear_noremap { sub expand_HTML_escapes { local($s) = $_[0]; - $s =~ s { E<([A-Za-z]+)> } + $s =~ s { E<((\d+)|([A-Za-z]+))> } { do { - exists $HTML_Escapes{$1} - ? do { $HTML_Escapes{$1} } + defined($2) + ? do { chr($2) } + : + exists $HTML_Escapes{$3} + ? do { $HTML_Escapes{$3} } : do { warn "Unknown escape: $& in $_"; "E<$1>";