diff options
author | Scott Baker <scott@perturb.org> | 2020-08-03 16:39:00 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-11-03 18:09:18 -0700 |
commit | bffa3370b3914606c36234afe43462fca37fcada (patch) | |
tree | 2b7a4625b3293410d3b7372e8d457c7b3b9da2cc /ext/Pod-Html/lib | |
parent | 57d967160766d88e73c4ec88a67e29edf79e0a67 (diff) | |
download | perl-bffa3370b3914606c36234afe43462fca37fcada.tar.gz |
Use Text::Tabs to convert tabs to spaces instead
Diffstat (limited to 'ext/Pod-Html/lib')
-rw-r--r-- | ext/Pod-Html/lib/Pod/Html.pm | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/ext/Pod-Html/lib/Pod/Html.pm b/ext/Pod-Html/lib/Pod/Html.pm index 100f537ed1..b8f526faa3 100644 --- a/ext/Pod-Html/lib/Pod/Html.pm +++ b/ext/Pod-Html/lib/Pod/Html.pm @@ -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 @@ -848,19 +849,11 @@ sub relativize_url { # 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) = @_; - my $tab_width = 4; + my ($para) = @_; # Start by converting tabs to spaces - for my $line (@$para) { - # Count how many tabs on the beginnging of the line - my ($tabs) = $line =~ /^(\t*)/; - my $tab_count = length($tabs); - - # Remove all the tabs, and add them back as spaces - $line =~ s/^\t+//g; - $line = (" " x ($tab_count * $tab_width)) . $line; - } + $tabstop = 4; + @$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)); |