diff options
author | Stas Bekman <stas@stason.org> | 2002-03-17 10:11:26 +0800 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-16 17:58:08 +0000 |
commit | 0d396dd49649461b6bb1fd38d6f42743e0d6589f (patch) | |
tree | 4d0372fc7f2721d2e851137a24b3eeb403d45c85 /lib | |
parent | 3a4b996c622ca8a2cd8d468317fb869865ee25b2 (diff) | |
download | perl-0d396dd49649461b6bb1fd38d6f42743e0d6589f.tar.gz |
fix anchor generation code (ID 20020312.006)
Message-ID: <Pine.LNX.4.44.0203170205130.16962-100000@hope.stason.org>
p4raw-id: //depot/perl@15259
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Pod/Html.pm | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/Pod/Html.pm b/lib/Pod/Html.pm index 362b054e3f..dd2f0bf439 100644 --- a/lib/Pod/Html.pm +++ b/lib/Pod/Html.pm @@ -1055,8 +1055,7 @@ sub process_head { print HTML "</p>\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 "<h$level><a name=\"$name\">$convert</a></h$level>\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{<a name="$name">}, process_text( \$otext ), '</a>'; } print HTML "</strong><br />\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 # |