Rhesa Rozendaal > CGI-Application-Plugin-HtmlTidy-1.05 > CGI::Application::Plugin::HtmlTidy

Download:
CGI-Application-Plugin-HtmlTidy-1.05.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.05   Source  

NAME ^

CGI::Application::Plugin::HtmlTidy - Add HTML::Tidy support to CGI::Application

VERSION ^

version 1.05

SYNOPSIS ^

  use CGI::Application::Plugin::HtmlTidy;
  
  sub cgiapp_postrun {
    my ($self, $contentref) = @_;

        # your post-process code here
        
    $self->htmltidy_clean($contentref);
  }

  
  # generate a validation report
  use CGI::Application::Plugin::DevPopup;
  use CGI::Application::Plugin::HtmlTidy;

CHANGES ^

This release integrates with CGI::Application::Plugin::DevPopup. If that plugin is active, this one will add an HTML validation report. As a consequence, htmltidy_validate() is no longer exported, and should not be called directly.

DESCRIPTION ^

This plugin is a wrapper around HTML::Tidy. It exports two methods that allow you to either validate or clean up the output of your cgiapp application. They should be called at the end of your postrun method.

The htmltidy_validate method is a helpful addition during development. It generates a detailed report specifying the issues with your html.

The htmltidy_clean modifies your output to conform to the W3C standards. It has been in use for quite some time on a largish site (generating over 10 million pages per day) and has proven to be quite stable and fast. Every single page view is valid html, which makes many browsers happy :-)

CONFIGURATION

libtidy is extremely configurable. It has many options to influence how it transforms your documents. HTML::Tidy communicates these options to libtidy through a configuration file. In the future, it may also allow programmatic access to all options.

You can specify the configuration using cgiapp's param() method, or in your instance script through the PARAM attribute, or through the htmltidy_config() method. This plugin looks for a parameter named htmltidy_config, whose value should be a hash ref. This hash ref is then passed on directly to HTML::Tidy. Currently the only supported parameter is "config_file".

Here's an example:

  sub setup {
    my $self = shift;
        $self->param( htmltidy_config => {
                            config_file => '/path/to/my/tidy.conf',
                        });
  }

This plugin comes with a default configuration file with the following settings:

        tidy-mark:      no
        wrap:           120
        indent:         auto
        output-xhtml:   yes
        char-encoding:  utf8
        doctype:        loose
        add-xml-decl:   yes
        alt-text:       [image]

EXPORT

htmltidy

Direct access to the underlying HTML::Tidy object.

htmltidy_config

Pass in a hash of options to configure the behaviour of this plugin. Accepted keys are:

config_file

The path to a config file used by tidy. See the tidy man page for details.

tidy config options

HTML::Tidy 1.08 now supports tidy options directly, so there is no need for a separate config file anymore.

htmltidy_validate

If you're using CGI::Application::Plugin::DevPopup, this method is used to generate a report for it.It parses your output, and generates a detailed report if it doesn't conform to standards.

htmltidy_clean

Parses and cleans your output to conform to standards.

SEE ALSO ^

CGI::Application, HTML::Tidy.

The cgiapp mailing list can be used for questions, comments and reports. The CPAN RT system can also be used.

AUTHOR ^

Rhesa Rozendaal, <rhesa@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005-2007 by Rhesa Rozendaal

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: