Node/Text.pm
Go to the documentation of this file.
1 #============================================================= -*-Perl-*-
2 #
3 # Pod::POM::Node::Text
4 #
5 # DESCRIPTION
6 # Module implementing specific nodes in a Pod::POM, subclassed from
7 # Pod::POM::Node.
8 #
9 # AUTHOR
10 # Andy Wardley <abw@kfs.org>
11 # Andrew Ford <a.ford@ford-mason.co.uk>
12 #
13 # COPYRIGHT
14 # Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
15 # Copyright (C) 2009 Andrew Ford. All Rights Reserved.
16 #
17 # This module is free software; you can redistribute it and/or
18 # modify it under the same terms as Perl itself.
19 #
20 # REVISION
21 # $Id: Text.pm 76 2009-08-20 20:41:33Z ford $
22 #
23 #========================================================================
24 
25 package BASIS::Pod::POM::Node::Text;
26 
27 use strict;
28 
29 use BASIS::Pod::POM::Constants qw( :all );
30 use parent qw( BASIS::Pod::POM::Node );
31 use vars qw( %ATTRIBS $ERROR );
32 
33 %ATTRIBS = ( text => '' );
34 
35 sub new {
36  my $class = shift;
37  my $pom = shift;
38  my $text = shift;
39  $text = $pom->parse_sequence($text)
40  || return $class->error($pom->error())
41  if length $text && ! $pom->{in_begin};
42  return $class->SUPER::new($pom, $text);
43 }
44 
45 sub add {
46  return IGNORE;
47 }
48 
49 sub present {
50  my ($self, $view) = @_;
51  my $text = $self->{ text };
52  $view ||= $BASIS::Pod::POM::DEFAULT_VIEW;
53 
54  $text = $text->present($view)
55  if ref $text;
56 
57  return $view->view_textblock($text);
58 }
59 
60 1;
61 
62 =head1 NAME
63 
64 Pod::POM::Node::Text -
65 
66 =head1 SYNOPSIS
67 
68  use Pod::POM::Nodes;
69 
70 =head1 DESCRIPTION
71 
72 This module implements a specialization of the node class to represent text elements.
73 
74 =head1 AUTHOR
75 
76 Andrew Ford E<lt>a.ford@ford-mason.co.ukE<gt>
77 
78 Andy Wardley E<lt>abw@kfs.orgE<gt>
79 
80 =head1 COPYRIGHT
81 
82 Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
83 
84 Copyright (C) 2009 Andrew Ford. All Rights Reserved.
85 
86 This module is free software; you can redistribute it and/or
87 modify it under the same terms as Perl itself.
88 
89 =head1 SEE ALSO
90 
91 Consult L<Pod::POM::Node> for a discussion of nodes.