line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#============================================================= -*-Perl-*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Pod::POM::View::Text |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# Text view of a Pod Object Model. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Andy Wardley |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# COPYRIGHT |
12
|
|
|
|
|
|
|
# Copyright (C) 2000 Andy Wardley. All Rights Reserved. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or |
15
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# REVISION |
18
|
|
|
|
|
|
|
# $Id: Text.pm 77 2009-08-20 20:44:14Z ford $ |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
#======================================================================== |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Pod::POM::View::Text; |
23
|
|
|
|
|
|
|
$Pod::POM::View::Text::VERSION = '2.00'; |
24
|
|
|
|
|
|
|
require 5.006; |
25
|
6
|
|
|
6
|
|
3369
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
145
|
|
26
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
152
|
|
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
6
|
|
26
|
use Pod::POM::View; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
128
|
|
29
|
6
|
|
|
6
|
|
25
|
use parent qw( Pod::POM::View ); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
36
|
|
30
|
6
|
|
|
6
|
|
314
|
use vars qw( $DEBUG $ERROR $AUTOLOAD $INDENT ); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
353
|
|
31
|
6
|
|
|
6
|
|
11117
|
use Text::Wrap; |
|
6
|
|
|
|
|
17739
|
|
|
6
|
|
|
|
|
9264
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$DEBUG = 0 unless defined $DEBUG; |
34
|
|
|
|
|
|
|
$INDENT = 0; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
2
|
|
|
2
|
1
|
16
|
my $class = shift; |
39
|
2
|
50
|
|
|
|
9
|
my $args = ref $_[0] eq 'HASH' ? shift : { @_ }; |
40
|
2
|
|
|
|
|
13
|
bless { |
41
|
|
|
|
|
|
|
INDENT => 0, |
42
|
|
|
|
|
|
|
%$args, |
43
|
|
|
|
|
|
|
}, $class; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub view { |
48
|
265
|
|
|
265
|
1
|
402
|
my ($self, $type, $item) = @_; |
49
|
|
|
|
|
|
|
|
50
|
265
|
100
|
|
|
|
721
|
if ($type =~ s/^seq_//) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
51
|
251
|
|
|
|
|
975
|
return $item; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif (UNIVERSAL::isa($item, 'HASH')) { |
54
|
12
|
50
|
|
|
|
29
|
if (defined $item->{ content }) { |
|
|
0
|
|
|
|
|
|
55
|
12
|
|
|
|
|
48
|
return $item->{ content }->present($self); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif (defined $item->{ text }) { |
58
|
0
|
|
|
|
|
0
|
my $text = $item->{ text }; |
59
|
0
|
0
|
|
|
|
0
|
return ref $text ? $text->present($self) : $text; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
0
|
|
|
|
|
0
|
return ''; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif (! ref $item) { |
66
|
2
|
|
|
|
|
9
|
return $item; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
0
|
|
|
|
|
0
|
return ''; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub view_head1 { |
75
|
32
|
|
|
32
|
1
|
41
|
my ($self, $head1) = @_; |
76
|
32
|
50
|
|
|
|
60
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
77
|
32
|
|
|
|
|
49
|
my $pad = ' ' x $$indent; |
78
|
32
|
|
|
|
|
42
|
local $Text::Wrap::unexpand = 0; |
79
|
32
|
|
|
|
|
133
|
my $title = wrap($pad, $pad, |
80
|
|
|
|
|
|
|
$head1->title->present($self)); |
81
|
|
|
|
|
|
|
|
82
|
32
|
|
|
|
|
2853
|
$$indent += 4; |
83
|
32
|
|
|
|
|
148
|
my $output = "$title\n" . $head1->content->present($self); |
84
|
32
|
|
|
|
|
2320
|
$$indent -= 4; |
85
|
|
|
|
|
|
|
|
86
|
32
|
|
|
|
|
76
|
return $output; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub view_head2 { |
91
|
8
|
|
|
8
|
1
|
13
|
my ($self, $head2) = @_; |
92
|
8
|
50
|
|
|
|
19
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
93
|
8
|
|
|
|
|
16
|
my $pad = ' ' x $$indent; |
94
|
8
|
|
|
|
|
10
|
local $Text::Wrap::unexpand = 0; |
95
|
8
|
|
|
|
|
44
|
my $title = wrap($pad, $pad, |
96
|
|
|
|
|
|
|
$head2->title->present($self)); |
97
|
|
|
|
|
|
|
|
98
|
8
|
|
|
|
|
733
|
$$indent += 4; |
99
|
8
|
|
|
|
|
48
|
my $output = "$title\n" . $head2->content->present($self); |
100
|
8
|
|
|
|
|
209
|
$$indent -= 4; |
101
|
|
|
|
|
|
|
|
102
|
8
|
|
|
|
|
21
|
return $output; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub view_head3 { |
107
|
5
|
|
|
5
|
1
|
9
|
my ($self, $head3) = @_; |
108
|
5
|
50
|
|
|
|
10
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
109
|
5
|
|
|
|
|
11
|
my $pad = ' ' x $$indent; |
110
|
5
|
|
|
|
|
6
|
local $Text::Wrap::unexpand = 0; |
111
|
5
|
|
|
|
|
29
|
my $title = wrap($pad, $pad, |
112
|
|
|
|
|
|
|
$head3->title->present($self)); |
113
|
|
|
|
|
|
|
|
114
|
5
|
|
|
|
|
418
|
$$indent += 4; |
115
|
5
|
|
|
|
|
25
|
my $output = "$title\n" . $head3->content->present($self); |
116
|
5
|
|
|
|
|
8
|
$$indent -= 4; |
117
|
|
|
|
|
|
|
|
118
|
5
|
|
|
|
|
12
|
return $output; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub view_head4 { |
123
|
7
|
|
|
7
|
1
|
9
|
my ($self, $head4) = @_; |
124
|
7
|
50
|
|
|
|
15
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
125
|
7
|
|
|
|
|
11
|
my $pad = ' ' x $$indent; |
126
|
7
|
|
|
|
|
11
|
local $Text::Wrap::unexpand = 0; |
127
|
7
|
|
|
|
|
30
|
my $title = wrap($pad, $pad, |
128
|
|
|
|
|
|
|
$head4->title->present($self)); |
129
|
|
|
|
|
|
|
|
130
|
7
|
|
|
|
|
652
|
$$indent += 4; |
131
|
7
|
|
|
|
|
33
|
my $output = "$title\n" . $head4->content->present($self); |
132
|
7
|
|
|
|
|
11
|
$$indent -= 4; |
133
|
|
|
|
|
|
|
|
134
|
7
|
|
|
|
|
18
|
return $output; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
139
|
|
|
|
|
|
|
# view_over($self, $over) |
140
|
|
|
|
|
|
|
# |
141
|
|
|
|
|
|
|
# Present an =over block - this is a blockquote if there are no =items |
142
|
|
|
|
|
|
|
# within the block. |
143
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub view_over { |
146
|
8
|
|
|
8
|
1
|
12
|
my ($self, $over) = @_; |
147
|
|
|
|
|
|
|
|
148
|
8
|
100
|
|
|
|
8
|
if (@{$over->item}) { |
|
8
|
|
|
|
|
43
|
|
149
|
5
|
|
|
|
|
23
|
return $over->content->present($self); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
else { |
152
|
3
|
50
|
|
|
|
8
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
153
|
3
|
|
|
|
|
5
|
my $pad = ' ' x $$indent; |
154
|
3
|
|
|
|
|
4
|
$$indent += 4; |
155
|
3
|
|
|
|
|
15
|
my $content = $over->content->present($self); |
156
|
3
|
|
|
|
|
210
|
$$indent -= 4; |
157
|
|
|
|
|
|
|
|
158
|
3
|
|
|
|
|
8
|
return $content; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub view_item { |
163
|
12
|
|
|
12
|
1
|
20
|
my ($self, $item) = @_; |
164
|
12
|
50
|
|
|
|
61
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
165
|
12
|
|
|
|
|
23
|
my $pad = ' ' x $$indent; |
166
|
12
|
|
|
|
|
15
|
local $Text::Wrap::unexpand = 0; |
167
|
12
|
|
|
|
|
60
|
my $title = wrap($pad . '* ', $pad . ' ', |
168
|
|
|
|
|
|
|
$item->title->present($self)); |
169
|
|
|
|
|
|
|
|
170
|
12
|
|
|
|
|
1131
|
$$indent += 2; |
171
|
12
|
|
|
|
|
65
|
my $content = $item->content->present($self); |
172
|
12
|
|
|
|
|
899
|
$$indent -= 2; |
173
|
|
|
|
|
|
|
|
174
|
12
|
|
|
|
|
38
|
return "$title\n\n$content"; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub view_for { |
179
|
1
|
|
|
1
|
1
|
4
|
my ($self, $for) = @_; |
180
|
1
|
50
|
|
|
|
9
|
return '' unless $for->format() =~ /\btext\b/; |
181
|
0
|
|
|
|
|
0
|
return $for->text() |
182
|
|
|
|
|
|
|
. "\n\n"; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub view_begin { |
187
|
4
|
|
|
4
|
1
|
9
|
my ($self, $begin) = @_; |
188
|
4
|
100
|
|
|
|
27
|
return '' unless $begin->format() =~ /\btext\b/; |
189
|
1
|
|
|
|
|
8
|
return $begin->content->present($self); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub view_textblock { |
194
|
82
|
|
|
82
|
1
|
108
|
my ($self, $text) = @_; |
195
|
82
|
50
|
|
|
|
148
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
196
|
82
|
|
|
|
|
372
|
$text =~ s/\s+/ /mg; |
197
|
|
|
|
|
|
|
|
198
|
82
|
|
100
|
|
|
320
|
$$indent ||= 0; |
199
|
82
|
|
|
|
|
119
|
my $pad = ' ' x $$indent; |
200
|
82
|
|
|
|
|
96
|
local $Text::Wrap::unexpand = 0; |
201
|
82
|
|
|
|
|
187
|
return wrap($pad, $pad, $text) . "\n\n"; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub view_verbatim { |
206
|
6
|
|
|
6
|
1
|
8
|
my ($self, $text) = @_; |
207
|
6
|
50
|
|
|
|
15
|
my $indent = ref $self ? \$self->{ INDENT } : \$INDENT; |
208
|
6
|
|
|
|
|
9
|
my $pad = ' ' x $$indent; |
209
|
6
|
|
|
|
|
30
|
$text =~ s/^/$pad/mg; |
210
|
6
|
|
|
|
|
25
|
return "$text\n\n"; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub view_seq_bold { |
215
|
10
|
|
|
10
|
1
|
15
|
my ($self, $text) = @_; |
216
|
10
|
|
|
|
|
37
|
return "*$text*"; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub view_seq_italic { |
221
|
9
|
|
|
9
|
1
|
17
|
my ($self, $text) = @_; |
222
|
9
|
|
|
|
|
33
|
return "_${text}_"; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub view_seq_code { |
227
|
7
|
|
|
7
|
1
|
13
|
my ($self, $text) = @_; |
228
|
7
|
|
|
|
|
25
|
return "'$text'"; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub view_seq_file { |
233
|
3
|
|
|
3
|
1
|
7
|
my ($self, $text) = @_; |
234
|
3
|
|
|
|
|
13
|
return "_${text}_"; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
my $entities = { |
238
|
|
|
|
|
|
|
gt => '>', |
239
|
|
|
|
|
|
|
lt => '<', |
240
|
|
|
|
|
|
|
amp => '&', |
241
|
|
|
|
|
|
|
quot => '"', |
242
|
|
|
|
|
|
|
}; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub view_seq_entity { |
246
|
10
|
|
|
10
|
1
|
15
|
my ($self, $entity) = @_; |
247
|
10
|
|
33
|
|
|
44
|
return $entities->{ $entity } || $entity; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub view_seq_index { |
251
|
2
|
|
|
2
|
1
|
5
|
return ''; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub view_seq_link { |
255
|
3
|
|
|
3
|
1
|
6
|
my ($self, $link) = @_; |
256
|
3
|
100
|
|
|
|
11
|
if ($link =~ s/^.*?\|//) { |
257
|
1
|
|
|
|
|
4
|
return $link; |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
else { |
260
|
2
|
|
|
|
|
9
|
return "the $link manpage"; |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
1; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 NAME |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Pod::POM::View::Text |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 DESCRIPTION |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Text view of a Pod Object Model. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 METHODS |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=over 4 |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item C |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=item C |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=item C |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=item C |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=item C |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item C |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=item C |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=item C |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=item C |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=item C |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=item C |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=item C |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=item C |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=item C |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Returns the text of a CE> sequence in 'bold' (i.e. surrounded by asterisks, like *this*). |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=item C |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Returns the text of a CE> sequence in 'italics' (i.e. surrounded by underscores, like _this_). |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=item C |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=item C |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=item C |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=item C |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
Returns an empty string. Index sequences are suppressed in text view. |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=item C |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=back |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head1 AUTHOR |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Andy Wardley Eabw@kfs.orgE |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
Copyright (C) 2000 Andy Wardley. All Rights Reserved. |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
337
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=cut |