From: Stas Bekman Date: Sun, 17 Mar 2002 02:11:26 +0000 (+0800) Subject: fix anchor generation code (ID 20020312.006) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0d396dd49649461b6bb1fd38d6f42743e0d6589f;p=p5sagit%2Fp5-mst-13.2.git fix anchor generation code (ID 20020312.006) Message-ID: p4raw-id: //depot/perl@15259 --- diff --git a/lib/Pod/Html.pm b/lib/Pod/Html.pm index 362b054..dd2f0bf 100644 --- a/lib/Pod/Html.pm +++ b/lib/Pod/Html.pm @@ -1055,8 +1055,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 +1078,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"; @@ -1733,7 +1732,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 +1759,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 +1946,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 #