Parent Directory
|
Revision Log
|
Patch
| revision 1.114 by wakaba, Sun Mar 16 11:40:19 2008 UTC | revision 1.228 by wakaba, Sun Aug 16 06:47:59 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 | ## TODO: Control charcters and noncharacters are not allowed (HTML5 revision 1263) | require IO::Handle; |
| 25 | ## TODO: 1252 parse error (revision 1264) | |
| 26 | ## TODO: 8859-11 = 874 (revision 1271) | ## Namespace URLs |
| 27 | ||
| 28 | my $permitted_slash_tag_name = { | my $HTML_NS = q<http://www.w3.org/1999/xhtml>; |
| 29 | base => 1, | my $MML_NS = q<http://www.w3.org/1998/Math/MathML>; |
| 30 | link => 1, | my $SVG_NS = q<http://www.w3.org/2000/svg>; |
| 31 | meta => 1, | my $XLINK_NS = q<http://www.w3.org/1999/xlink>; |
| 32 | hr => 1, | my $XML_NS = q<http://www.w3.org/XML/1998/namespace>; |
| 33 | br => 1, | my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>; |
| 34 | img => 1, | |
| 35 | embed => 1, | ## Element categories |
| 36 | param => 1, | |
| 37 | area => 1, | ## Bits 12-15 |
| 38 | col => 1, | sub SPECIAL_EL () { 0b1_000000000000000 } |
| 39 | input => 1, | sub SCOPING_EL () { 0b1_00000000000000 } |
| 40 | sub FORMATTING_EL () { 0b1_0000000000000 } | |
| 41 | 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 ADDRESS_DIV_EL () { SPECIAL_EL | ADDRESS_DIV_P_EL | 0b001 } | |
| 77 | sub BODY_EL () { SPECIAL_EL | ALL_END_TAG_OPTIONAL_EL | 0b001 } | |
| 78 | ||
| 79 | sub DTDD_EL () { | |
| 80 | SPECIAL_EL | | |
| 81 | END_TAG_OPTIONAL_EL | | |
| 82 | ALL_END_TAG_OPTIONAL_EL | | |
| 83 | 0b010 | |
| 84 | } | |
| 85 | sub LI_EL () { | |
| 86 | SPECIAL_EL | | |
| 87 | END_TAG_OPTIONAL_EL | | |
| 88 | ALL_END_TAG_OPTIONAL_EL | | |
| 89 | 0b100 | |
| 90 | } | |
| 91 | sub P_EL () { | |
| 92 | SPECIAL_EL | | |
| 93 | ADDRESS_DIV_P_EL | | |
| 94 | END_TAG_OPTIONAL_EL | | |
| 95 | ALL_END_TAG_OPTIONAL_EL | | |
| 96 | 0b001 | |
| 97 | } | |
| 98 | ||
| 99 | sub TABLE_ROW_EL () { | |
| 100 | SPECIAL_EL | | |
| 101 | TABLE_ROWS_EL | | |
| 102 | TABLE_ROW_SCOPING_EL | | |
| 103 | ALL_END_TAG_OPTIONAL_EL | | |
| 104 | 0b001 | |
| 105 | } | |
| 106 | sub TABLE_ROW_GROUP_EL () { | |
| 107 | SPECIAL_EL | | |
| 108 | TABLE_ROWS_EL | | |
| 109 | TABLE_ROWS_SCOPING_EL | | |
| 110 | ALL_END_TAG_OPTIONAL_EL | | |
| 111 | 0b001 | |
| 112 | } | |
| 113 | ||
| 114 | sub MISC_SCOPING_EL () { SCOPING_EL | 0b000 } | |
| 115 | sub BUTTON_EL () { SCOPING_EL | 0b001 } | |
| 116 | sub CAPTION_EL () { SCOPING_EL | 0b010 } | |
| 117 | sub HTML_EL () { | |
| 118 | SCOPING_EL | | |
| 119 | TABLE_SCOPING_EL | | |
| 120 | TABLE_ROWS_SCOPING_EL | | |
| 121 | TABLE_ROW_SCOPING_EL | | |
| 122 | ALL_END_TAG_OPTIONAL_EL | | |
| 123 | 0b001 | |
| 124 | } | |
| 125 | sub TABLE_EL () { | |
| 126 | SCOPING_EL | | |
| 127 | TABLE_ROWS_EL | | |
| 128 | TABLE_SCOPING_EL | | |
| 129 | 0b001 | |
| 130 | } | |
| 131 | sub TABLE_CELL_EL () { | |
| 132 | SCOPING_EL | | |
| 133 | TABLE_ROW_SCOPING_EL | | |
| 134 | ALL_END_TAG_OPTIONAL_EL | | |
| 135 | 0b001 | |