summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Pod/Html.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Pod/Html.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/Pod/Html.pm31
1 files changed, 26 insertions, 5 deletions
diff --git a/Master/tlpkg/tlperl/lib/Pod/Html.pm b/Master/tlpkg/tlperl/lib/Pod/Html.pm
index 71555e723ca..ba0ab0b39ac 100644
--- a/Master/tlpkg/tlperl/lib/Pod/Html.pm
+++ b/Master/tlpkg/tlperl/lib/Pod/Html.pm
@@ -2,7 +2,7 @@ package Pod::Html;
use strict;
require Exporter;
-our $VERSION = 1.25;
+our $VERSION = 1.27;
our @ISA = qw(Exporter);
our @EXPORT = qw(pod2html htmlify);
our @EXPORT_OK = qw(anchorify relativize_url);
@@ -16,6 +16,7 @@ use File::Spec::Unix;
use Getopt::Long;
use Pod::Simple::Search;
use Pod::Simple::SimpleTree ();
+use Text::Tabs;
use locale; # make \w work right in non-ASCII lands
=head1 NAME
@@ -257,8 +258,6 @@ my %Pages = (); # associative array used to find the location
my $Curdir = File::Spec->curdir;
-init_globals();
-
sub init_globals {
$Cachedir = "."; # The directory to which directory caches
# will be written.
@@ -367,6 +366,9 @@ sub pod2html {
# set options for input parser
my $parser = Pod::Simple::SimpleTree->new;
+ # Normalize whitespace indenting
+ $parser->strip_verbatim_indent(\&trim_leading_whitespace);
+
$parser->codes_in_verbatim(0);
$parser->accept_targets(qw(html HTML));
$parser->no_errata_section(!$Poderrors); # note the inverse
@@ -579,13 +581,12 @@ my $Saved_Cache_Key;
sub get_cache {
my($dircache, $podpath, $podroot, $recurse) = @_;
- my @cache_key_args = @_;
# A first-level cache:
# Don't bother reading the cache files if they still apply
# and haven't changed since we last read them.
- my $this_cache_key = cache_key(@cache_key_args);
+ my $this_cache_key = cache_key($dircache, $podpath, $podroot, $recurse);
return 1 if $Saved_Cache_Key and $this_cache_key eq $Saved_Cache_Key;
$Saved_Cache_Key = $this_cache_key;
@@ -842,4 +843,24 @@ sub relativize_url {
return $rel_path;
}
+# Remove any level of indentation (spaces or tabs) from each code block consistently
+# Adapted from: https://metacpan.org/source/HAARG/MetaCPAN-Pod-XHTML-0.002001/lib/Pod/Simple/Role/StripVerbatimIndent.pm
+sub trim_leading_whitespace {
+ my ($para) = @_;
+
+ # Start by converting tabs to spaces
+ @$para = Text::Tabs::expand(@$para);
+
+ # Find the line with the least amount of indent, as that's our "base"
+ my @indent_levels = (sort(map { $_ =~ /^( *)./mg } @$para));
+ my $indent = $indent_levels[0] || "";
+
+ # Remove the "base" amount of indent from each line
+ foreach (@$para) {
+ $_ =~ s/^\Q$indent//mg;
+ }
+
+ return;
+}
+
1;