HTML::Tagset - patch proposal for HTML 5 elements.

James Bromberger <[email protected]> Fri, 20 May 2011 12:41:00 +0800
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hello all,
At the suggestions of Andy Lester, I'd like to propose here a patch for
HTML::Tagset that add support for some of the HTML 5 elements that are
starting to make their way into the interwebs. I've trawled through
http://www.w3.org/TR/html5/, which right now the Working Draft dated 5th
April 2011, and cast my eye over the current editors draft dated 24 May
2011 (http://dev.w3.org/html5/spec/Overview.html) and tried to amend the
current data structures to cover the new elements.

My reason for raising this now is that the HTML5 spec elements are
starting to appear on documents on the internet, and with these tags
missing from HTML::Tagset, it impacts the effectiveness of other
libraries that depend upon it.

I'm not saying my patch works - nor has it been tested, but I submit
this to try and have those much wiser than I to poke it and see why my
understanding of the library falls down! :) In particular, I am unsure
if any of these elements would be considered as "barrier" elements for
implicit closures.

Many thanks,

  James
-- 
/Mobile:/ +61 422 166 708, /Email:/ james_AT_rcpt.to
<http://perth.pm.org>
html-tagset-3.20.patch.txt (text/plain, 1.7 KB)
--- 3.20/Tagset.pm      2011-05-20 11:50:41.987911127 +0800
+++ new/Tagset.pm       2011-05-20 12:24:38.519497374 +0800
@@ -95,6 +95,7 @@
  'a'       => ['href'],
  'applet'  => ['archive', 'codebase', 'code'],
  'area'    => ['href'],
+ 'audio'   => ['src'],
  'base'    => ['href'],
  'bgsound' => ['src'],
  'blockquote' => ['cite'],
@@ -115,10 +116,13 @@
  'object'  => ['classid', 'codebase', 'data', 'archive', 'usemap'],
  'q'       => ['cite'],
  'script'  => ['src', 'for'],
+ 'source'  => ['src'],
  'table'   => ['background'],
  'td'      => ['background'],
  'th'      => ['background'],
  'tr'      => ['background'],
+ 'track'   => ['src'],
+ 'video'   => ['poster'],
  'xmp'     => ['href'],
 );

@@ -185,6 +189,7 @@
   wbr nobr blink
   font basefont bdo
   spacer embed noembed
+  time mark ruby rp rt bdi bdo
 );  # had: center, hr, table


@@ -253,7 +258,7 @@
 =cut

 %isFormElement  = map {; $_ => 1 }
- qw(input select option optgroup textarea button label);
+ qw(input select option optgroup textarea button label keygen output progress meter );

 =head2 hashset %HTML::Tagset::isBodyElement

@@ -285,6 +290,10 @@
   table
   center
   form
+
+  section nav article aside hgroup figure
+  param video audio source track canvas
+  details summary command menu
  ),
  keys %isFormElement,
  keys %isPhraseMarkup,   # And everything phrasal
@@ -313,7 +322,7 @@
 %isKnown = (%isHeadElement, %isBodyElement,
   map{; $_=>1 }
    qw( head body html
-       frame frameset noframes
+       frame frameset noframes figcaption
        ~comment ~pi ~directive ~literal
 ));
  # that should be all known tags ever ever