| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Pod::Text::Overstrike -- Convert POD data to formatted overstrike text |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This was written because the output from: |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# pod2text Text.pm > plain.txt; less plain.txt |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# is not as rich as the output from |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# pod2man Text.pm | nroff -man > fancy.txt; less fancy.txt |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# and because both Pod::Text::Color and Pod::Text::Termcap are not device |
|
12
|
|
|
|
|
|
|
# independent. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# Created by Joe Smith 30-Nov-2000 |
|
15
|
|
|
|
|
|
|
# (based on Pod::Text::Color by Russ Allbery ) |
|
16
|
|
|
|
|
|
|
# Copyright 2000 Joe Smith . |
|
17
|
|
|
|
|
|
|
# Copyright 2001, 2004, 2008, 2014 Russ Allbery . |
|
18
|
|
|
|
|
|
|
# |
|
19
|
|
|
|
|
|
|
# This program is free software; you may redistribute it and/or modify it |
|
20
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
############################################################################## |
|
23
|
|
|
|
|
|
|
# Modules and declarations |
|
24
|
|
|
|
|
|
|
############################################################################## |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Pod::Text::Overstrike; |
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
54577
|
use 5.006; |
|
|
2
|
|
|
|
|
17
|
|
|
29
|
2
|
|
|
2
|
|
8
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
44
|
|
|
30
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
51
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
2
|
|
|
2
|
|
9
|
use vars qw(@ISA $VERSION); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
83
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
232
|
use Pod::Text (); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1322
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
@ISA = qw(Pod::Text); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$VERSION = '4.10'; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
############################################################################## |
|
41
|
|
|
|
|
|
|
# Overrides |
|
42
|
|
|
|
|
|
|
############################################################################## |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Make level one headings bold, overriding any existing formatting. |
|
45
|
|
|
|
|
|
|
sub cmd_head1 { |
|
46
|
11
|
|
|
11
|
0
|
23
|
my ($self, $attrs, $text) = @_; |
|
47
|
11
|
|
|
|
|
29
|
$text =~ s/\s+$//; |
|
48
|
11
|
|
|
|
|
24
|
$text = $self->strip_format ($text); |
|
49
|
11
|
|
|
|
|
129
|
$text =~ s/(.)/$1\b$1/g; |
|
50
|
11
|
|
|
|
|
35
|
return $self->SUPER::cmd_head1 ($attrs, $text); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Make level two headings bold, overriding any existing formatting. |
|
54
|
|
|
|
|
|
|
sub cmd_head2 { |
|
55
|
2
|
|
|
2
|
0
|
4
|
my ($self, $attrs, $text) = @_; |
|
56
|
2
|
|
|
|
|
8
|
$text =~ s/\s+$//; |
|
57
|
2
|
|
|
|
|
5
|
$text = $self->strip_format ($text); |
|
58
|
2
|
|
|
|
|
28
|
$text =~ s/(.)/$1\b$1/g; |
|
59
|
2
|
|
|
|
|
7
|
return $self->SUPER::cmd_head2 ($attrs, $text); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Make level three headings underscored, overriding any existing formatting. |
|
63
|
|
|
|
|
|
|
sub cmd_head3 { |
|
64
|
2
|
|
|
2
|
0
|
4
|
my ($self, $attrs, $text) = @_; |
|
65
|
2
|
|
|
|
|
21
|
$text =~ s/\s+$//; |
|
66
|
2
|
|
|
|
|
5
|
$text = $self->strip_format ($text); |
|
67
|
2
|
|
|
|
|
40
|
$text =~ s/(.)/_\b$1/g; |
|
68
|
2
|
|
|
|
|
10
|
return $self->SUPER::cmd_head3 ($attrs, $text); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Level four headings look like level three headings. |
|
72
|
|
|
|
|
|
|
sub cmd_head4 { |
|
73
|
2
|
|
|
2
|
0
|
5
|
my ($self, $attrs, $text) = @_; |
|
74
|
2
|
|
|
|
|
5
|
$text =~ s/\s+$//; |
|
75
|
2
|
|
|
|
|
5
|
$text = $self->strip_format ($text); |
|
76
|
2
|
|
|
|
|
24
|
$text =~ s/(.)/_\b$1/g; |
|
77
|
2
|
|
|
|
|
10
|
return $self->SUPER::cmd_head4 ($attrs, $text); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# The common code for handling all headers. We have to override to avoid |
|
81
|
|
|
|
|
|
|
# interpolating twice and because we don't want to honor alt. |
|
82
|
|
|
|
|
|
|
sub heading { |
|
83
|
17
|
|
|
17
|
0
|
41
|
my ($self, $text, $indent, $marker) = @_; |
|
84
|
17
|
50
|
|
|
|
35
|
$self->item ("\n\n") if defined $$self{ITEM}; |
|
85
|
17
|
50
|
|
|
|
28
|
$text .= "\n" if $$self{opt_loose}; |
|
86
|
17
|
|
|
|
|
38
|
my $margin = ' ' x ($$self{opt_margin} + $indent); |
|
87
|
17
|
|
|
|
|
62
|
$self->output ($margin . $text . "\n"); |
|
88
|
17
|
|
|
|
|
137
|
return ''; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Fix the various formatting codes. |
|
92
|
12
|
|
|
12
|
0
|
24
|
sub cmd_b { local $_ = $_[0]->strip_format ($_[2]); s/(.)/$1\b$1/g; $_ } |
|
|
12
|
|
|
|
|
140
|
|
|
|
12
|
|
|
|
|
26
|
|
|
93
|
3
|
|
|
3
|
0
|
6
|
sub cmd_f { local $_ = $_[0]->strip_format ($_[2]); s/(.)/_\b$1/g; $_ } |
|
|
3
|
|
|
|
|
26
|
|
|
|
3
|
|
|
|
|
7
|
|
|
94
|
16
|
|
|
16
|
0
|
38
|
sub cmd_i { local $_ = $_[0]->strip_format ($_[2]); s/(.)/_\b$1/g; $_ } |
|
|
16
|
|
|
|
|
124
|
|
|
|
16
|
|
|
|
|
40
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Output any included code in bold. |
|
97
|
|
|
|
|
|
|
sub output_code { |
|
98
|
0
|
|
|
0
|
0
|
0
|
my ($self, $code) = @_; |
|
99
|
0
|
|
|
|
|
0
|
$code =~ s/(.)/$1\b$1/g; |
|
100
|
0
|
|
|
|
|
0
|
$self->output ($code); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Strip all of the formatting from a provided string, returning the stripped |
|
104
|
|
|
|
|
|
|
# version. |
|
105
|
|
|
|
|
|
|
sub strip_format { |
|
106
|
77
|
|
|
77
|
0
|
103
|
my ($self, $text) = @_; |
|
107
|
77
|
|
|
|
|
179
|
$text =~ s/(.)[\b]\1/$1/g; |
|
108
|
77
|
|
|
|
|
115
|
$text =~ s/_[\b]//g; |
|
109
|
77
|
|
|
|
|
133
|
return $text; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# We unfortunately have to override the wrapping code here, since the normal |
|
113
|
|
|
|
|
|
|
# wrapping code gets really confused by all the backspaces. |
|
114
|
|
|
|
|
|
|
sub wrap { |
|
115
|
101
|
|
|
101
|
0
|
130
|
my $self = shift; |
|
116
|
101
|
|
|
|
|
117
|
local $_ = shift; |
|
117
|
101
|
|
|
|
|
114
|
my $output = ''; |
|
118
|
101
|
|
|
|
|
157
|
my $spaces = ' ' x $$self{MARGIN}; |
|
119
|
101
|
|
|
|
|
123
|
my $width = $$self{opt_width} - $$self{MARGIN}; |
|
120
|
101
|
|
|
|
|
209
|
while (length > $width) { |
|
121
|
|
|
|
|
|
|
# This regex represents a single character, that's possibly underlined |
|
122
|
|
|
|
|
|
|
# or in bold (in which case, it's three characters; the character, a |
|
123
|
|
|
|
|
|
|
# backspace, and a character). Use [^\n] rather than . to protect |
|
124
|
|
|
|
|
|
|
# against odd settings of $*. |
|
125
|
32
|
|
|
|
|
34
|
my $char = '(?:[^\n][\b])?[^\n]'; |
|
126
|
32
|
50
|
|
|
|
673
|
if (s/^((?>$char){0,$width})(?:\Z|\s+)//) { |
|
127
|
32
|
|
|
|
|
136
|
$output .= $spaces . $1 . "\n"; |
|
128
|
|
|
|
|
|
|
} else { |
|
129
|
0
|
|
|
|
|
0
|
last; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
101
|
|
|
|
|
181
|
$output .= $spaces . $_; |
|
133
|
101
|
|
|
|
|
426
|
$output =~ s/\s+$/\n\n/; |
|
134
|
101
|
|
|
|
|
303
|
return $output; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
############################################################################## |
|
138
|
|
|
|
|
|
|
# Module return value and documentation |
|
139
|
|
|
|
|
|
|
############################################################################## |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
|
142
|
|
|
|
|
|
|
__END__ |