X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FPod%2FHtml.pm;h=e8f9ff3fa5be47a609dc0a83a88edb243d2cdb56;hb=e69a2255d0db4d110e403864fcb97407ce8e4ff9;hp=91f78f6e03398aae12d03fd1106224ca2ad7dbb9;hpb=add5afb0e3c89e8b6e28a2a81d021fb15475e486;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Pod/Html.pm b/lib/Pod/Html.pm index 91f78f6..e8f9ff3 100644 --- a/lib/Pod/Html.pm +++ b/lib/Pod/Html.pm @@ -369,6 +369,25 @@ sub pod2html { $/ = ""; my @poddata = ; 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 @@ -407,7 +426,7 @@ sub pod2html { if ($title) { $title =~ s/\s*\(.*\)//; } else { - warn "$0: no title for $podfile" unless $quiet; + warn "$0: no title for $podfile.\n" unless $quiet; $podfile =~ /^(.*)(\.[^.\/]+)?\z/s; $title = ($podfile eq "-" ? 'No Title' : $1); warn "using $title" if $verbose; @@ -492,8 +511,6 @@ END_OF_HEAD if (/^=(head[1-6])\s+(.*\S)/s) { # =head[1-6] heading process_head( $1, $2, $doindex && $index ); } elsif (/^=item\s*(.*\S)?/sm) { # =item text - warn "$0: $podfile: =item without bullet, number or text" - . " in paragraph $paragraph.\n" if !defined($1) or $1 eq ''; $need_dd = process_item( $1 ); $after_item = 1; } elsif (/^=over\s*(.*)/) { # =over N @@ -1055,8 +1072,7 @@ sub process_head { print HTML "

\n"; } - my $name = htmlify( depod( $heading ) ); - $name =~ s/\s/_/g; # htmlify keeps spaces but we don't want them here... + my $name = anchorify( depod( $heading ) ); my $convert = process_text( \$heading ); print HTML "$convert\n"; } @@ -1079,8 +1095,8 @@ sub emit_item_tag($$$){ if ($items_named{$item}++) { print HTML process_text( \$otext ); } else { - my $name = 'item_' . $item; - $name =~ s/\s/_/g; # we don't want spaces here... + my $name = 'item_' . $item; + $name = anchorify($name); print HTML qq{}, process_text( \$otext ), ''; } print HTML "
\n"; @@ -1258,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; @@ -1595,7 +1611,7 @@ sub process_text1($$;$$){ # warning; show some text. $linktext = $opar unless defined $linktext; - warn "$0: $podfile: cannot resolve L<$opar> in paragraph $paragraph."; + warn "$0: $podfile: cannot resolve L<$opar> in paragraph $paragraph.\n"; } # now we have a URL or just plain code @@ -1617,7 +1633,7 @@ sub process_text1($$;$$){ } elsif( $func eq 'Z' ){ # Z<> - empty - warn "$0: $podfile: invalid X<> in paragraph $paragraph." + warn "$0: $podfile: invalid X<> in paragraph $paragraph.\n" unless $$rstr =~ s/^>//; } else { @@ -1636,7 +1652,7 @@ sub process_text1($$;$$){ if( $lev == 1 ){ $res .= pure_text( $$rstr ); } else { - warn "$0: $podfile: undelimited $func<> in paragraph $paragraph."; + warn "$0: $podfile: undelimited $func<> in paragraph $paragraph.\n"; } } return $res; @@ -1660,7 +1676,7 @@ sub go_ahead($$$){ } $res .= $2; } - warn "$0: $podfile: undelimited $func<> in paragraph $paragraph."; + warn "$0: $podfile: undelimited $func<> in paragraph $paragraph.\n"; return $res; } @@ -1697,7 +1713,8 @@ sub html_escape { $rest =~ s//>/g; $rest =~ s/"/"/g; - $rest =~ s/'/'/g; + # ' is only in XHTML, not HTML4. Be conservative + #$rest =~ s/'/'/g; return $rest; } @@ -1733,7 +1750,7 @@ sub page_sect($$) { $page83=dosify($page); $page=$page83 if (defined $pages{$page83}); if ($page eq "") { - $link = "#" . htmlify( $section ); + $link = "#" . anchorify( $section ); } elsif ( $page =~ /::/ ) { $page =~ s,::,/,g; # Search page cache for an entry keyed under the html page name, @@ -1760,11 +1777,11 @@ sub page_sect($$) { } $link = "$htmlroot/$page.html"; - $link .= "#" . htmlify( $section ) if ($section); + $link .= "#" . anchorify( $section ) if ($section); } elsif (!defined $pages{$page}) { $link = ""; } else { - $section = htmlify( $section ) if $section ne ""; + $section = anchorify( $section ) if $section ne ""; ### print STDERR "...section=$section\n"; # if there is a directory by the name of the page, then assume that an @@ -1947,6 +1964,16 @@ sub htmlify { } # +# similar to htmlify, but turns spaces into underscores +# +sub anchorify { + my ($anchor) = @_; + $anchor = htmlify($anchor); + $anchor =~ s/\s/_/g; # fixup spaces left by htmlify + return $anchor; +} + +# # depod - convert text by eliminating all interior sequences # Note: can be called with copy or modify semantics #