better description for tap methods
[catagits/DOM-Tiny.git] / lib / DOM / Tiny / HTML.pm
index 48a89e0..042ae5f 100644 (file)
@@ -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<DOM::Tiny::HTML> implements the following methods.
+L<DOM::Tiny::HTML> inherits a constructor from L<Class::Tiny::Object|Class::Tiny/"Object construction">,
+and implements the following methods.
 
 =head2 parse