You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
872 B

package Text::Dokuwiki::Render;
use strict;
use warnings;
use utf8;
sub new {
my ($class) = @_;
my $self = {
list_depth => 0,
trace => [],
};
return bless($self, $class);
}
sub treewalk {
my ($self, @tree) = @_;
my $output = "";
foreach my $part (@tree) {
if (ref $part eq 'ARRAY') {
my ($tag, $attrs, @rest) = @{$part};
if ($self->SUPER::can($tag)) {
push @{ $self->{trace} }, $tag;
$output .= $self->$tag($attrs, $self->treewalk(@rest));
pop @{ $self->{trace} };
} elsif ($self->SUPER::can('default')){
push @{ $self->{trace} }, $tag;
$output .= $self->default($tag, $attrs, $self->treewalk(@rest));
pop @{ $self->{trace} };
} else {
die("Unimplemented handler for tag: $tag\n");
}
next;
}
$output .= $part;
}
return $output;
}
1;