Integrate macperl patch #16868.
[p5sagit/p5-mst-13.2.git] / lib / Pod / Html.pm
index 1ae81c9..e8f9ff3 100644 (file)
@@ -369,6 +369,25 @@ sub pod2html {
     $/ = "";
     my @poddata  = <POD>;
     close(POD);
+
+    # be eol agnostic
+    for (@poddata) {
+       if (/\r/) {
+           if (/\r\n/) {
+               @poddata = map { s/\r\n/\n/g;
+                                /\n\n/ ?
+                                    map { "$_\n\n" } split /\n\n/ :
+                                    $_ } @poddata;
+           } else {
+               @poddata = map { s/\r/\n/g;
+                                /\n\n/ ?
+                                    map { "$_\n\n" } split /\n\n/ :
+                                    $_ } @poddata;
+           }
+           last;
+       }
+    }
+
     clean_data( \@poddata );
 
     # scan the pod for =head[1-6] directives and build an index
@@ -1255,9 +1274,9 @@ sub process_pre {
     $rest = $$text;
 
     # insert spaces in place of tabs
-    $rest =~ s#.*#
-           my $line = $&;
-           1 while $line =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
+    $rest =~ s#(.+)#
+           my $line = $1;
+            1 while $line =~ s/(\t+)/' ' x ((length($1) * 8) - $-[0] % 8)/e;
            $line;
        #eg;
 
@@ -1694,7 +1713,8 @@ sub html_escape {
     $rest   =~ s/</&lt;/g;
     $rest   =~ s/>/&gt;/g;
     $rest   =~ s/"/&quot;/g;
-    $rest   =~ s/'/&apos;/g;
+    # &apos; is only in XHTML, not HTML4.  Be conservative
+    #$rest   =~ s/'/&apos;/g;
     return $rest;
 }