Text::Microformat::Plugin::Parser::HTML - HTML parser plugin for Text::Microformat


Text-Microformat documentation Contained in the Text-Microformat distribution.

Index


Code Index:

NAME

Top

Text::Microformat::Plugin::Parser::HTML - HTML parser plugin for Text::Microformat

SEE ALSO

Top

Text::Microformat

AUTHOR

Top

Keith Grennan, <kgrennan at cpan.org>

BUGS

Top

Log bugs and feature requests here: http://code.google.com/p/ufperl/issues/list

SUPPORT

Top

Project homepage: http://code.google.com/p/ufperl/

COPYRIGHT & LICENSE

Top


Text-Microformat documentation Contained in the Text-Microformat distribution.

package Text::Microformat::Plugin::Parser::HTML;
use HTML::TreeBuilder;

sub html_to_tree {
    my $c = shift;
    my $content = shift;
    my $tree = HTML::TreeBuilder->new;
    while (my ($k,$v) = each %{$c->plugin_opts}) {
        $tree->$k($v) if $tree->can($k);
    }
    $tree->parse_content($content);
    return $tree;
}

sub parse {
    my $c = shift;
    if (!$c->tree and $c->opts->{content_type} =~ /html/i) {
    	$c->tree($c->html_to_tree($c->content));     
    }
    return $c->NEXT::parse(@_);
}

1;