| WikiText documentation | Contained in the WikiText distribution. |
WikiText::Receiver - An Interface Class
use base 'WikiText::Receiver';
The base class of WikiText modules that act as receivers of parse events, and are therefore hooked up to a parser.
Ingy döt Net <ingy@cpan.org>
Copyright (c) 2008. Ingy döt Net.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
| WikiText documentation | Contained in the WikiText distribution. |
package WikiText::Receiver; use strict; use warnings; sub new { my $class = shift; my $self = bless { ref($class) ? (map { /^(?:output)$/ ? () : ($_, $class->{$_}) } keys %$class) : (), @_ }, ref($class) || $class; } sub content { my $self = shift; return $self->{output}; } sub init { my $self = shift; die "You need to override WikiText::Receiver::init"; } sub insert { my $self = shift; my $ast = shift; die "You need to override WikiText::Receiver::insert"; # $self->{output} .= $ast->{output}; } sub begin_node { my $self = shift; my $context = shift; die "You need to override WikiText::Receiver::begin_node"; # $self->{output} .= "+" . $context->{type} . "\n"; } sub end_node { my $self = shift; my $context = shift; die "You need to override WikiText::Receiver::end_node"; # $self->{output} .= "-" . $context->{type} . "\n"; } sub text_node { my $self = shift; my $text = shift; die "You need to override WikiText::Receiver::text_node"; # $self->{output} .= " $text\n"; } 1;