X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FParser%2FBuiltIn.pm;h=efa07cbc597ae899d2018784e9fcae90508795a5;hb=1cf035405cb81b780825c083cf7f5c0767b19243;hp=30da5d6bb1b2c28ee938a9fca79d329cec0f30e7;hpb=f8ed299b5a37e9ff273ee064f7087449353c69d8;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/Parser/BuiltIn.pm b/lib/HTML/Zoom/Parser/BuiltIn.pm index 30da5d6..efa07cb 100644 --- a/lib/HTML/Zoom/Parser/BuiltIn.pm +++ b/lib/HTML/Zoom/Parser/BuiltIn.pm @@ -1,20 +1,19 @@ package HTML::Zoom::Parser::BuiltIn; -use strict; -use warnings FATAL => 'all'; - -use HTML::Zoom::CodeStream; +use strictures 1; +use base qw(HTML::Zoom::SubObject); sub html_to_events { - my ($class, $text) = @_; + my ($self, $text) = @_; my @events; _hacky_tag_parser($text => sub { push @events, $_[0] }); return \@events; } sub html_to_stream { - my ($class, $text) = @_; - return HTML::Zoom::CodeStream->from_array(@{$class->html_to_events($text)}); + my ($self, $text) = @_; + return $self->_zconfig->stream_utils + ->stream_from_array(@{$self->html_to_events($text)}); } sub _hacky_tag_parser { @@ -32,28 +31,31 @@ sub _hacky_tag_parser { ([^<]*) }sxg ) { - my ($whole, $is_close, $tag_name, $attributes, $is_comment, + my ($whole, $is_close, $tag_name, $attributes, $is_special, $in_place_close, $content) = ($1, $2, $3, $4, $5, $6, $7, $8); - next if defined $is_comment; - $tag_name =~ tr/A-Z/a-z/; - if ($is_close) { - $handler->({ type => 'CLOSE', name => $tag_name, raw => $whole }); + if ($is_special) { + $handler->({ type => 'SPECIAL', raw => $whole }); } else { - $attributes = '' if !defined($attributes) or $attributes =~ /^ +$/; - $handler->({ - type => 'OPEN', - name => $tag_name, - is_in_place_close => $in_place_close, - _hacky_attribute_parser($attributes), - raw_attrs => $attributes||'', - raw => $whole, - }); - if ($in_place_close) { + $tag_name =~ tr/A-Z/a-z/; + if ($is_close) { + $handler->({ type => 'CLOSE', name => $tag_name, raw => $whole }); + } else { + $attributes = '' if !defined($attributes) or $attributes =~ /^ +$/; $handler->({ - type => 'CLOSE', name => $tag_name, raw => '', - is_in_place_close => 1 + type => 'OPEN', + name => $tag_name, + is_in_place_close => $in_place_close, + _hacky_attribute_parser($attributes), + raw_attrs => $attributes||'', + raw => $whole, }); + if ($in_place_close) { + $handler->({ + type => 'CLOSE', name => $tag_name, raw => '', + is_in_place_close => 1 + }); + } } } if (length $content) {