summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E Keenan <jkeenan@cpan.org>2021-03-16 21:52:12 +0000
committerJames E Keenan <jkeenan@cpan.org>2021-07-06 01:08:03 +0000
commit8bb63676d3ee2ba429cc110c534beb95eca613bf (patch)
tree783f1d5e22effc0bd1500acbf3d451286d608493
parentc97f73fe8db20adb57725eac1957667c9036399b (diff)
downloadperl-8bb63676d3ee2ba429cc110c534beb95eca613bf.tar.gz
Introduce internal sub refine_globals()
Encapsulate! Encapsulate! Signed-off-by: James E Keenan <jkeenan@cpan.org>
-rw-r--r--ext/Pod-Html/lib/Pod/Html.pm44
1 files changed, 25 insertions, 19 deletions
diff --git a/ext/Pod-Html/lib/Pod/Html.pm b/ext/Pod-Html/lib/Pod/Html.pm
index 118812bf76..69c416798c 100644
--- a/ext/Pod-Html/lib/Pod/Html.pm
+++ b/ext/Pod-Html/lib/Pod/Html.pm
@@ -275,25 +275,7 @@ sub pod2html {
my $globals = init_globals();
$globals = parse_command_line($globals);
-
- # prevent '//' in urls
- $globals->{Htmlroot} = "" if $globals->{Htmlroot} eq "/";
- $globals->{Htmldir} =~ s#/\z##;
-
- if ( $globals->{Htmlroot} eq ''
- && defined( $globals->{Htmldir} )
- && $globals->{Htmldir} ne ''
- && substr( $globals->{Htmlfile}, 0, length( $globals->{Htmldir} ) ) eq $globals->{Htmldir}
- ) {
- # Set the 'base' url for this file, so that we can use it
- # as the location from which to calculate relative links
- # to other files. If this is '', then absolute links will
- # be used throughout.
- #$globals->{Htmlfileurl} = "$globals->{Htmldir}/" . substr( $globals->{Htmlfile}, length( $globals->{Htmldir} ) + 1);
- # Is the above not just "$globals->{Htmlfileurl} = $globals->{Htmlfile}"?
- $globals->{Htmlfileurl} = unixify($globals->{Htmlfile});
-
- }
+ $globals = refine_globals($globals);
# load or generate/cache %Pages
unless (get_cache($globals)) {
@@ -430,6 +412,30 @@ HTMLFOOT
write_file($globals, $output);
}
+sub refine_globals {
+ my $globals = shift;
+ require Data::Dumper if $globals->{verbose};
+
+ # prevent '//' in urls
+ $globals->{Htmlroot} = "" if $globals->{Htmlroot} eq "/";
+ $globals->{Htmldir} =~ s#/\z##;
+
+ if ( $globals->{Htmlroot} eq ''
+ && defined( $globals->{Htmldir} )
+ && $globals->{Htmldir} ne ''
+ && substr( $globals->{Htmlfile}, 0, length( $globals->{Htmldir} ) ) eq $globals->{Htmldir}
+ ) {
+ # Set the 'base' url for this file, so that we can use it
+ # as the location from which to calculate relative links
+ # to other files. If this is '', then absolute links will
+ # be used throughout.
+ #$globals->{Htmlfileurl} = "$globals->{Htmldir}/" . substr( $globals->{Htmlfile}, length( $globals->{Htmldir} ) + 1);
+ # Is the above not just "$globals->{Htmlfileurl} = $globals->{Htmlfile}"?
+ $globals->{Htmlfileurl} = unixify($globals->{Htmlfile});
+ }
+ return $globals;
+}
+
sub parse_input_for_podtree {
my ($globals, $input) = @_;
# set options for input parser