3 package Pod::Simple::Methody;
6 use vars qw(@ISA $VERSION);
8 @ISA = ('Pod::Simple');
10 # Yes, we could use named variables, but I want this to be impose
11 # as little an additional performance hit as possible.
13 sub _handle_element_start {
15 ( $_[0]->can( 'start_' . $_[1] )
23 ( $_[0]->can( 'handle_text' )
30 sub _handle_element_end {
32 ( $_[0]->can( 'end_' . $_[1] )
46 Pod::Simple::Methody -- turn Pod::Simple events into method calls
52 package SomePodFormatter;
53 use base qw(Pod::Simple::Methody);
56 my($self, $text) = @_;
61 my($self, $attrs) = @_;
69 ...and start_/end_ methods for whatever other events you want to catch.
74 interest to people writing Pod formatters based on Pod::Simple.
76 This class (which is very small -- read the source) overrides
77 Pod::Simple's _handle_element_start, _handle_text, and
78 _handle_element_end methods so that parser events are turned into method
79 calls. (Otherwise, this is a subclass of L<Pod::Simple> and inherits all
82 You can use this class as the base class for a Pod formatter/processor.
86 When Pod::Simple sees a "=head1 Hi there", for example, it basically does
89 $parser->_handle_element_start( "head1", \%attributes );
90 $parser->_handle_text( "Hi there" );
91 $parser->_handle_element_end( "head1" );
93 But if you subclass Pod::Simple::Methody, it will instead do this
94 when it sees a "=head1 Hi there":
96 $parser->start_head1( \%attributes ) if $parser->can('start_head1');
97 $parser->handle_text( "Hi there" ) if $parser->can('handle_text');
98 $parser->end_head1() if $parser->can('end_head1');
100 If Pod::Simple sends an event where the element name has a dash,
101 period, or colon, the corresponding method name will have a underscore
102 in its place. For example, "foo.bar:baz" becomes start_foo_bar_baz
105 See the source for Pod::Simple::Text for an example of using this class.
109 L<Pod::Simple>, L<Pod::Simple::Subclassing>
113 Questions or discussion about POD and Pod::Simple should be sent to the
114 pod-people@perl.org mail list. Send an empty email to
115 pod-people-subscribe@perl.org to subscribe.
117 This module is managed in an open GitHub repository,
118 L<https://github.com/perl-pod/pod-simple/>. Feel free to fork and contribute, or
119 to clone L<git://github.com/perl-pod/pod-simple.git> and send patches!
121 Patches against Pod::Simple are welcome. Please send bug reports to
122 <bug-pod-simple@rt.cpan.org>.
124 =head1 COPYRIGHT AND DISCLAIMERS
126 Copyright (c) 2002 Sean M. Burke.
128 This library is free software; you can redistribute it and/or modify it
129 under the same terms as Perl itself.
131 This program is distributed in the hope that it will be useful, but
132 without any warranty; without even the implied warranty of
133 merchantability or fitness for a particular purpose.
137 Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.
138 But don't bother him, he's retired.
140 Pod::Simple is maintained by:
144 =item * Allison Randal C<allison@perl.org>
146 =item * Hans Dieter Pearcey C<hdp@cpan.org>
148 =item * David E. Wheeler C<dwheeler@cpan.org>