Aozora2Epub

 view release on metacpan or  search on metacpan

lib/Aozora2Epub/XHTML/Tree.pm  view on Meta::CPAN

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    }
    return selector_to_xpath($selector);
}
 
sub _select {
    my ($self, $selector) = @_;
    $selector = _selector($selector);
    return [ $self->_result->findnodes($selector) ];
}
 
sub _apply(&$) { ## no critic (ProhibitSubroutinePrototypes)
    _apply0(@_);
}
 
sub _apply0 {
    my ($sub, $elem) = @_;
    if ($elem->isa('HTML::Element')) {
        return $sub->($elem);
    }
    return $elem;
}
 
sub _map_apply(&@) { ## no critic (ProhibitSubroutinePrototypes)
    my ($sub, @nodes) = @_;
    return map { _apply0($sub, $_) } @nodes;
}
 
sub _result {
    my ($self, $nodes) = @_;
    return $self->{result} unless $nodes;
    _apply { $_->detach } $_ for @$nodes;
    $self->{result} = HTML::Element->new_from_lol(['dummy', @$nodes]);
}



( run in 0.308 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )