HTML::Lint::Pluggable - plugin system for HTML::Lint
This document describes HTML::Lint::Pluggable version 0.10.
use HTML::Lint::Pluggable; my $lint = HTML::Lint::Pluggable->new; $lint->only_types( HTML::Lint::Error::STRUCTURE ); $lint->load_plugins(qw/HTML5/); while ( my $line = <HTML> ) { $lint->parse( $line ); } $lint->eof; # or $lint->parse_file( $filename ); my $error_count = $lint->errors; foreach my $error ( $lint->errors ) { print $error->as_string, "\n"; }
HTML::Lint::Pluggable adds plugin system for HTML::Lint.
HTML::Lint is useful. But, HTML::Lint can interpret *only* for rules of HTML4. and, HTML::Lint gives an error of "Character char should be written as entity" for such as for multi-byte characters. However, you are often no problem if they are properly encoded.
These problems can be solved easily to facilitate the various hooks for HTML::Lint.
$lint->load_plugin($module_name[, \%config])
This method loads plugin for the instance.
$module_name: package name of the plugin. You can write it as two form like DBIx::Class:
$lint->load_plugin("HTML5"); # => loads HTML::Lint::Pluggable::HTML5
If you want to load a plugin in your own name space, use '+' character before package name like following:
$lint->load_plugin("+MyApp::Plugin::XHTML"); # => loads MyApp::Plugin::XHTML
$lint->load_plugins($module_name[, \%config ], ...)
Load multiple plugins at one time.
$lint->load_plugins( qw/HTML5/, WhiteList => +{ rule => +{ 'attr-unknown' => sub { my $param = shift; if ($param->{tag} =~ /input|textarea/ && $param->{attr} eq 'istyle') { return 1; } else { return 0; } }, } } ); # => loads HTML::Lint::Pluggable::HTML5, HTML::Lint::Pluggable::WhiteList
this code is same as:
$lint->load_plugin('HTML5'); # => loads HTML::Lint::Pluggable::HTML5 $lint->load_plugin(WhiteList => +{ rule => +{ 'attr-unknown' => sub { my $param = shift; if ($param->{tag} =~ /input|textarea/ && $param->{attr} eq 'istyle') { return 1; } else { return 0; } }, } }); # => loads HTML::Lint::Pluggable::WhiteList
Perl 5.8.1 or later.
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.
HTML::Lint HTML::Tidy5
Kenta Sato <karupa@cpan.org>
Copyright (c) 2012, Kenta Sato. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTML::Lint::Pluggable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Lint::Pluggable
CPAN shell
perl -MCPAN -e shell install HTML::Lint::Pluggable
For more information on module installation, please visit the detailed CPAN module installation guide.