File Coverage

blib/lib/Text/Microformat/Plugin/Include.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 4 50.0
condition 2 6 33.3
subroutine 3 3 100.0
pod 0 1 0.0
total 22 29 75.8


line stmt bran cond sub pod time code
1             package Text::Microformat::Plugin::Include;
2 4     4   7730 use strict;
  4         8  
  4         168  
3 4     4   22 use warnings;
  4         7  
  4         886  
4              
5             sub post_parse {
6 20     20 0 4186 my $c = shift;
7 20         79 my @includes = $c->tree->look_down(
8             _tag => $c->tag_regex('object'),
9             class => $c->class_regex('include'),
10             );
11 20         3693 foreach my $source (@includes) {
12 2         73 my $id = $source->attr('data');
13 2 50 33     35 if (defined $id and length $id > 1 and $id =~ s/^#//) {
      33        
14 2         5 my ($target) = $c->tree->look_down(id => $id);
15 2 50       403 if ($target) {
16 2         10 $source->replace_with($target->clone)->delete;
17             }
18             }
19             }
20 20         168 return $c->NEXT::post_parse(@_);
21             }
22              
23             =head1 NAME
24              
25             Text::Microformat::Plugin::Include - a plugin providing the Microformat include pattern
26              
27             =head1 SEE ALSO
28              
29             L, L
30              
31             =head1 NAME
32              
33             Text::Microformat::Plugin::Parser::HTML - HTML parser plugin for Text::Microformat
34              
35             =head1 AUTHOR
36              
37             Keith Grennan, C<< >>
38              
39             =head1 BUGS
40              
41             Log bugs and feature requests here: L
42              
43             =head1 SUPPORT
44              
45             Project homepage: L
46              
47             =head1 COPYRIGHT & LICENSE
48              
49             Copyright 2007 Keith Grennan, all rights reserved.
50              
51             This program is free software; you can redistribute it and/or modify it
52             under the same terms as Perl itself.
53              
54             =cut
55              
56             1;