Parent Directory
|
Revision Log
|
Patch
| revision 1.47 by wakaba, Sat Jul 21 09:12:43 2007 UTC | revision 1.228 by wakaba, Sun Aug 16 06:47:59 2009 UTC | |
|---|---|---|
| # | Line 1 | Line 1 |
| 1 | package Whatpm::HTML; | package Whatpm::HTML; |
| 2 | use strict; | 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); | |
| 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; |
| ## strip BOM and the HTML layer MUST ignore it. Whether we can do it | ||
| ## is not yet clear. | ||
| ## "{U+FEFF}..." in UTF-16BE/UTF-16LE is three or four characters? | ||
| ## "{U+FEFF}..." in GB18030? | ||
| my $permitted_slash_tag_name = { | ||
| base => 1, | ||
| link => 1, | ||
| meta => 1, | ||
| hr => 1, | ||
| br => 1, | ||
| img=> 1, | ||
| embed => 1, | ||
| param => 1, | ||
| area => 1, | ||
| col => 1, | ||
| input => 1, | ||
| }; | ||
| 25 | ||
| 26 | my $c1_entity_char = { | ## Namespace URLs |
| 27 | 0x80 => 0x20AC, | |
| 28 | 0x81 => 0xFFFD, | my $HTML_NS = q<http://www.w3.org/1999/xhtml>; |
| 29 | 0x82 => 0x201A, | my $MML_NS = q<http://www.w3.org/1998/Math/MathML>; |
| 30 | 0x83 => 0x0192, | my $SVG_NS = q<http://www.w3.org/2000/svg>; |
| 31 | 0x84 => 0x201E, | my $XLINK_NS = q<http://www.w3.org/1999/xlink>; |
| 32 | 0x85 => 0x2026, | my $XML_NS = q<http://www.w3.org/XML/1998/namespace>; |
| 33 | 0x86 => 0x2020, | my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>; |
| 34 | 0x87 => 0x2021, | |
| 35 | 0x88 => 0x02C6, | ## Element categories |
| 36 | 0x89 => 0x2030, | |
| 37 | & |