NAME
HTML::Valid - tidy/validate HTML
SYNOPSIS
use FindBin '$Bin';
use HTML::Valid;
my $html = <<EOF;
<ul>
<li>Shape it up
<li>Get straight
<li>Go forward
<li>Move ahead
<li>Try to detect it
<li>It's not too late
EOF
my $htv = HTML::Valid->new ();
my ($output, $errors) = $htv->run ($html);
print "$output\n";
print "$errors\n";
outputs
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 for FreeBSD version 5.0.0">
<title></title>
</head>
<body>
<ul>
<li>Shape it up</li>
<li>Get straight</li>
<li>Go forward</li>
<li>Move ahead</li>
<li>Try to detect it</li>
<li>It's not too late</li>
</ul>
</body>
</html>
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 1 - Warning: inserting implicit <body>
line 2 column 1 - Info: missing optional end tag </li>
line 3 column 1 - Info: missing optional end tag </li>
line 4 column 1 - Info: missing optional end tag </li>
line 5 column 1 - Info: missing optional end tag </li>
line 6 column 1 - Info: missing optional end tag </li>
line 1 column 1 - Warning: missing </ul>
line 1 column 1 - Warning: inserting missing 'title' element
Info: Document content looks like HTML5
Tidy found 4 warnings and 0 errors!
VERSION
This documents HTML::Valid version 0.08 corresponding to git commit e5beaaba00502cc4aba10db6bba5b0758f64726d released on Thu May 20 08:07:15 2021 +0900.
This Perl module is built on top of the "HTML Tidy" library version 5.7.28.
DESCRIPTION
Validate/repair HTML. This module is based on "HTML Tidy", but not on the Perl module HTML::Tidy. However, you do not need to install HTML Tidy before installing this, because the library is contained in the distribution.
FUNCTIONS
new
my $htv = HTML::Valid->new ();
Make a new HTML::Valid object.
It's also possible to supply options, as described in "OPTIONS":
$htv->new (
show_body_only => 1,
alt_text => 'An image of a polar bear',
);
run
my ($output, $errors) = $htv->run ($content);
Get the tidy HTML output and errors. This is basically the same thing as running the "tidy" utility with the given options.
set_filename
$htv->set_filename ('file.html');
Set the file name for error reporting to file.html.
set_option
$htv->set_option ('omit-optional-tags', 1);
Most of the options of "HTML Tidy" are supported.
OPTIONS
The following options can be set with "set_option". In this documentation they are given with a hyphen, but underscores can also be used. Options taking true or false values test for truth or falsehood using the standard Perl tests, so empty strings, the undefined value, or zero are all valid "false" values.
Please note the following documentation of the options is automatically extracted from the "HTML Tidy" documentation.
- accessibility-check
-
$htv->set_option ('accessibility-check', <value>);
Type: integer
Default: 0
This option specifies what level of accessibility checking, if any, that Tidy should perform.
Level
0 (Tidy Classic)
is equivalent to Tidy Classic's accessibility checking.For more information on Tidy's accessibility checking, visit Tidy's Accessibility Page.
- add-xml-decl
-
$htv->set_option ('add-xml-decl', <value>);
Type: true or false
Default: false
This option specifies if Tidy should add the XML declaration when outputting XML or XHTML.
Note that if the input already includes an
<?xml ... ?>
declaration then this option will be ignored.If the encoding for the output is different from
ascii
, one of the utf encodings orraw
, the declaration is always added as required by the XML standard. - add-xml-space
-
$htv->set_option ('add-xml-space', <value>);
Type: true or false
Default: false
This option specifies if Tidy should add
xml:space="preserve"
to elements such as<pre>
,<style>
and<script>
when generating XML.This is needed if the whitespace in such elements is to be parsed appropriately without having access to the DTD.
- alt-text
-
$htv->set_option ('alt-text', <value>);
Type: string
Default: <empty>
This option specifies the default
alt=
text Tidy uses for<img>
attributes.Use with care, as this feature suppresses further accessibility warnings.
- anchor-as-name
-
$htv->set_option ('anchor-as-name', <value>);
Type: true or false
Default: true
This option controls the deletion or addition of the
name
attribute in elements where it can serve as anchor.If set to
yes
aname
attribute, if not already existing, is added along an existingid
attribute if the DTD allows it.If set to
no
any existing name attribute is removed if anid
attribute exists or has been added. - ascii-chars
-
$htv->set_option ('ascii-chars', <value>);
Type: true or false
Default: false
Can be used to modify behavior of the
clean
option when set toyes
.If set to
yes
whenclean
,&emdash;
,”
, and other named character entities are downgraded to their closest ASCII equivalents. - assume-xml-procins
-
$htv->set_option ('assume-xml-procins', <value>);
Type: true or false
Default: false
This option specifies if Tidy should change the parsing of processing instructions to require
?>
as the terminator rather than>
.This option is automatically set if the input is in XML.
- bare
-
$htv->set_option ('bare', <value>);
Type: true or false
Default: false
This option specifies if Tidy should strip Microsoft specific HTML from Word 2000 documents, and output spaces rather than non-breaking spaces where they exist in the input.
- break-before-br
-
$htv->set_option ('break-before-br', <value>);
Type: true or false
Default: false
This option specifies if Tidy should output a line break before each
<br>
element. - clean
-
$htv->set_option ('clean', <value>);
Type: true or false
Default: false
This option specifies if Tidy should perform cleaning of some legacy presentational tags (currently
<i>
,<b>
,<center>
when enclosed within appropriate inline tags, and<font>
). If set toyes
then legacy tags will be replaced with CSS<style>
tags and structural markup as appropriate. -
$htv->set_option ('coerce-endtags', <value>);
Type: true or false
Default: true
This option specifies if Tidy should coerce a start tag into an end tag in cases where it looks like an end tag was probably intended; for example, given
<span>foo <b>bar<b> baz</span>
Tidy will output
<span>foo <b>bar</b> baz</span>
- css-prefix
-
$htv->set_option ('css-prefix', <value>);
Type: string
Default: <empty>
This option specifies the prefix that Tidy uses for styles rules.
By default,
c
will be used. - decorate-inferred-ul
-
$htv->set_option ('decorate-inferred-ul', <value>);
Type: true or false
Default: false
This option specifies if Tidy should decorate inferred
<ul>
elements with some CSS markup to avoid indentation to the right. - doctype
-
$htv->set_option ('doctype', <value>);
Type: string
Default: <empty>
This option specifies the DOCTYPE declaration generated by Tidy.
If set to
omit
the output won't contain a DOCTYPE declaration. Note this this also impliesnumeric-entities
is set toyes
If set to
html5
the DOCTYPE is set to<!DOCTYPE html>
.If set to
auto
(the default) Tidy will use an educated guess based upon the contents of the document.If set to
strict
, Tidy will set the DOCTYPE to the HTML4 or XHTML1 strict DTD.If set to
loose
, the DOCTYPE is set to the HTML4 or XHTML1 loose (transitional) DTD.Alternatively, you can supply a string for the formal public identifier (FPI).
For example:
doctype: "-//ACME//DTD HTML 3.14159//EN"
If you specify the FPI for an XHTML document, Tidy will set the system identifier to an empty string. For an HTML document, Tidy adds a system identifier only if one was already present in order to preserve the processing mode of some browsers. Tidy leaves the DOCTYPE for generic XML documents unchanged.
This option does not offer a validation of document conformance.
- drop-empty-elements
-
$htv->set_option ('drop-empty-elements', <value>);
Type: true or false
Default: true
This option specifies if Tidy should discard empty elements.
- drop-empty-paras
-
$htv->set_option ('drop-empty-paras', <value>);
Type: true or false
Default: true
This option specifies if Tidy should discard empty paragraphs.
-
$htv->set_option ('drop-font-tags', <value>);
Type: true or false
Default: false
Deprecated; do not use. This option is destructive to
<font>
tags, and it will be removed from future versions of Tidy. Use theclean
option instead.If you do set this option despite the warning it will perform as
clean
except styles will be inline instead of put into a CSS class.<font>
tags will be dropped completely and their styles will not be preserved.If both
clean
and this option are enabled,<font>
tags will still be dropped completely, and other styles will be preserved in a CSS class instead of inline.See
clean
for more information. - drop-proprietary-attributes
-
$htv->set_option ('drop-proprietary-attributes', <value>);
Type: true or false
Default: false
This option specifies if Tidy should strip out proprietary attributes, such as Microsoft data binding attributes.
- enclose-block-text
-
$htv->set_option ('enclose-block-text', <value>);
Type: true or false
Default: false
This option specifies if Tidy should insert a
<p>
element to enclose any text it finds in any element that allows mixed content for HTML transitional but not HTML strict. - enclose-text
-
$htv->set_option ('enclose-text', <value>);
Type: true or false
Default: false
This option specifies if Tidy should enclose any text it finds in the body element within a
<p>
element.This is useful when you want to take existing HTML and use it with a style sheet.
- escape-cdata
-
$htv->set_option ('escape-cdata', <value>);
Type: true or false
Default: false
This option specifies if Tidy should convert
<![CDATA[]]>
sections to normal text. - fix-backslash
-
$htv->set_option ('fix-backslash', <value>);
Type: true or false
Default: true
This option specifies if Tidy should replace backslash characters
\
in URLs with forward slashes/
. - fix-bad-comments
-
$htv->set_option ('fix-bad-comments', <value>);
Type: true or false
Default: true
This option specifies if Tidy should replace unexpected hyphens with
=
characters when it comes across adjacent hyphens.The default is
yes
.This option is provided for users of Cold Fusion which uses the comment syntax:
<!--- --->
. - fix-uri
-
$htv->set_option ('fix-uri', <value>);
Type: true or false
Default: true
This option specifies if Tidy should check attribute values that carry URIs for illegal characters and if such are found, escape them as HTML4 recommends.
- force-output
-
$htv->set_option ('force-output', <value>);
Type: true or false
Default: false
This option specifies if Tidy should produce output even if errors are encountered.
Use this option with care; if Tidy reports an error, this means Tidy was not able to (or is not sure how to) fix the error, so the resulting output may not reflect your intention.
- gdoc
-
$htv->set_option ('gdoc', <value>);
Type: true or false
Default: false
This option specifies if Tidy should enable specific behavior for cleaning up HTML exported from Google Docs.
- gnu-emacs
-
$htv->set_option ('gnu-emacs', <value>);
Type: true or false
Default: false
This option specifies if Tidy should change the format for reporting errors and warnings to a format that is more easily parsed by GNU Emacs.
- hide-comments
-
$htv->set_option ('hide-comments', <value>);
Type: true or false
Default: false
This option specifies if Tidy should print out comments.
-
$htv->set_option ('hide-endtags', <value>);
Type: true or false
Default: false
This option is an alias for
omit-optional-tags
. - indent
-
$htv->set_option ('indent', <value>);
Type: integer
Default: 0
This option specifies if Tidy should indent block-level tags.
If set to
auto
Tidy will decide whether or not to indent the content of tags such as<title>
,<h1>
-<h6>
,<li>
,<td>
, or<p>
based on the content including a block-level element.Setting
indent
toyes
can expose layout bugs in some browsers.Use the option
indent-spaces
to control the number of spaces or tabs output per level of indent, andindent-with-tabs
to specify whether spaces or tabs are used. - indent-attributes
-
$htv->set_option ('indent-attributes', <value>);
Type: true or false
Default: false
This option specifies if Tidy should begin each attribute on a new line.
- indent-cdata
-
$htv->set_option ('indent-cdata', <value>);
Type: true or false
Default: false
This option specifies if Tidy should indent
<![CDATA[]]>
sections. - indent-spaces
-
$htv->set_option ('indent-spaces', <value>);
Type: integer
Default: 2
This option specifies the number of spaces or tabs that Tidy uses to indent content when
indent
is enabled.Note that the default value for this option is dependent upon the value of
indent-with-tabs
(see also). - indent-with-tabs
-
$htv->set_option ('indent-with-tabs', <value>);
Type: true or false
Default: false
This option specifies if Tidy should indent with tabs instead of spaces, assuming
indent
isyes
.Set it to
yes
to indent using tabs instead of the default spaces.Use the option
indent-spaces
to control the number of tabs output per level of indent. Note that whenindent-with-tabs
is enabled the default value ofindent-spaces
is reset to1
.Note
tab-size
controls converting input tabs to spaces. Set it to zero to retain input tabs. - input-xml
-
$htv->set_option ('input-xml', <value>);
Type: true or false
Default: false
This option specifies if Tidy should use the XML parser rather than the error correcting HTML parser.
- join-classes
-
$htv->set_option ('join-classes', <value>);
Type: true or false
Default: false
This option specifies if Tidy should combine class names to generate a single, new class name if multiple class assignments are detected on an element.
- join-styles
-
$htv->set_option ('join-styles', <value>);
Type: true or false
Default: true
This option specifies if Tidy should combine styles to generate a single, new style if multiple style values are detected on an element.
- language
-
$htv->set_option ('language', <value>);
Type: string
Default: <empty>
Currently not used, but this option specifies the language Tidy would use if it were properly localized. For example:
en
. - literal-attributes
-
$htv->set_option ('literal-attributes', <value>);
Type: true or false
Default: false
This option specifies how Tidy deals with whitespace characters within attribute values.
If the value is
no
Tidy normalizes attribute values by replacing any newline or tab with a single space, and further by replacing any contiguous whitespace with a single space.To force Tidy to preserve the original, literal values of all attributes and ensure that whitespace within attribute values is passed through unchanged, set this option to
yes
. - logical-emphasis
-
$htv->set_option ('logical-emphasis', <value>);
Type: true or false
Default: false
This option specifies if Tidy should replace any occurrence of
<i>
with<em>
and any occurrence of<b>
with<strong>
. Any attributes are preserved unchanged.This option can be set independently of the
clean
option. - lower-literals
-
$htv->set_option ('lower-literals', <value>);
Type: true or false
Default: true
This option specifies if Tidy should convert the value of an attribute that takes a list of predefined values to lower case.
This is required for XHTML documents.
- markup
-
$htv->set_option ('markup', <value>);
Type: true or false
Default: true
This option specifies if Tidy should generate a pretty printed version of the markup. Note that Tidy won't generate a pretty printed version if it finds significant errors (see
force-output
). - merge-divs
-
$htv->set_option ('merge-divs', <value>);
Type: integer
Default: 2
This option can be used to modify the behavior of
clean
when set toyes
.This option specifies if Tidy should merge nested
<div>
such as<div><div>...</div></div>
.If set to
auto
the attributes of the inner<div>
are moved to the outer one. Nested<div>
withid
attributes are not merged.If set to
yes
the attributes of the inner<div>
are discarded with the exception ofclass
andstyle
. - merge-emphasis
-
$htv->set_option ('merge-emphasis', <value>);
Type: true or false
Default: true
This option specifies if Tidy should merge nested
<b>
and<i>
elements; for example, for the case<b class="rtop-2">foo <b class="r2-2">bar</b> baz</b>
,Tidy will output
<b class="rtop-2">foo bar baz</b>
. - merge-spans
-
$htv->set_option ('merge-spans', <value>);
Type: integer
Default: 2
This option can be used to modify the behavior of
clean
when set toyes
.This option specifies if Tidy should merge nested
<span>
such as<span><span>...</span></span>
.The algorithm is identical to the one used by
merge-divs
. - ncr
-
$htv->set_option ('ncr', <value>);
Type: true or false
Default: true
This option specifies if Tidy should allow numeric character references.
-
$htv->set_option ('new-blocklevel-tags', <value>);
Type: string
Default: <empty>
This option specifies new block-level tags. This option takes a space or comma separated list of tag names.
Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
Note you can't change the content model for elements such as
<table>
,<ul>
,<ol>
and<dl>
.This option is ignored in XML mode.
-
$htv->set_option ('new-empty-tags', <value>);
Type: string
Default: <empty>
This option specifies new empty inline tags. This option takes a space or comma separated list of tag names.
Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
Remember to also declare empty tags as either inline or blocklevel.
This option is ignored in XML mode.
-
$htv->set_option ('new-inline-tags', <value>);
Type: string
Default: <empty>
This option specifies new non-empty inline tags. This option takes a space or comma separated list of tag names.
Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
This option is ignored in XML mode.
-
$htv->set_option ('new-pre-tags', <value>);
Type: string
Default: <empty>
This option specifies new tags that are to be processed in exactly the same way as HTML's
<pre>
element. This option takes a space or comma separated list of tag names.Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
Note you cannot as yet add new CDATA elements.
This option is ignored in XML mode.
- newline
-
$htv->set_option ('newline', <value>);
Type: integer
Default: 0
The default is appropriate to the current platform.
Genrally CRLF on PC-DOS, Windows and OS/2; CR on Classic Mac OS; and LF everywhere else (Linux, Mac OS X, and Unix).
- numeric-entities
-
$htv->set_option ('numeric-entities', <value>);
Type: true or false
Default: false
This option specifies if Tidy should output entities other than the built-in HTML entities (
&
,<
,>
, and"
) in the numeric rather than the named entity form.Only entities compatible with the DOCTYPE declaration generated are used.
Entities that can be represented in the output encoding are translated correspondingly.
-
$htv->set_option ('omit-optional-tags', <value>);
Type: true or false
Default: false
This option specifies if Tidy should omit optional start tags and end tags when generating output.
Setting this option causes all tags for the
<html>
,<head>
, and<body>
elements to be omitted from output, as well as such end tags as</p>
,</li>
,</dt>
,</dd>
,</option>
,</tr>
,</td>
, and</th>
.This option is ignored for XML output.
- output-html
-
$htv->set_option ('output-html', <value>);
Type: true or false
Default: false
This option specifies if Tidy should generate pretty printed output, writing it as HTML.
- output-xhtml
-
$htv->set_option ('output-xhtml', <value>);
Type: true or false
Default: false
This option specifies if Tidy should generate pretty printed output, writing it as extensible HTML.
This option causes Tidy to set the DOCTYPE and default namespace as appropriate to XHTML, and will use the corrected value in output regardless of other sources.
For XHTML, entities can be written as named or numeric entities according to the setting of
numeric-entities
.The original case of tags and attributes will be preserved, regardless of other options.
- output-xml
-
$htv->set_option ('output-xml', <value>);
Type: true or false
Default: false
This option specifies if Tidy should pretty print output, writing it as well-formed XML.
Any entities not defined in XML 1.0 will be written as numeric entities to allow them to be parsed by an XML parser.
The original case of tags and attributes will be preserved, regardless of other options.
- preserve-entities
-
$htv->set_option ('preserve-entities', <value>);
Type: true or false
Default: false
This option specifies if Tidy should preserve well-formed entities as found in the input.
- punctuation-wrap
-
$htv->set_option ('punctuation-wrap', <value>);
Type: true or false
Default: false
This option specifies if Tidy should line wrap after some Unicode or Chinese punctuation characters.
- quiet
-
$htv->set_option ('quiet', <value>);
Type: true or false
Default: false
This option specifies if Tidy should output the summary of the numbers of errors and warnings, or the welcome or informational messages.
- quote-ampersand
-
$htv->set_option ('quote-ampersand', <value>);
Type: true or false
Default: true
This option specifies if Tidy should output unadorned
&
characters as&
. - quote-marks
-
$htv->set_option ('quote-marks', <value>);
Type: true or false
Default: false
This option specifies if Tidy should output
"
characters as"
as is preferred by some editing environments.The apostrophe character
'
is written out as'
since many web browsers don't yet support'
. - quote-nbsp
-
$htv->set_option ('quote-nbsp', <value>);
Type: true or false
Default: true
This option specifies if Tidy should output non-breaking space characters as entities, rather than as the Unicode character value 160 (decimal).
- repeated-attributes
-
$htv->set_option ('repeated-attributes', <value>);
Type: integer
Default: 1
This option specifies if Tidy should keep the first or last attribute, if an attribute is repeated, e.g. has two
align
attributes. - replace-color
-
$htv->set_option ('replace-color', <value>);
Type: true or false
Default: false
This option specifies if Tidy should replace numeric values in color attributes with HTML/XHTML color names where defined, e.g. replace
#ffffff
withwhite
. - show-body-only
-
$htv->set_option ('show-body-only', <value>);
Type: integer
Default: 0
This option specifies if Tidy should print only the contents of the body tag as an HTML fragment.
If set to
auto
, this is performed only if the body tag has been inferred.Useful for incorporating existing whole pages as a portion of another page.
This option has no effect if XML output is requested.
- show-errors
-
$htv->set_option ('show-errors', <value>);
Type: integer
Default: 6
This option specifies the number Tidy uses to determine if further errors should be shown. If set to
0
, then no errors are shown. - show-info
-
$htv->set_option ('show-info', <value>);
Type: true or false
Default: true
This option specifies if Tidy should display info-level messages.
- show-warnings
-
$htv->set_option ('show-warnings', <value>);
Type: true or false
Default: true
This option specifies if Tidy should suppress warnings. This can be useful when a few errors are hidden in a flurry of warnings.
- skip-nested
-
$htv->set_option ('skip-nested', <value>);
Type: true or false
Default: true
This option specifies that Tidy should skip nested tags when parsing script and style data.
- slide-style
-
$htv->set_option ('slide-style', <value>);
Type: string
Default: <empty>
This option has no function and is deprecated.
- sort-attributes
-
$htv->set_option ('sort-attributes', <value>);
Type: integer
Default: 0
This option specifies that Tidy should sort attributes within an element using the specified sort algorithm. If set to
alpha
, the algorithm is an ascending alphabetic sort. - split
-
$htv->set_option ('split', <value>);
Type: true or false
Default: false
This option has no function and is deprecated.
- tab-size
-
$htv->set_option ('tab-size', <value>);
Type: integer
Default: 8
This option specifies the number of columns that Tidy uses between successive tab stops. It is used to map tabs to spaces when reading the input.
- tidy-mark
-
$htv->set_option ('tidy-mark', <value>);
Type: true or false
Default: true
This option specifies if Tidy should add a
meta
element to the document head to indicate that the document has been tidied.Tidy won't add a meta element if one is already present.
- uppercase-attributes
-
$htv->set_option ('uppercase-attributes', <value>);
Type: true or false
Default: false
This option specifies if Tidy should output attribute names in upper case.
The default is
no
, which results in lower case attribute names, except for XML input, where the original case is preserved. -
$htv->set_option ('uppercase-tags', <value>);
Type: true or false
Default: false
This option specifies if Tidy should output tag names in upper case.
The default is
no
which results in lower case tag names, except for XML input where the original case is preserved. - vertical-space
-
$htv->set_option ('vertical-space', <value>);
Type: integer
Default: 0
This option specifies if Tidy should add some extra empty lines for readability.
The default is
no
.If set to
auto
Tidy will eliminate nearly all newline characters. - word-2000
-
$htv->set_option ('word-2000', <value>);
Type: true or false
Default: false
This option specifies if Tidy should go to great pains to strip out all the surplus stuff Microsoft Word 2000 inserts when you save Word documents as "Web pages". It doesn't handle embedded images or VML.
You should consider using Word's "Save As: Web Page, Filtered".
- wrap
-
$htv->set_option ('wrap', <value>);
Type: integer
Default: 68
This option specifies the right margin Tidy uses for line wrapping.
Tidy tries to wrap lines so that they do not exceed this length.
Set
wrap
to0
(zero) if you want to disable line wrapping. - wrap-asp
-
$htv->set_option ('wrap-asp', <value>);
Type: true or false
Default: true
This option specifies if Tidy should line wrap text contained within ASP pseudo elements, which look like:
<% ... %>
. - wrap-attributes
-
$htv->set_option ('wrap-attributes', <value>);
Type: true or false
Default: false
This option specifies if Tidy should line-wrap attribute values, meaning that if the value of an attribute causes a line to exceed the width specified by
wrap
, Tidy will add one or more line breaks to the value, causing it to be wrapped into multiple lines.Note that this option can be set independently of
wrap-script-literals
. By default Tidy replaces any newline or tab with a single space and replaces any sequences of whitespace with a single space.To force Tidy to preserve the original, literal values of all attributes, and ensure that whitespace characters within attribute values are passed through unchanged, set
literal-attributes
toyes
. - wrap-jste
-
$htv->set_option ('wrap-jste', <value>);
Type: true or false
Default: true
This option specifies if Tidy should line wrap text contained within JSTE pseudo elements, which look like:
<# ... #>
. - wrap-php
-
$htv->set_option ('wrap-php', <value>);
Type: true or false
Default: true
This option specifies if Tidy should line wrap text contained within PHP pseudo elements, which look like:
<?php ... ?>
. - wrap-script-literals
-
$htv->set_option ('wrap-script-literals', <value>);
Type: true or false
Default: false
This option specifies if Tidy should line wrap string literals that appear in script attributes.
Tidy wraps long script string literals by inserting a backslash character before the line break.
- wrap-sections
-
$htv->set_option ('wrap-sections', <value>);
Type: true or false
Default: true
This option specifies if Tidy should line wrap text contained within
<![ ... ]>
section tags.
(The above options were generated from the documentation of HTML Tidy 5.1.25, so they may be outdated relative to the current version.)
SCRIPT
There are two scripts, "htmlok", which runs on files or URLs and prints errors found to standard output, and "htmltidy", which runs on files or URLs and prints the reformatted HTML to standard output, with errors going to standard error. To use these scripts with URL validation, you need to have Data::Validate::URI and LWP::Simple installed.
SEE ALSO
HTML Tidy
This is a program and a library in C for improving HTML. It was originally written by Dave Raggett of the W3 Consortium. HTML::Valid is based on this project.
Please note that this is not the Perl module HTML::Tidy by Andy Lester, although that module is also based on the above library.
HTML standards
This section gives links to the HTML standards which HTML::Valid supports.
HTML 2.0
HTML 2.0 was described in RFC ("Request For Comments") 1866, a standard of the Internet Engineering Task Force. See http://www.ietf.org/rfc/rfc1866.txt.
HTML 3.2
This was described in the HTML 3.2 Reference Specification. See http://www.w3.org/TR/REC-html32.
HTML 4.01
This was described in the HTML 4.01 Specification. See http://www.w3.org/TR/html401/.
HTML5
- Dive into HTML5
-
This isn't a standards document, but "Dive into HTML 5" may be good background reading before trying to read the standards documents.
- HTML: The Living Standard
-
This is at https://developers.whatwg.org/. It says
This specification is intended for authors of documents and scripts that use the features defined in this specification.
- HTML5 - A vocabulary and associated APIs for HTML and XHTML
-
This is at http://www.w3.org/TR/html5/. It's the W3 consortium's version of the WHATWG documents.
Online HTML validators
You may like to try these validators for checking your HTML.
- http://www.onlinewebcheck.com/
-
Commercial HTML validator.
- http://watson.addy.com/
- https://validator.w3.org/
-
W3 Consortium validator.
- https://validator.w3.org/nu/
-
New W3 Consortium validator.
CPAN modules
- HTML::Tidy
- HTML::Lint
- HTML::Normalize
- HTML::Validator
-
There is another module called HTML::Validator, but it can only be found on Backpan, dating from 2000. It uses an external XML validating tool. See http://backpan.perl.org/authors/id/S/SA/SAIT/.
Other
- JWZ's validate script
-
From the documentation:
A small HTML validator: really all this does is make sure your tags are balanced, that your tables aren't missing TRs around the TDs, and that the local files that any relative URLs point to exist. There are much more fully-featured validators out there, but I haven't found them very useful: when all I want to know is "you left out a </UL>", they tend to spend their time whining at me about "where's your DTD?" and similar nonsense.
DEPENDENCIES
- JSON::Parse
-
This is used to read a file of options
BUILD PROCESS
This module is built from "HTML Tidy" source code using a script which converts the HTML Tidy library into a single C file. This is available in the github repository as tools/make-c-file.pl, but is not in the CPAN distribution. This also includes extra C functions in extra.c into the library to access internals which are not part of the public interface. This is used for creating the machine-readable file of option documentation included above in "OPTIONS" and for creating the tables of tags and attributes in HTML::Valid::Tagset.
AUTHOR
Ben Bullock <bkb@cpan.org>
COPYRIGHT AND LICENCE
HTML::Valid is based on HTML Tidy, which is under the following copyright:
HTML Tidy
HTML parser and pretty printer
Copyright (c) 1998-2016 World Wide Web Consortium (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University). All Rights Reserved.
Additional contributions (c) 2001-2016 University of Toronto, Terry Teague, @geoffmcl, HTACG, and others.
Contributing Author(s):
Dave Raggett <dsr@w3.org>
The contributing author(s) would like to thank all those who helped with testing, bug fixes and suggestions for improvements. This wouldn't have been possible without your help.
COPYRIGHT NOTICE:
This software and documentation is provided "as is," and the copyright holders and contributing author(s) make no representations or warranties, express or implied, including but not limited to, warranties of merchantability or fitness for any particular purpose or that the use of the software or documentation will not infringe any third party patents, copyrights, trademarks or other rights.
The copyright holders and contributing author(s) will not be held liable for any direct, indirect, special or consequential damages arising out of any use of the software or documentation, even if advised of the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute this source code, or portions hereof, documentation and executables, for any purpose, without fee, subject to the following restrictions:
1. The origin of this source code must not be misrepresented. 2. Altered versions must be plainly marked as such and must not be misrepresented as being the original source. 3. This Copyright notice may not be removed or altered from any source or altered source distribution.
The copyright holders and contributing author(s) specifically permit, without fee, and encourage the use of this source code as a component for supporting the Hypertext Markup Language in commercial products. If you use this source code in a product, acknowledgement is not required but would be appreciated.
The Perl parts of this distribution are copyright (C) 2015-2021 Ben Bullock and may be used under either the above licence terms, or the usual Perl conditions, either the GNU General Public Licence or the Perl Artistic Licence.