WikiText::Receiver - An Interface Class


WikiText documentation Contained in the WikiText distribution.

Index


Code Index:

NAME

Top

WikiText::Receiver - An Interface Class

SYNOPSIS

Top

    use base 'WikiText::Receiver';

DESCRIPTION

Top

The base class of WikiText modules that act as receivers of parse events, and are therefore hooked up to a parser.

AUTHOR

Top

Ingy döt Net <ingy@cpan.org>

COPYRIGHT

Top


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;