1 #============================================================= -*-Perl-*-
6 # Text view of a Pod Object Model.
9 # Andy Wardley <abw@kfs.org>
12 # Copyright (C) 2000 Andy Wardley. All Rights Reserved.
14 # This module is free software; you can redistribute it and/or
15 # modify it under the same terms as Perl itself.
18 # $Id: Text.pm 77 2009-08-20 20:44:14Z ford $
20 #========================================================================
22 package BASIS::Pod::POM::View::Text;
27 use BASIS::Pod::POM::View;
28 use parent qw( BASIS::Pod::POM::View );
29 use vars qw( $VERSION $DEBUG $ERROR $AUTOLOAD $INDENT );
32 $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
33 $DEBUG = 0 unless defined $DEBUG;
39 my $args = ref $_[0] eq 'HASH' ? shift : { @_ };
48 my ($self, $type, $item) = @_;
50 if ($type =~ s/^seq_//) {
53 elsif (UNIVERSAL::isa($item, 'HASH')) {
54 if (defined $item->{ content }) {
55 return $item->{ content }->present($self);
57 elsif (defined $item->{ text }) {
58 my $text = $item->{ text };
59 return ref $text ? $text->present($self) : $text;
75 my ($self, $head1) = @_;
76 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
77 my $pad = ' ' x $$indent;
78 local $Text::Wrap::unexpand = 0;
79 my $title = wrap($pad, $pad,
80 $head1->title->present($self));
83 my $output = "$title\n" . $head1->content->present($self);
91 my ($self, $head2) = @_;
92 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
93 my $pad = ' ' x $$indent;
94 local $Text::Wrap::unexpand = 0;
95 my $title = wrap($pad, $pad,
96 $head2->title->present($self));
99 my $output = "$title\n" . $head2->content->present($self);
107 my ($self, $head3) = @_;
108 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
109 my $pad = ' ' x $$indent;
110 local $Text::Wrap::unexpand = 0;
111 my $title = wrap($pad, $pad,
112 $head3->title->present($self));
115 my $output = "$title\n" . $head3->content->present($self);
123 my ($self, $head4) = @_;
124 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
125 my $pad = ' ' x $$indent;
126 local $Text::Wrap::unexpand = 0;
127 my $title = wrap($pad, $pad,
128 $head4->title->present($self));
131 my $output = "$title\n" . $head4->content->present($self);
138 #------------------------------------------------------------------------
139 # view_over($self, $over)
141 # Present an =over block - this is a blockquote if there are no =items
143 #------------------------------------------------------------------------
146 my ($self, $over) = @_;
148 if (@{$over->item}) {
149 return $over->content->present($self);
152 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
153 my $pad = ' ' x $$indent;
155 my $content = $over->content->present($self);
163 my ($self, $item) = @_;
164 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
165 my $pad = ' ' x $$indent;
166 local $Text::Wrap::unexpand = 0;
167 my $title = wrap($pad . '* ', $pad . ' ',
168 $item->title->present($self));
171 my $content = $item->content->present($self);
174 return "$title\n\n$content";
179 my ($self, $for) = @_;
180 return '' unless $for->format() =~ /\btext\b/;
187 my ($self, $begin) = @_;
188 return '' unless $begin->format() =~ /\btext\b/;
189 return $begin->content->present($self);
194 my ($self, $text) = @_;
195 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
199 my $pad = ' ' x $$indent;
200 local $Text::Wrap::unexpand = 0;
201 return wrap($pad, $pad, $text) . "\n\n";
206 my ($self, $text) = @_;
207 my $indent = ref $self ? \$self->{ INDENT } : \$INDENT;
208 my $pad = ' ' x $$indent;
209 $text =~ s/^/$pad/mg;
215 my ($self, $text) = @_;
220 sub view_seq_italic {
221 my ($self, $text) = @_;
227 my ($self, $text) = @_;
233 my ($self, $text) = @_;
245 sub view_seq_entity {
246 my ($self, $entity) = @_;
247 return $entities->{ $entity } || $entity;
255 my ($self, $link) = @_;
256 if ($link =~ s/^.*?\|//) {
260 return "the $link manpage";
274 Text view of a Pod Object Model.
280 =item C<view($self, $type, $item)>
282 =item C<view_pod($self, $pod)>
284 =item C<view_head1($self, $head1)>
286 =item C<view_head2($self, $head2)>
288 =item C<view_head3($self, $head3)>
290 =item C<view_head4($self, $head4)>
292 =item C<view_over($self, $over)>
294 =item C<view_item($self, $item)>
296 =item C<view_for($self, $for)>
298 =item C<view_begin($self, $begin)>
300 =item C<view_textblock($self, $textblock)>
302 =item C<view_verbatim($self, $verbatim)>
304 =item C<view_meta($self, $meta)>
306 =item C<view_seq_bold($self, $text)>
308 Returns the text of a C<BE<lt>E<gt>> sequence in 'bold' (i.e. surrounded by asterisks, like *this*).
310 =item C<view_seq_italic($self, $text)>
312 Returns the text of a C<IE<lt>E<gt>> sequence in 'italics' (i.e. surrounded by underscores, like _this_).
314 =item C<view_seq_code($self, $text)>
316 =item C<view_seq_file($self, $text)>
318 =item C<view_seq_entity($self, $text)>
320 =item C<view_seq_index($self, $text)>
322 Returns an empty string. Index sequences are suppressed in text view.
324 =item C<view_seq_link($self, $text)>
330 Andy Wardley E<lt>abw@kfs.orgE<gt>
332 =head1 COPYRIGHT AND LICENSE
334 Copyright (C) 2000 Andy Wardley. All Rights Reserved.
336 This module is free software; you can redistribute it and/or
337 modify it under the same terms as Perl itself.