X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDOM%2FTiny%2FHTML.pm;h=042ae5fd7a764434b86726e2e22ce2d4444865c7;hb=e99ef07d6c8b76be11c70996ce7edf40562b4625;hp=48a89e0099e915b9b6831024557a79d1c04c8207;hpb=927f135111d601e084c5a50e2d806bddd5c9cefb;p=catagits%2FDOM-Tiny.git diff --git a/lib/DOM/Tiny/HTML.pm b/lib/DOM/Tiny/HTML.pm index 48a89e0..042ae5f 100644 --- a/lib/DOM/Tiny/HTML.pm +++ b/lib/DOM/Tiny/HTML.pm @@ -2,7 +2,7 @@ package DOM::Tiny::HTML; use strict; use warnings; -use DOM::Tiny::Entities qw(html_unescape xml_escape); +use DOM::Tiny::Entities qw(html_escape html_unescape); use Scalar::Util 'weaken'; use Class::Tiny::Chained 'xml', { tree => sub { ['root'] } }; @@ -121,7 +121,7 @@ sub parse { # Attributes my (%attrs, $closing); while ($attr =~ /$ATTR_RE/go) { - my ($key, $value) = ($xml ? $1 : lc $1, defined $3 ? $3 : $4); + my ($key, $value) = ($xml ? $1 : lc $1, $3 // $4); # Empty tag ++$closing and next if $key eq '/'; @@ -196,7 +196,7 @@ sub _render { # Text (escaped) my $type = $tree->[0]; - return xml_escape($tree->[1]) if $type eq 'text'; + return html_escape($tree->[1]) if $type eq 'text'; # Raw text return $tree->[1] if $type eq 'raw'; @@ -225,7 +225,7 @@ sub _render { for my $key (sort keys %{$tree->[2]}) { my $value = $tree->[2]{$key}; $result .= $xml ? qq{ $key="$key"} : " $key" and next unless defined $value; - $result .= qq{ $key="} . xml_escape($value) . '"'; + $result .= qq{ $key="} . html_escape($value) . '"'; } # No children @@ -311,7 +311,8 @@ auto detection based on processing instructions. =head1 METHODS -L implements the following methods. +L inherits a constructor from L, +and implements the following methods. =head2 parse