On 2005-04-24, Rhesa Rozendaal <[EMAIL PROTECTED]> wrote:
> # In my base class:
>
> use HTML::Tidy 1.05_02; # this version has support for config files
> our $HTMLTIDY;
>
> sub tidy_clean
> {
>      my ($self, $html) = @_;
>      $HTMLTIDY ||= HTML::Tidy->new({config_file => '/etc/tidy.conf'});
>      return $HTMLTIDY->clean($html);
> }
>
> # somewhere in postrun:
>
>      if($self->header_type eq 'header')
>      {
>          my %props = $self->header_props;
>          if(!exists($props{'-type'}) or $props{'-type'} eq 'text/html')
>          {
>              $self->header_add(-type=>'text/html', -charset=>'utf-8');
>
>              $$outputref = $self->tidy_clean($$outputref);
>              if( $outputref !~ m/equiv.*charset/ )
>              {
>                  $$outputref =~ s|(<head.*?>)|$1\n  <meta 
> http-equiv="Content-Type" content="text/html; charset=utf-8" />|si;
>              }
>
>              $self->header_add(-Content_length=>length($$outputref));
>          }
>      }
>
> With the new proposed callback functionality, this could be added completely 
> transparently. For the current version of cgi-app, it can still 
> be added with very little code. I don't think the utf8 code _has_ to be in 
> there, but I needed it.
>
> Do you think it would make sense to make a plugin for this?

Yes. It sounds like something someone else would find useful. My
ValidateRM is nearly as short.

    Mark

--
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark Stosberg            Principal Developer  
   [EMAIL PROTECTED]     Summersault, LLC     
   765-939-9301 ext 202     database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to