diff options
-rwxr-xr-x | Makefile.SH | 1 | ||||
-rw-r--r-- | ext/Pod-Html/lib/Pod/Html.pm | 19 | ||||
-rw-r--r-- | ext/Pod-Html/t/anchorify.t | 24 | ||||
-rw-r--r-- | installhtml | 14 |
4 files changed, 26 insertions, 32 deletions
diff --git a/Makefile.SH b/Makefile.SH index 7ddb23ed2d..8569955e57 100755 --- a/Makefile.SH +++ b/Makefile.SH @@ -1204,7 +1204,6 @@ install.html: all installhtml ${LOCAL_PERL} installhtml \\ --podroot=. --podpath=. --recurse \\ --htmldir=\$(privlib)/html \\ - --htmlroot=\$(privlib)/html \\ --splithead=pod/perlipc \\ --splititem=pod/perlfunc \\ --ignore=Porting/Maintainers.pm,Porting/pumpkin.pod,Porting/repository.pod \\ diff --git a/ext/Pod-Html/lib/Pod/Html.pm b/ext/Pod-Html/lib/Pod/Html.pm index 8f7999b835..4927a7c961 100644 --- a/ext/Pod-Html/lib/Pod/Html.pm +++ b/ext/Pod-Html/lib/Pod/Html.pm @@ -5,7 +5,7 @@ require Exporter; our $VERSION = 1.23; our @ISA = qw(Exporter); our @EXPORT = qw(pod2html htmlify); -our @EXPORT_OK = qw(anchorify); +our @EXPORT_OK = qw(anchorify relativize_url); use Carp; use Config; @@ -661,19 +661,12 @@ sub html_escape { # # htmlify - converts a pod section specification to a suitable section -# specification for HTML. Note that we keep spaces and special characters -# except ", ? (Netscape problem) and the hyphen (writer's problem...). +# specification for HTML. We adopt the mechanism used by the formatter +# that we use. # sub htmlify { my( $heading) = @_; - $heading =~ s/(\s+)/ /g; - $heading =~ s/\s+\Z//; - $heading =~ s/\A\s+//; - # The hyphen is a disgrace to the English language. - # $heading =~ s/[-"?]//g; - $heading =~ s/["?]//g; - $heading = lc( $heading ); - return $heading; + return Pod::Simple::XHTML->can("idify")->(undef, $heading, 1); } # @@ -801,7 +794,7 @@ sub resolve_pod_page_link { # then $self->htmlroot eq '' (by definition of htmlfileurl) so # $self->htmldir needs to be prepended to link to get the absolute path # that will be relativized - $url = relativize_url( + $url = Pod::Html::relativize_url( File::Spec::Unix->catdir(Pod::Html::_unixify($self->htmldir), $url), $self->htmlfileurl # already unixified ); @@ -810,6 +803,8 @@ sub resolve_pod_page_link { return $url . ".html$section"; } +package Pod::Html; + # # relativize_url - convert an absolute URL to one relative to a base URL. # Assumes both end in a filename. diff --git a/ext/Pod-Html/t/anchorify.t b/ext/Pod-Html/t/anchorify.t index d7b180818f..0677f9ed30 100644 --- a/ext/Pod-Html/t/anchorify.t +++ b/ext/Pod-Html/t/anchorify.t @@ -23,18 +23,18 @@ foreach $i (0..$#poddata) { $heads{anchorify($1)} = 1 if $poddata[$i] =~ /=head[1-6]\s+(.*)/; } my %expected = map { $_ => 1 } qw( - name - description - subroutine - error - method - has_a_wordspace - hastrailingwordspace - hasleadingwordspace - has_extra_internalwordspace - hasquotes - hasquestionmark - has_hyphen_and_space + NAME + DESCRIPTION + Subroutine + Error + Method + Has_A_Wordspace + HasTrailingWordspace + HasLeadingWordspace + Has_Extra_InternalWordspace + Has_Quotes + Has_QuestionMark + Has_Hyphen_And_Space ); is_deeply( \%heads, diff --git a/installhtml b/installhtml index 1b724c0c41..62e92fc806 100644 --- a/installhtml +++ b/installhtml @@ -7,7 +7,7 @@ use Config; # for config options in the makefile use File::Spec::Functions qw(rel2abs no_upwards); use Getopt::Long; # for command-line parsing use Cwd; -use Pod::Html 'anchorify'; +use Pod::Html 1.23 qw(anchorify relativize_url); =head1 NAME @@ -240,10 +240,10 @@ foreach my $dir (@splithead) { $/ = ""; my @data = (); while (<H>) { - last if /name="name"/i; + last if m!<h1 id="NAME">NAME</h1>!; $_ =~ s{href="#(.*)">}{ - my $url = "$pod/$1.html" ; - $url = Pod::Html::relativize_url( $url, "$file.html" ) + my $url = "$file/@{[anchorify(qq($1))]}.html" ; + $url = relativize_url( $url, "$file.html" ) if ( ! defined $Options{htmlroot} || $Options{htmlroot} eq '' ); "href=\"$url\">" ; }egi; @@ -254,7 +254,7 @@ foreach my $dir (@splithead) { # now rewrite the file open(H, '>', "$file.html") || die "$0: error opening $file.html for output: $!\n"; - print H "@data", "\n"; + print H @data, "</body>\n\n</html>\n\n\n"; close(H); } @@ -321,9 +321,9 @@ sub create_index { m#<h1 id="NAME">NAME</h1>\s*<p>\s*(\S+)\s+-\s+(\S.*?\S)</p>#); defined $lcp1 or die "$0: can't find NAME section in $dir/$file\n"; - my $url= "$pod/$file" ; + my $url= "$dir/$file" ; if ( ! defined $Options{htmlroot} || $Options{htmlroot} eq '' ) { - $url = Pod::Html::relativize_url( "$pod/$file", $html ) ; + $url = relativize_url( $url, $html ) ; } print HTML qq(<DT><A HREF="$url">); |