X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/df00c67262066411ebfc0f93c144a6d711bcf2a7..d52b7888e9c3eb0ccb038b7c44075ba28e8fefa6:/installhtml diff --git a/installhtml b/installhtml index 97c2079..5a76ba0 100755 --- a/installhtml +++ b/installhtml @@ -4,9 +4,10 @@ use strict; use Config; # for config options in the makefile +use File::Spec; use Getopt::Long; # for command-line parsing use Cwd; -use Pod::Html; +use Pod::Html 'anchorify'; =head1 NAME @@ -227,6 +228,7 @@ foreach my $dir (@splititem) { } foreach my $dir (@splithead) { + (my $pod = $dir) =~ s,^.*/,,; $dir .= ".pod" unless $dir =~ /(\.pod|\.pm)$/; # let pod2html create the file runpod2html($dir, 1); @@ -243,15 +245,15 @@ foreach my $dir (@splithead) { $/ = ""; my @data = (); while () { - last if /NAME=/; - $_ =~ s{HREF="#(.*)">}{ - my $url = "$file/$1.html" ; - $url = Pod::Html::relativize_url( $url, "$file.html" ) - if ( ! defined $Options{htmlroot} || $Options{htmlroot} eq '' ); - "HREF=\"$url\">" ; - }eg; + last if /name="name"/i; + $_ =~ s{href="#(.*)">}{ + my $url = "$pod/$1.html" ; + $url = Pod::Html::relativize_url( $url, "$file.html" ) + if ( ! defined $Options{htmlroot} || $Options{htmlroot} eq '' ); + "href=\"$url\">" ; + }egi; push @data, $_; - } + } close(H); # now rewrite the file @@ -292,15 +294,6 @@ sub parse_command_line { } -sub absolute_path { - my($cwd, $path) = @_; - return "$cwd/$path" unless $path =~ m:/:; - # add cwd if path is not already an absolute path - $path = "$cwd/$path" if (substr($path,0,1) ne '/'); - return $path; -} - - sub create_index { my($html, $dir) = @_; (my $pod = $dir) =~ s,^.*/,,; @@ -390,7 +383,8 @@ sub split_on_item { print "splitting files by item.\n" if $verbose && $#splititem >= 0; $pwd = getcwd(); - my $splitter = absolute_path($pwd, "$splitpod/splitpod"); + my $splitter = File::Spec->rel2abs("$splitpod/splitpod", $pwd); + my $perl = File::Spec->rel2abs($^X, $pwd); foreach my $pod (@splititem) { # figure out the directory to split into $pod =~ s,^([^/]*)$,/$1,; @@ -411,7 +405,7 @@ sub split_on_item { die "$0: error changing to directory $podroot/$dirname: $!\n"; die "$splitter not found. Use '-splitpod dir' option.\n" unless -f $splitter; - system("perl", $splitter, "../$filename") && + system($perl, $splitter, "../$filename") && warn "$0: error running '$splitter ../$filename'" ." from $podroot/$dirname"; } @@ -453,7 +447,7 @@ sub splitpod { # L<> links as necessary. my %heads = (); foreach $i (0..$#poddata) { - $heads{htmlize($1)} = 1 if $poddata[$i] =~ /=head[1-6]\s+(.*)/; + $heads{anchorify($1)} = 1 if $poddata[$i] =~ /=head[1-6]\s+(.*)/; } # create a directory of a similar name and store all the @@ -485,15 +479,15 @@ sub splitpod { # determine an appropriate filename (this must correspond with # what pod2html will try and guess) # $poddata[$i] =~ /^\s*=head[1-6]\s+(.*)/; - $file = "$dir/" . htmlize($section) . ".pod"; + $file = "$dir/" . anchorify($section) . ".pod"; # create the new .pod file print "\tcreating $poddir/$file\n" if $verbose; open(SPLITOUT, ">$poddir/$file") || die "$0: error opening $poddir/$file for output: $!\n"; $poddata[$i] =~ s,L<([^<>]*)>, - defined $heads{htmlize($1)} ? "L<$dir/$1>" : "L<$1>" - ,ge; + defined $heads{anchorify($1)} ? "L<$dir/$1>" : "L<$1>" + ,ge; print SPLITOUT $poddata[$i]."\n\n"; print SPLITOUT "=over 4\n\n"; print SPLITOUT "=item *\n\nBack to L<$dir/\"$prevsec\">\n\n" if $prevsec; @@ -605,5 +599,3 @@ sub runpod2html { "--infile=$podroot/$pod", "--outfile=$htmldir/$html"); die "$0: error running $pod2html: $!\n" if $?; } - -sub htmlize { htmlify(0, @_) }