source: trunk/gsdl/perllib/cpan/HTML/TokeParser/Simple/Token.pm@ 13983

Last change on this file since 13983 was 13983, checked in by lh92, 17 years ago

Added for Realistic Book Project

  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1package HTML::TokeParser::Simple::Token;
2
3use strict;
4
5use vars qw/ $VERSION $REVISION /;
6$REVISION = '$Id: Token.pm 13983 2007-03-15 01:32:44Z lh92 $';
7$VERSION = '3.0';
8
9sub new {
10 my ($class, $token) = @_;
11 $class->_croak("This class should not be instantiated") if __PACKAGE__ eq $class;
12 return bless $token, $class;
13}
14
15sub _croak {
16 my ($proto, $message) = @_;
17 require Carp;
18 Carp::croak($message);
19}
20
21sub _carp {
22 my ($proto, $message) = @_;
23 require Carp;
24 Carp::carp($message);
25}
26
27sub is_tag {}
28sub is_start_tag {}
29sub is_end_tag {}
30sub is_text {}
31sub is_comment {}
32sub is_declaration {}
33sub is_pi {}
34sub is_process_instruction {}
35
36sub rewrite_tag { shift }
37sub delete_attr {}
38sub set_attr {}
39sub get_tag {}
40sub return_tag {} # deprecated
41sub get_attr {}
42sub return_attr {} # deprecated
43sub get_attrseq {}
44sub return_attrseq {} # deprecated
45sub get_token0 {}
46sub return_token0 {} # deprecated
47
48# get_foo methods
49
50sub return_text {
51 my ($self) = @_;
52 $self->_carp('return_text() is deprecated. Use as_is() instead');
53 goto &as_is;
54}
55
56sub as_is { return shift->[-1] }
57
581;
59
60__END__
61
62=head1 NAME
63
64HTML::TokeParser::Simple::Token - Base class for C<HTML::TokeParser::Simple>
65tokens.
66
67=head1 SYNOPSIS
68
69 use HTML::TokeParser::Simple;
70 my $p = HTML::TokeParser::Simple->new( $somefile );
71
72 while ( my $token = $p->get_token ) {
73 # This prints all text in an HTML doc (i.e., it strips the HTML)
74 next unless $token->is_text;
75 print $token->as_is;
76 }
77
78=head1 DESCRIPTION
79
80This is the base class for all returned tokens. It should never be
81instantiated directly. In fact, it will C<croak()> if it is.
82
83=head1 METHODS
84
85The following list of methods are provided by this class. Most of these are
86stub methods which must be overridden in a subclass. See
87L<HTML::TokeParser::Simple> for descriptions of these methods.
88
89=over 4
90
91=item * as_is
92
93=item * delete_attr
94
95=item * get_attr
96
97=item * get_attrseq
98
99=item * get_tag
100
101=item * get_token0
102
103=item * is_comment
104
105=item * is_declaration
106
107=item * is_end_tag
108
109=item * is_pi
110
111=item * is_process_instruction
112
113=item * is_start_tag
114
115=item * is_tag
116
117=item * is_text
118
119=item * return_attr
120
121=item * return_attrseq
122
123=item * return_tag
124
125=item * return_text
126
127=item * return_token0
128
129=item * rewrite_tag
130
131=item * set_attr
132
133=back
Note: See TracBrowser for help on using the repository browser.