line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Simple::Role::StripVerbatimIndent; |
2
|
1
|
|
|
1
|
|
86507
|
use Moo::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.003002'; |
5
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
338
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
397
|
use namespace::clean; |
|
1
|
|
|
|
|
9106
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
requires 'expand_verbatim_tabs'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $gen_strip_verbatim_indent = sub { |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
weaken $self; |
16
|
|
|
|
|
|
|
sub { |
17
|
|
|
|
|
|
|
my ($para) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if (my $tab_width = $self->expand_verbatim_tabs) { |
20
|
|
|
|
|
|
|
# ugly to be modifying this, but we need the initial tabs expanded first |
21
|
|
|
|
|
|
|
for my $line (@$para) { |
22
|
|
|
|
|
|
|
1 while $line =~ s{\A( *)(\t+)}{ |
23
|
|
|
|
|
|
|
my $expand = $tab_width * length($2) - length($1) % $tab_width; |
24
|
|
|
|
|
|
|
$1 . (" " x $expand); |
25
|
|
|
|
|
|
|
}e; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my @indents = map /\A([ \t]+)/, @$para; |
30
|
|
|
|
|
|
|
my $longest_indent = shift @indents; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
for my $indent (@indents) { |
33
|
|
|
|
|
|
|
if (length $indent < length $longest_indent) { |
34
|
|
|
|
|
|
|
($longest_indent, $indent) = ($indent, $longest_indent); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
chop $longest_indent |
38
|
|
|
|
|
|
|
while index($indent, $longest_indent) != 0; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
last |
41
|
|
|
|
|
|
|
if $longest_indent eq ''; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return $longest_indent; |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
4
|
0
|
|
sub BUILD {} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
after BUILD => sub { |
51
|
|
|
|
|
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
$self->expand_verbatim_tabs(0); |
53
|
|
|
|
|
|
|
$self->strip_verbatim_indent($self->$gen_strip_verbatim_indent); |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Pod::Simple::Role::StripVerbatimIndent - Strip indentation from verbatim sections sanely |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package MyPodParser; |
67
|
|
|
|
|
|
|
with 'Pod::Simple::Role::StripVerbatimIndent; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $parser = MyPodParser->new; |
70
|
|
|
|
|
|
|
$parser->output_string(\my $html); |
71
|
|
|
|
|
|
|
$parser->parse_string_document($pod); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Strips the indentation from verbatim blocks, while not corrupting tab indents. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The shortest indentation in the verbatim block (excluding empty lines) will be |
78
|
|
|
|
|
|
|
stripped from all lines. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
By default, using this role will disable tab expansion. It can be re-enabled |
81
|
|
|
|
|
|
|
using L<< expand_verbatim_tabs|Pod::Simple/$parser->expand_verbatim_tabs( I ) >> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SUPPORT |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
See L for support and contact information. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHORS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
See L for authors. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
See L for the copyright and license. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |