Parent Directory
|
Revision Log
|
Patch
| revision 1.69 by wakaba, Sun Feb 17 12:39:32 2008 UTC | revision 1.239 by wakaba, Sun Sep 6 10:17:38 2009 UTC | |
|---|---|---|
| # | Line 3 use strict; | Line 3 use strict; |
| 3 | our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; | our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
| 4 | use Error qw(:try); | use Error qw(:try); |
| 5 | ||
| 6 | use Whatpm::HTML::Tokenizer; | |
| 7 | ||
| 8 | ## NOTE: This module don't check all HTML5 parse errors; character | |
| 9 | ## encoding related parse errors are expected to be handled by relevant | |
| 10 | ## modules. | |
| 11 | ## Parse errors for control characters that are not allowed in HTML5 | |
| 12 | ## documents, for surrogate code points, and for noncharacter code | |
| 13 | ## points, as well as U+FFFD substitions for characters whose code points | |
| 14 | ## is higher than U+10FFFF may be detected by combining the parser with | |
| 15 | ## the checker implemented by Whatpm::Charset::UnicodeChecker (for its | |
| 16 | ## usage example, see |t/HTML-tree.t| in the Whatpm package or the | |
| 17 | ## WebHACC::Language::HTML module in the WebHACC package). | |
| 18 | ||
| 19 | ## ISSUE: | ## ISSUE: |
| 20 | ## var doc = implementation.createDocument (null, null, null); | ## var doc = implementation.createDocument (null, null, null); |
| 21 | ## doc.write (''); | ## doc.write (''); |
| 22 | ## alert (doc.compatMode); | ## alert (doc.compatMode); |
| 23 | ||
| 24 | ## ISSUE: HTML5 revision 967 says that the encoding layer MUST NOT | require IO::Handle; |
| 25 | ## strip BOM and the HTML layer MUST ignore it. Whether we can do it | |
| 26 | ## is not yet clear. | ## Namespace URLs |
| 27 | ## "{U+FEFF}..." in UTF-16BE/UTF-16LE is three or four characters? | |
| 28 | ## "{U+FEFF}..." in GB18030? | my $HTML_NS = q<http://www.w3.org/1999/xhtml>; |
| 29 | my $MML_NS = q<http://www.w3.org/1998/Math/MathML>; | |
| 30 | my $permitted_slash_tag_name = { | my $SVG_NS = q<http://www.w3.org/2000/svg>; |
| 31 | base => 1, | my $XLINK_NS = q<http://www.w3.org/1999/xlink>; |
| 32 | link => 1, | my $XML_NS = q<http://www.w3.org/XML/1998/namespace>; |
| 33 | meta => 1, | my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>; |
| 34 | hr => 1, | |
| 35 | br => 1, | ## Element categories |
| 36 | img=> 1, | |
| 37 | embed => 1, | ## Bits 12-15 |
| 38 | param => 1, | sub SPECIAL_EL () { 0b1_000000000000000 } |
| 39 | area => 1, | sub SCOPING_EL () { 0b1_00000000000000 } |
| 40 | col => 1, | sub FORMATTING_EL () { 0b1_0000000000000 } |
| 41 | input => 1, | sub PHRASING_EL () { 0b1_000000000000 } |
| 42 | ||
| 43 | ## Bits 10-11 | |
| 44 | #sub FOREIGN_EL () { 0b1_00000000000 } # see Whatpm::HTML::Tokenizer | |
| 45 | sub FOREIGN_FLOW_CONTENT_EL () { 0b1_0000000000 } | |
| 46 | ||
| 47 | ## Bits 6-9 | |
| 48 | sub TABLE_SCOPING_EL () { 0b1_000000000 } | |
| 49 | sub TABLE_ROWS_SCOPING_EL () { 0b1_00000000 } | |
| 50 | sub TABLE_ROW_SCOPING_EL () { 0b1_0000000 } | |
| 51 | sub TABLE_ROWS_EL () { 0b1_000000 } | |
| 52 | ||
| 53 | ## Bit 5 | |
| 54 | sub ADDRESS_DIV_P_EL () { 0b1_00000 } | |
| 55 | ||
| 56 | ## NOTE: Used in </body> and EOF algorithms. | |
| 57 | ## Bit 4 | |
| 58 | sub ALL_END_TAG_OPTIONAL_EL () { 0b1_0000 } | |
| 59 | ||
| 60 | ## NOTE: Used in "generate implied end tags" algorithm. | |
| 61 | ## NOTE: There is a code where a modified version of | |
| 62 | ## END_TAG_OPTIONAL_EL is used in "generate implied end tags" | |
| 63 | ## implementation (search for the algorithm name). | |
| 64 | ## Bit 3 | |
| 65 | sub END_TAG_OPTIONAL_EL () { 0b1_000 } | |
| 66 | ||
| 67 | ## Bits 0-2 | |
| 68 | ||
| 69 | sub MISC_SPECIAL_EL () { SPECIAL_EL | 0b000 } | |
| 70 | sub FORM_EL () { SPECIAL_EL | 0b001 } | |
| 71 | sub FRAMESET_EL () { SPECIAL_EL | 0b010 } | |
| 72 | sub HEADING_EL () { SPECIAL_EL | 0b011 } | |
| 73 | sub SELECT_EL () { SPECIAL_EL | 0b100 } | |
| 74 | sub SCRIPT_EL () { SPECIAL_EL | 0b101 } | |
| 75 | ||
| 76 | sub |