Misc. doc patches missing in _20
[p5sagit/p5-mst-13.2.git] / pod / pod2html.PL
index aee400d..b97c00c 100644 (file)
@@ -15,8 +15,7 @@ use File::Basename qw(&basename &dirname);
 chdir(dirname($0));
 ($file = basename($0)) =~ s/\.PL$//;
 $file =~ s/\.pl$//
-       if ($Config{'osname'} eq 'VMS' or
-           $Config{'osname'} eq 'OS2');  # "case-forgiving"
+       if ($^O eq 'VMS' or $^O eq 'os2');  # "case-forgiving"
 
 open OUT,">$file" or die "Can't create $file: $!";
 
@@ -26,14 +25,15 @@ print "Extracting $file (with variable substitutions)\n";
 # You can use $Config{...} to use Configure variables.
 
 print OUT <<"!GROK!THIS!";
-$Config{'startperl'}
+$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.
 
 print OUT <<'!NO!SUBS!';
-eval 'exec perl -S $0 ${1+"$@"}'
-        if $running_under_some_shell;
+
 #
 # pod2html - convert pod format to html
 # Version 1.15
@@ -99,9 +99,9 @@ unless (@Pods) {
 
 # loop twice through the pods, first to learn the links, then to produce html
 for $count (0,1) {
-    print STTDER "Scanning pods...\n" unless $count;
+    print STDERR "Scanning pods...\n" unless $count;
     foreach $podfh ( @Pods ) {
-       ($pod = $podfh) =~ s/\.pod$//;
+       ($pod = $podfh) =~ s/\.(?:pod|pm)$//;
        Debug("files", "opening 2 $podfh" );
        print "Creating $pod.html from $podfh\n" if $count;
        $RS = "\n=";         # grok pods by item (Nonstandard but effecient)
@@ -119,8 +119,9 @@ for $count (0,1) {
            open(HTML,">$html") || die "can't create $html: $ERRNO";
            print HTML '<!-- $Id$ -->',"\n",'<HTML><HEAD>',"\n";
            print HTML "<CENTER>" unless $NO_NS;
-           print HTML "<TITLE>$pod</TITLE>\n</HEAD>\n<BODY>";
+           print HTML "<TITLE>$pod</TITLE>";
            print HTML "</CENTER>" unless $NO_NS;
+           print HTML "\n</HEAD>\n<BODY>";
        }
        for ($i = 0; $i <= $#all; $i++) {       # decide what to do with each chunk
            $all[$i] =~ /^(\w+)\s*(.*)\n?([^\0]*)$/ ;
@@ -152,7 +153,7 @@ for $count (0,1) {
                if ($count) {  # producing html
                    ($depth) or next; # just skip it
                    do_list("back",$all[$i+1],\$in_list,\$depth);
-                   do_rest("$title.$rest");
+                   do_rest($title.$rest);
                }
            }
            elsif ($cmd =~ /^cut/) {
@@ -162,7 +163,7 @@ for $count (0,1) {
                 if ($count) {  # producing html
                     if ($title =~ s/^html//) {
                         $in_html =1;
-                        do_rest("$title.$rest");
+                        do_rest($title.$rest);
                     }
                 }
             }
@@ -323,6 +324,7 @@ sub scan_thing{           # scan a chunk for later references
     my($cmd,$title,$pod) = @_;
     $_ = $title;
     s/\n$//;
+    s/E<(\d+)>/&#$1;/g;
     s/E<(.*?)>/&$1;/g;
     # remove any formatting information for the headers
     s/[SFCBI]<(.*?)>/$1/g;         
@@ -379,7 +381,7 @@ sub picrefs {
            } 
        } 
        if (length($key)) {
-            ($pod2,$num) = split(/_/,$value,2);
+            ($pod2, $num) = $value =~ /^(.*)_(\S+_\d+)$/;
            if ($htype eq "NAME") {  
                return "\n<A NAME=\"".$value."\">\n$bigkey</A>\n"
            }
@@ -502,10 +504,12 @@ sub gensym {
 sub pre_escapes {  # twiddle these, and stay up late  :-)
     my($thing) = @_;
     for ($$thing) { 
+    s/([\200-\377])/noremap("&".ord($1).";")/ge;
        s/"(.*?)"/``$1''/gs;
        s/&/noremap("&amp;")/ge;
        s/<</noremap("&lt;&lt;")/eg;
        s/([^ESIBLCF])</$1\&lt\;/g;
+       s/E<(\d+)>/\&#$1\;/g;                     # embedded numeric special
        s/E<([^\/][^<>]*)>/\&$1\;/g;              # embedded special
     }
 }