| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pod::Simple::Role::StripVerbatimIndent; |
|
2
|
1
|
|
|
1
|
|
83997
|
use Moo::Role; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.003000'; |
|
5
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
328
|
use Scalar::Util qw(weaken); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
381
|
use namespace::clean; |
|
|
1
|
|
|
|
|
9164
|
|
|
|
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
|
|
|
|
|
|
|
sub BUILD { |
|
49
|
4
|
|
|
4
|
0
|
8991
|
my $self = shift; |
|
50
|
4
|
|
|
|
|
13
|
$self->expand_verbatim_tabs(0); |
|
51
|
4
|
|
|
|
|
25
|
$self->strip_verbatim_indent($self->$gen_strip_verbatim_indent); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Pod::Simple::Role::StripVerbatimIndent - Strip indentation from verbatim sections sanely |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package MyPodParser; |
|
65
|
|
|
|
|
|
|
with 'Pod::Simple::Role::StripVerbatimIndent; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $parser = MyPodParser->new; |
|
68
|
|
|
|
|
|
|
$parser->output_string(\my $html); |
|
69
|
|
|
|
|
|
|
$parser->parse_string_document($pod); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Strips the indentation from verbatim blocks, while not corrupting tab indents. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The shortest indentation in the verbatim block (excluding empty lines) will be |
|
76
|
|
|
|
|
|
|
stripped from all lines. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
By default, using this role will disable tab expansion. It can be re-enabled |
|
79
|
|
|
|
|
|
|
using L<< expand_verbatim_tabs|Pod::Simple/$parser->expand_verbatim_tabs( I ) >> |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SUPPORT |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
See L for support and contact information. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHORS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
See L for authors. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
See L for the copyright and license. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |