Text::Microformat::Plugin::Include - a plugin providing the Microformat include pattern


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

Index


Code Index:

NAME

Top

Text::Microformat::Plugin::Include - a plugin providing the Microformat include pattern

SEE ALSO

Top

Text::Microformat, http://microformats.org/wiki/include-pattern

NAME

Top

Text::Microformat::Plugin::Parser::HTML - HTML parser plugin for 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::Include;
use strict;
use warnings;

sub post_parse {
    my $c = shift;
	my @includes = $c->tree->look_down(
		_tag => $c->tag_regex('object'),
		class => $c->class_regex('include'),
	);
	foreach my $source (@includes) {
		my $id = $source->attr('data');
		if (defined $id and length $id > 1 and $id =~ s/^#//) {
			my ($target) = $c->tree->look_down(id => $id);
			if ($target) {
				$source->replace_with($target->clone)->delete;
			}
		}
	}
    return $c->NEXT::post_parse(@_);
}

1;