use strict;
use warnings FATAL => 'all';
-use HTML::Zoom::MatchWithoutFilter;
+use HTML::Zoom::TransformBuilder;
sub _zconfig { shift->{_zconfig} }
if (exists $self->{_peeked}) {
return ($self->{_peeked});
}
- if (my ($peeked) = $self->next) {
+ if (my ($peeked) = $self->_next(1)) {
return ($self->{_peeked} = $peeked);
}
return;
}
+sub next {
+ my ($self) = @_;
+
+ # peeked entry so return that
+
+ if (exists $self->{_peeked}) {
+ if (my $peeked_from = delete $self->{_peeked_from}) {
+ $peeked_from->next;
+ }
+ return (delete $self->{_peeked});
+ }
+
+ $self->_next;
+}
+
+
sub flatten {
my $self = shift;
require HTML::Zoom::FlattenedStream;
$self->_zconfig->stream_utils->wrap_with_filter($self, $match, $filter);
}
+sub with_transform {
+ my ($self, $transform) = @_;
+ $transform->apply_to_stream($self);
+}
+
sub select {
my ($self, $selector) = @_;
- my $match = $self->_parse_selector($selector);
- return HTML::Zoom::MatchWithoutFilter->construct(
- $self, $match, $self->_zconfig->filter_builder,
- );
+ return HTML::Zoom::TransformBuilder->new({
+ zconfig => $self->_zconfig,
+ selector => $selector,
+ filters => [],
+ proto => $self,
+ });
}
-sub _parse_selector {
- my ($self, $selector) = @_;
- return $selector if ref($selector); # already a match sub
- $self->_zconfig->selector_parser->parse_selector($selector);
+sub then {
+ my ($self) = @_;
+ # see notes in HTML/Zoom.pm for why this needs to be fixed
+ $self->select($self->transform->selector);
}
sub apply {
$self->$code;
}
+sub to_html {
+ my ($self) = @_;
+ $self->_zconfig->producer->html_from_stream($self);
+}
+
1;