Hello

In order to get something approaching valid xhtml out of various other modules 
I've been happily using the patch below for a number of years, and had 
forgotten all about it until it resurfaced again so I thought I'd think about 
why I'm doing it and perhaps find a better way to do it that doesn't require 
patching

The idea being you set $HTML::Element::html_quote_all_attr = 1; and it quotes 
all attribute variable even numerics so you get <td height="1"> instead of 
<td height=1>

The fact that it isn't provided by HTML::Element makes me think its a bad 
idea.

Surely someone else is doing this or something like it as a step towards to 
producing valid xhtml?

For what its worth a gendiff style version of the patch is attached

Any suggestions for how I might do this in a better way greatfully received

Neil

< use vars qw($VERSION $html_uc $Debug $ID_COUNTER %list_type_to_sub);
---
> use vars qw($VERSION $html_uc $html_quote_all_attributes $Debug $ID_COUNTER 
%list_type_to_sub);
180a181,183
> $html_quote_all_attributes = 0;
> # set to 1 if you attribute values to be quoted (even numeric ones)
>
1896c1899
<             if ($val !~ m/^[0-9]+$/s) { # quote anything not purely numeric
---
>             if ($html_quote_all_attributes || $val !~ m/^[0-9]+$/s) { # 
quote anything not purely numeric
--- ./Element.pm.5.8.0.html_quote_all_attributes	2004-07-20 18:34:19.000000000 +0100
+++ ./Element.pm.5.8.0	2004-07-19 21:16:16.000000000 +0100
@@ -143,7 +143,7 @@
 use HTML::Tagset ();
 use integer; # vroom vroom!
 
-use vars qw($VERSION $html_uc $html_quote_all_attributes $Debug $ID_COUNTER %list_type_to_sub);
+use vars qw($VERSION $html_uc $Debug $ID_COUNTER %list_type_to_sub);
 
 $VERSION = '3.16';
 $Debug = 0 unless defined $Debug;
@@ -178,9 +178,6 @@
 # set to 1 if you want tag and attribute names from starttag and endtag
 #  to be uc'd
 
-$html_quote_all_attributes = 0;
-# set to 1 if you attribute values to be quoted (even numeric ones)
-
 # Elements that does not have corresponding end tags (i.e. are empty)
 
 #==========================================================================
@@ -1896,7 +1893,7 @@
         ) {
             $tag .= $html_uc ? " \U$_" : " \L$_";
         } else { # non-boolean attribute
-            if ($html_quote_all_attributes || $val !~ m/^[0-9]+$/s) { # quote anything not purely numeric
+            if ($val !~ m/^[0-9]+$/s) { # quote anything not purely numeric
               # Might as well double-quote everything, for simplicity's sake
               HTML::Entities::encode_entities($val, $entities);
               $val = qq{"$val"};

Reply via email to