diff options
Diffstat (limited to 'pod/pod2latex.PL')
-rw-r--r-- | pod/pod2latex.PL | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/pod/pod2latex.PL b/pod/pod2latex.PL index 34b1faadba..3d0b55b32f 100644 --- a/pod/pod2latex.PL +++ b/pod/pod2latex.PL @@ -12,10 +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 ($^O eq 'VMS' or $^O 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: $!"; @@ -25,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. @@ -124,11 +123,21 @@ open(LATEX,">$pod.tex"); &do_hdr(); $cutting = 1; +$begun = ""; while (<POD>) { 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; @@ -146,6 +155,22 @@ while (<POD>) { 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*//; @@ -500,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 { @@ -513,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>"; |