| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 |
<head> |
<head> |
| 4 |
<title>Whatpm::HTML - An HTML Parser</title> |
<title>Whatpm::HTML - An HTML Parser and Serializer</title> |
| 5 |
<link rel="stylesheet" href="http://suika.fam.cx/www/style/html/pod.css" type="text/css" /> |
<link rel="stylesheet" href="http://suika.fam.cx/www/style/html/pod.css" type="text/css" /> |
| 6 |
<link rev="made" href="mailto:admin@suika.fam.cx" /> |
<link rev="made" href="mailto:admin@suika.fam.cx" /> |
| 7 |
</head> |
</head> |
| 17 |
<li><a href="#synopsis">SYNOPSIS</a></li> |
<li><a href="#synopsis">SYNOPSIS</a></li> |
| 18 |
<li><a href="#description">DESCRIPTION</a></li> |
<li><a href="#description">DESCRIPTION</a></li> |
| 19 |
<li><a href="#methods">METHODS</a></li> |
<li><a href="#methods">METHODS</a></li> |
| 20 |
|
<li><a href="#lowlevel_interface">LOW-LEVEL INTERFACE</a></li> |
| 21 |
|
<ul> |
| 22 |
|
|
| 23 |
|
<li><a href="#application_cache_selection_algorithm_hook">Application Cache Selection Algorithm Hook</a></li> |
| 24 |
|
</ul> |
| 25 |
|
|
| 26 |
|
<li><a href="#error_reports">ERROR REPORTS</a></li> |
| 27 |
<li><a href="#to_do">TO DO</a></li> |
<li><a href="#to_do">TO DO</a></li> |
| 28 |
|
<li><a href="#dependency">DEPENDENCY</a></li> |
| 29 |
<li><a href="#see_also">SEE ALSO</a></li> |
<li><a href="#see_also">SEE ALSO</a></li> |
| 30 |
<li><a href="#author">AUTHOR</a></li> |
<li><a href="#author">AUTHOR</a></li> |
| 31 |
<li><a href="#license">LICENSE</a></li> |
<li><a href="#license">LICENSE</a></li> |
| 36 |
<p> |
<p> |
| 37 |
</p> |
</p> |
| 38 |
<h1><a name="name">NAME</a></h1> |
<h1><a name="name">NAME</a></h1> |
| 39 |
<p>Whatpm::HTML - An HTML Parser</p> |
<p>Whatpm::HTML - An HTML Parser and Serializer</p> |
| 40 |
<p> |
<p> |
| 41 |
</p> |
</p> |
| 42 |
<hr /> |
<hr /> |
| 47 |
my $s = q<<!DOCTYPE html><html>...</html>>; |
my $s = q<<!DOCTYPE html><html>...</html>>; |
| 48 |
# $doc = an empty DOM |Document| object |
# $doc = an empty DOM |Document| object |
| 49 |
my $on_error = sub { |
my $on_error = sub { |
| 50 |
my $error_code = shift; |
my %error = @_; |
| 51 |
warn $error_code, "\n"; |
warn $error{type}, "\n"; |
| 52 |
}; |
}; |
| 53 |
|
|
| 54 |
Whatpm::HTML->parse_string ($s => $doc, $onerror); |
Whatpm::HTML->parse_char_string ($s => $doc, $onerror); |
| 55 |
|
|
| 56 |
## Then, |$doc| is the DOM representation of |$s|.</pre> |
## Now, |$doc| is the DOM representation of |$s|.</pre> |
| 57 |
<p> |
<p> |
| 58 |
</p> |
</p> |
| 59 |
<hr /> |
<hr /> |
| 73 |
<hr /> |
<hr /> |
| 74 |
<h1><a name="methods">METHODS</a></h1> |
<h1><a name="methods">METHODS</a></h1> |
| 75 |
<dl> |
<dl> |
| 76 |
<dt><strong><a name="item_parse_string">[<em>$doc</em> =] Whatpm::HTML->parse_string (<em>$s</em>, <em>$doc</em>[, <em>$onerror</em>]);</a></strong><br /> |
<dt><strong><a name="item_parse_char_string">[<em>$doc</em> =] Whatpm::HTML->parse_char_string (<em>$s</em>, <em>$doc</em>[, <em>$onerror</em>]);</a></strong><br /> |
| 77 |
</dt> |
</dt> |
| 78 |
<dd> |
<dd> |
| 79 |
Parse a string <em>$s</em> as an HTML document. |
Parse a string <em>$s</em> as an HTML document. |
| 120 |
<pre> |
<pre> |
| 121 |
use Whatpm::HTML; |
use Whatpm::HTML; |
| 122 |
use Whatpm::NanoDOM; |
use Whatpm::NanoDOM; |
| 123 |
my $doc = Whatpm::HTML->parse_string |
my $doc = Whatpm::HTML->parse_char_string |
| 124 |
($s => Whatpm::NanoDOM::Document->new, $onerror);</pre> |
($s => Whatpm::NanoDOM::Document->new, $onerror);</pre> |
| 125 |
</dd> |
</dd> |
|
<p></p> |
|
|
<dt><strong><a name="item_get_inner_html"><em>$s</em> = Whatpm::HTML->get_inner_html (<em>$node</em>[, <em>$onerror</em>]);</a></strong><br /> |
|
|
</dt> |
|
|
<dd> |
|
|
Return the HTML serialization of a DOM node <em>$node</em>. |
|
|
</dd> |
|
|
<dd> |
|
|
<p>The first argument, <em>$node</em>, MUST be a DOM <code>Document</code>, |
|
|
<code>Element</code>, or <code>DocumentFragment</code> node.</p> |
|
|
</dd> |
|
|
<dd> |
|
|
<p>The second argument, <em>$onerror</em>, MUST be a reference to the |
|
|
error handling code. This code will be invoked if a descendant |
|
|
of <em>$node</em> is neither of <code>Element</code>, <code>Text</code>, <code>CDATASection</code>, |
|
|
<code>Comment</code>, <code>DocumentType</code>, nor <code>EntityReference</code>, so |
|
|
that an <code>INVALID_STATE_ERR</code> exception MUST be thrown. |
|
|
The code will be invoked with an argument, which is the node |
|
|
whose type is invalid. |
|
|
The argument <em>$onerror</em> is optional; if missing, any erroneous |
|
|
node is simply ignored.</p> |
|
|
</dd> |
|
|
<dd> |
|
|
<p>The method returns a reference to the <code>inner_html</code> attribute |
|
|
value, i.e. the HTML serialization of the <em>$node</em>.</p> |
|
|
</dd> |
|
| 126 |
<p></p></dl> |
<p></p></dl> |
| 127 |
<p> |
<p> |
| 128 |
</p> |
</p> |
| 129 |
<hr /> |
<hr /> |
| 130 |
|
<h1><a name="lowlevel_interface">LOW-LEVEL INTERFACE</a></h1> |
| 131 |
|
<p>@@ TBW</p> |
| 132 |
|
<p> |
| 133 |
|
</p> |
| 134 |
|
<h2><a name="application_cache_selection_algorithm_hook">Application Cache Selection Algorithm Hook</a></h2> |
| 135 |
|
<p>Once a parser <em>$p</em> is instantiated by method <code>new</code>, |
| 136 |
|
a <code>CODE</code> reference can be set to <code>$p->{application_cache_selection}</code>. |
| 137 |
|
That <code>CODE</code> will be called back when the application cache selection |
| 138 |
|
algorithm MUST be run per HTML5. By default, |
| 139 |
|
<code>$p->{application_cache_selection}</code> is set to an empty subroutine.</p> |
| 140 |
|
<p>The subroutine will be invoked with an argument <em>manifest_uri</em>, |
| 141 |
|
which is set to the manifest URI when the algorithm MUST be invoked |
| 142 |
|
with a manifest URI, or is set to <code>undef</code> when the algorithm MUST |
| 143 |
|
be invoked without no manifest URI.</p> |
| 144 |
|
<p> |
| 145 |
|
</p> |
| 146 |
|
<hr /> |
| 147 |
|
<h1><a name="error_reports">ERROR REPORTS</a></h1> |
| 148 |
|
<p>@@ TBW</p> |
| 149 |
|
<p>The list of the error types is available in |
| 150 |
|
Whatpm Error Types <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.</p> |
| 151 |
|
<p> |
| 152 |
|
</p> |
| 153 |
|
<hr /> |
| 154 |
<h1><a name="to_do">TO DO</a></h1> |
<h1><a name="to_do">TO DO</a></h1> |
| 155 |
|
<p>Documentation for parse_byte_string.</p> |
| 156 |
<p>Tokenizer should emit a sequence of character tokens as one token |
<p>Tokenizer should emit a sequence of character tokens as one token |
| 157 |
to improve performance.</p> |
to improve performance.</p> |
| 158 |
<p>A method that accepts a byte stream as an input.</p> |
<p>A method that accepts a byte stream as an input.</p> |
| 162 |
<p> |
<p> |
| 163 |
</p> |
</p> |
| 164 |
<hr /> |
<hr /> |
| 165 |
|
<h1><a name="dependency">DEPENDENCY</a></h1> |
| 166 |
|
<p>This module requires <em>Error</em>. That module is available at CPAN |
| 167 |
|
<http://search.cpan.org/author/SHLOMIF/Error-0.17009/lib/Error.pm>. |
| 168 |
|
It is also part of manakai-core distribution |
| 169 |
|
<http://suika.fam.cx/www/2006/manakai/>.</p> |
| 170 |
|
<p> |
| 171 |
|
</p> |
| 172 |
|
<hr /> |
| 173 |
<h1><a name="see_also">SEE ALSO</a></h1> |
<h1><a name="see_also">SEE ALSO</a></h1> |
| 174 |
<p>Whatpm |
<p>Whatpm <http://suika.fam.cx/www/markup/html/whatpm/readme>.</p> |
| 175 |
<http://suika.fam.cx/www/markup/html/whatpm/readme></p> |
<p>Whatpm Error Types |
| 176 |
<p>Web Applications 1.0 Working Draft (aka HTML5) |
<http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.</p> |
| 177 |
<http://whatwg.org/html5>. (Revision 792, 1 May 2007)</p> |
<p>HTML5 <http://whatwg.org/html5>.</p> |
| 178 |
<p><a href="../Whatpm/NanoDOM.html">the Whatpm::NanoDOM manpage</a></p> |
<p><a href="../Whatpm/HTML/Serializer.html">the Whatpm::HTML::Serializer manpage</a>.</p> |
| 179 |
|
<p><a href="../Whatpm/NanoDOM.html">the Whatpm::NanoDOM manpage</a>.</p> |
| 180 |
|
<p><a href="../Whatpm/ContentChecker/HTML.html">the Whatpm::ContentChecker::HTML manpage</a>.</p> |
| 181 |
<p> |
<p> |
| 182 |
</p> |
</p> |
| 183 |
<hr /> |
<hr /> |