NAME
HTML::GMUCK - The Generated MarkUp ChecKer
SYNOPSIS
use HTML::GMUCK ();
my $gmuck = HTML::GMUCK->new( mode => 'XHTML',
tab_width => 4,
quote => '"',
);
my @elem_errors = $gmuck->elements ($string);
my @attr_arrors = $gmuck->attributes($string);
my @ent_errors = $gmuck->entities ($string);
my @doct_errors = $gmuck->doctype ($string);
my @mime_errors = $gmuck->mime_types($string);
my @depr_errors = $gmuck->deprecated($string);
my ($num_errors, $num_warnings) = $gmuck->stats();
DESCRIPTION
HTML::GMUCK is the module part of gmuck. It contains the logic for the checks and provides an OO interface to them.
CONSTRUCTORS
The following constructor is available:
- new
-
$gmuck = HTML::GMUCK->new( %options );
Class method, constructs a new
HTML::GMUCK
object and returns a reference to it.Options may be specified in key/value pairs:
mode sets the initial mode of the GMUCK object, the default is 'XHTML'. See mode().
tab_width the initial value of TAB width, the default is 4. See tab_width().
quote sets your preferred character for attribute quoting, the default is '"' (the double quote). See quote().
CHECKER METHODS
The checker methods contain the functionality of HTML::GMUCK. All of them are instance methods, take a list of lines as an argument, and return a list of errors.
For now, the lines passed as arguments will be checked one by one, but in the future, the meaning is that they will be checked as one logical entity. The idea is to provide a bit of context for checking. So to ensure future compatibility, pass only one line at a time.
The errors in the returned list are hash references, with the following keys:
line contains the line number (in the argument array of lines) where the error was found. Never undefined; the first line number is 0.
col contains the column (character) number where the error was found. Never undefined; the first column number is 0. This will also be 0 in the rare cases that the column could not be resolved.
type contains the type of the error. Never undefined, 'E' for errors, 'W' for warnings.
elem contains the element name (string) of the error. Undefined if not available.
attr contains the attribute name (string) of the error. Undefined if not available.
mesg contains the message for the error. Never undefined.
The following checker instance methods are available:
- elements
-
@errors = $gmuck->elements(@lines);
Checks elements; eg. the CasE of the elements and end tags.
- attributes
-
@errors = $gmuck->attributes(@lines);
Checks attributes.
- entities
-
@errors = $gmuck->entities(@lines);
Checks entities; eg. illegal '&' vs. '&' in URIs.
- doctype
-
@errors = $gmuck->doctype(@lines);
Checks DOCTYPE declarations.
- mime_types
-
@errors = $gmuck->mime_types(@lines);
Checks MIME types; eg. unregistered ones.
- deprecated
-
@errors = $gmuck->deprecated(@lines);
Checks deprecated things; eg. deprecated elements and attributes.
ACCESSORS, MUTATORS
The following accessor and mutator instance methods are available:
- mode
-
$mode = $gmuck->mode( [$mode] );
Gets, or if called with an optional argument, sets the mode of the object. Valid modes are 'XHTML', 'HTML' and 'XML'.
The mode of an HTML::GMUCK object affects the tests; you should set this corresponding to the kind of markup you are generating (or checking).
Note that setting the mode when the current mode is 'HTML' and the current quote character is '' (the empty string) will also set the quote character to '"' (the double quote).
- tab_width
-
$tab_width = $gmuck->tab_width( [$tab_width] );
Gets, or if called with the optional argument, sets the TAB width of the object. Valid values are integers > 0.
TAB width is used when calculating the line position for an error or warning message, ie. how many spaces does one TAB character count as.
- quote
-
$quote = $gmuck->quote( [$quote] );
Gets, or if called with an optional argument, sets the preferred quote character of the object. Valid values are '"' (the double quote), ''' (the single quote) and '' (the empty string).
- stats
-
($errors, $warnings) = $gmuck->stats();
Retrieves the count of errors and warnings that the object has found.
- reset
-
($errors, $warnings) = $gmuck->reset();
Similar to stats(), but also resets the error and warning counts to 0.
- full_version
-
($version) $gmuck->full_version();
Gets the version, with information about other packages in use. You can also call this as a function.
EXPORT
Nothing at the moment.
BUGS
This tool should have existed many years ago.
Due to the impossible task of this tool, there are and will be bugs, lots of them. There is a thin line between reporting lots of bogus errors and spotting enough real ones.
See BUGS in the distribution for an up to date list.
TODO
See TODO in the distribution for an up to date list.
SEE ALSO
The gmuck homepage, <URL:http://gmuck.sourceforge.net/>
The W3C HTML Validation Service <URL:http://validator.w3.org/>
WDG HTML Validator <URL:http://www.htmlhelp.com/tools/validator/>
Site Valet <URL:http://valet.htmlhelp.com/>
AUTHOR
Ville Skyttä <ville . skytta @ iki . fi>
COPYRIGHT
Copyright (C) 2001-2002 Ville Skyttä. All rights reserved.
This program is free software, you can redistribute it and/or modify it under the terms of The Artistic License or the GNU General Public License ("GPL") as published by the Free Software Foundation; either version 2 of the GPL, or (at your option) any later version.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 231:
Non-ASCII character seen before =encoding in 'Skyttä'. Assuming CP1252