/[suikacvs]/markup/html/whatpm/What/HTML.html
Suika

Contents of /markup/html/whatpm/What/HTML.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Tue May 1 08:17:44 2007 UTC (17 years, 6 months ago) by wakaba
Branch: MAIN
File MIME type: text/html
++ whatpm/What/ChangeLog	1 May 2007 08:17:35 -0000
	* NanoDOM.html: Documentation is added.

	* HTML.pod, ContentType.html: Documentation is revised.

	* .cvsignore: Pod2html temporary files are added.

	* Makefile: Make |NanoDOM.html|.

2007-05-01  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 <!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">
3     <head>
4     <title>What::HTML - An HTML Parser</title>
5     <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" />
7     </head>
8    
9     <body>
10    
11     <p><a name="__index__"></a></p>
12     <!-- INDEX BEGIN -->
13    
14     <ul>
15    
16     <li><a href="#name">NAME</a></li>
17     <li><a href="#synopsis">SYNOPSIS</a></li>
18     <li><a href="#description">DESCRIPTION</a></li>
19     <li><a href="#methods">METHODS</a></li>
20     <li><a href="#to_do">TO DO</a></li>
21     <li><a href="#see_also">SEE ALSO</a></li>
22     <li><a href="#author">AUTHOR</a></li>
23     <li><a href="#license">LICENSE</a></li>
24     </ul>
25     <!-- INDEX END -->
26    
27     <hr />
28     <p>
29     </p>
30     <h1><a name="name">NAME</a></h1>
31     <p>What::HTML - An HTML Parser</p>
32     <p>
33     </p>
34     <hr />
35     <h1><a name="synopsis">SYNOPSIS</a></h1>
36     <pre>
37     use What::HTML;
38    
39     my $s = q&lt;&lt;!DOCTYPE html&gt;&lt;html&gt;...&lt;/html&gt;&gt;;
40     # $doc = an empty DOM |Document| object
41     my $on_error = sub {
42     my $error_code = shift;
43     warn $error_code, &quot;\n&quot;;
44     };
45    
46     What::HTML-&gt;parse_string ($s =&gt; $doc, $onerror);
47    
48     ## Then, |$doc| is the DOM representation of |$s|.</pre>
49     <p>
50     </p>
51     <hr />
52     <h1><a name="description">DESCRIPTION</a></h1>
53     <p>The <code>What::HTML</code> module contains HTML parser and serializer.</p>
54     <p>The HTML parser can be used to construct the DOM tree representation
55     from an HTML document. The parsing and tree construction are done
56     as described in the Web Application 1.0 specification.</p>
57     <p>The HTML serializer can be used to obtain the HTML document representation
58     of a DOM tree (or a tree fragment thereof). The serialization
59     is performed as described in the Web Applications 1.0 specification
60     for <code>innerHTML</code> DOM attribute.</p>
61     <p>This module is part of WHAT.pm - Perl Modules for
62     Web Hypertext Application Technologies.</p>
63     <p>
64     </p>
65     <hr />
66     <h1><a name="methods">METHODS</a></h1>
67     <dl>
68     <dt><strong><a name="item_parse_string">[<em>$doc</em> =] What::HTML-&gt;parse_string (<em>$s</em>, <em>$doc</em>[, <em>$onerror</em>]);</a></strong><br />
69     </dt>
70     <dd>
71     Parse a string <em>$s</em> as an HTML document.
72     </dd>
73     <dd>
74     <p>The first argument, <em>$s</em>, MUST be a string. It is parsed
75     as a sequence of characters representing an HTML document.</p>
76     </dd>
77     <dd>
78     <p>The second argument, <em>$doc</em>, MUST be an empty read-write
79     DOM <code>Document</code> object. The HTML DOM tree is constructed
80     onto this <code>Document</code> object.</p>
81     </dd>
82     <dd>
83     <p>The third argument, <em>$onerror</em>, MUST be a reference to
84     the error handler code. Whenever a parse error is detected,
85     this code is invoked with an argument that contains a
86     useless string that might describe what is wrong.
87     The code MAY throw an exception, so that whole the parsing
88     process aborts. Otherwise, the parser will continue to
89     process the input. The code MUST NOT modify <em>$s</em> or <em>$doc</em>.
90     If it does, then the result is undefined.
91     This argument is optional; if missing, any
92     parse error makes that string being <code>warn</code>ed.</p>
93     </dd>
94     <dd>
95     <p>The method returns the DOM <code>Document</code> object (i.e. the second argument).</p>
96     </dd>
97     <dd>
98     <p>Note that the <code>What::NanoDOM</code> module provides a non-conforming
99     implementation of DOM that only implements the subset that
100     is necessary for the purpose of <code>What::HTML</code>'s parsing and
101     serializing.
102     With this module, creating a new HTML <code>Document</code> object
103     from a string containing HTML document can be coded as:</p>
104     </dd>
105     <dd>
106     <pre>
107     use What::HTML;
108     use What::NanoDOM;
109     my $doc = What::HTML-&gt;parse_string ($s =&gt; What::NanoDOM-&gt;new, $onerror);</pre>
110     </dd>
111     <p></p>
112     <dt><strong><a name="item_get_inner_html"><em>$s</em> = What::HTML-&gt;get_inner_html (<em>$node</em>[, <em>$onerror</em>]);</a></strong><br />
113     </dt>
114     <dd>
115     Return the HTML serialization of a DOM node <em>$node</em>.
116     </dd>
117     <dd>
118     <p>The first argument, <em>$node</em>, MUST be a DOM <code>Document</code>,
119     <code>Node</code>, or <code>DocumentFragment</code> object.</p>
120     </dd>
121     <dd>
122     <p>The second argument, <em>$onerror</em>, MUST be a reference to the
123     error handling code. This code will be invoked if a descendant
124     of <code>$node</code> is not of <code>Element</code>, <code>Text</code>, <code>CDATASection</code>,
125     <code>Comment</code>, <code>DocumentType</code>, or <code>EntityReference</code> so
126     that <code>INVALID_STATE_ERR</code> MUST be thrown.
127     The code will be invoked with an argument, which is the node
128     whose type is invalid.
129     This argument is optional; if missing, any such
130     node is simply ignored.</p>
131     </dd>
132     <dd>
133     <p>The method returns the <code>inner_html</code> attribute
134     value, i.e. the HTML serialization of the <code>$node</code>.</p>
135     </dd>
136     <p></p></dl>
137     <p>
138     </p>
139     <hr />
140     <h1><a name="to_do">TO DO</a></h1>
141     <p>Tokenizer should emit a sequence of character tokens as one token
142     to improve performance.</p>
143     <p>A method that accepts a byte stream as an input.</p>
144     <p>Charset detection algorithm.</p>
145     <p>Setting inner_html.</p>
146     <p>And there are many ``TODO''s and ``ISSUE''s in the source code.</p>
147     <p>
148     </p>
149     <hr />
150     <h1><a name="see_also">SEE ALSO</a></h1>
151     <p>Web Applications 1.0 Working Draft (aka HTML5)
152     &lt;http://whatwg.org/html5&gt;. (Revision 792, 1 May 2007)</p>
153     <p><a href="../What/NanoDOM.html">the What::NanoDOM manpage</a></p>
154     <p>
155     </p>
156     <hr />
157     <h1><a name="author">AUTHOR</a></h1>
158     <p>Wakaba &lt;<a href="mailto:w@suika.fam.cx">w@suika.fam.cx</a>&gt;.</p>
159     <p>
160     </p>
161     <hr />
162     <h1><a name="license">LICENSE</a></h1>
163     <p>Copyright 2007 Wakaba &lt;<a href="mailto:w@suika.fam.cx">w@suika.fam.cx</a>&gt;</p>
164     <p>This library is free software; you can redistribute it
165     and/or modify it under the same terms as Perl itself.</p>
166    
167     </body>
168    
169     </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24