/[suikacvs]/test/html-webhacc/WebHACC/Language/HTML.pm
Suika

Contents of /test/html-webhacc/WebHACC/Language/HTML.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sun Jul 20 16:53:10 2008 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +1 -12 lines
++ ChangeLog	20 Jul 2008 16:48:51 -0000
2008-07-21  Wakaba  <wakaba@suika.fam.cx>

	* cc.cgi: Errors and results are now handled by WebHACC::Result.
	Decode |uri| parameter as UTF-8.  HTTP header dump and
	input error are now handled by WebHACC::Input.

++ html/WebHACC/Language/ChangeLog	20 Jul 2008 16:53:06 -0000
2008-07-21  Wakaba  <wakaba@suika.fam.cx>

	* Base.pm (_get_cc_url, _encode_url_component): Remove (now
	supported by WebHACC::Output).

	* CSS.pm, CacheManifest.pm, DOM.pm, Default.pm,
	HTML.pm, WebIDL.pm, XML.pm: Error reporting is now delegated to
	WebHACC::Result.

++ html/WebHACC/ChangeLog	20 Jul 2008 16:50:41 -0000
2008-07-21  Wakaba  <wakaba@suika.fam.cx>

	* Input.pm (generate_transfer_sections, generate_http_header_section):
	New (partially comes from cc.cgi).

	* Output.pm (link): Call |start_tag| such that attributes
	can be set.
	(link_to_webhacc): New.
	(encode_url_component): From WebHACC::Language::Base.

	* Result.pm: Support for error outputting and result table
	generation.

1 wakaba 1.1 package WebHACC::Language::HTML;
2     use strict;
3     require WebHACC::Language::DOM;
4     push our @ISA, 'WebHACC::Language::DOM';
5    
6     require Message::DOM::DOMImplementation;
7    
8     sub new ($) {
9     return bless {}, shift;
10     } # new
11    
12     sub generate_syntax_error_section ($) {
13     my $self = shift;
14    
15     require Encode;
16     require Whatpm::HTML;
17    
18     my $out = $self->output;
19     $out->start_section (id => 'parse-errors', title => 'Parse Errors');
20     $out->start_tag (id => 'parse-errors-list');
21    
22     my $input = $self->input;
23     my $result = $self->result;
24    
25     my $onerror = sub {
26 wakaba 1.2 $result->add_error (@_, layer => 'syntax');
27 wakaba 1.1 };
28    
29     my $dom = Message::DOM::DOMImplementation->new;
30     my $doc = $dom->create_document;
31     my $el;
32     my $inner_html_element = $input->{inner_html_element};
33     if (defined $inner_html_element and length $inner_html_element) {
34     $input->{charset} ||= 'windows-1252'; ## TODO: for now.
35     my $t = \($input->{s});
36     unless ($input->{is_char_string}) {
37     $t = \(Encode::decode ($input->{charset}, $$t));
38     }
39    
40     $el = $doc->create_element_ns
41     ('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]);
42     Whatpm::HTML->set_inner_html ($el, $$t, $onerror);
43    
44     $self->{structure} = $el;
45     } else {
46     if ($input->{is_char_string}) {
47     Whatpm::HTML->parse_char_string ($input->{s} => $doc, $onerror);
48     } else {
49     Whatpm::HTML->parse_byte_string
50     ($input->{charset}, $input->{s} => $doc, $onerror);
51     }
52    
53     $self->{structure} = $doc;
54     }
55     $doc->manakai_charset ($input->{official_charset})
56     if defined $input->{official_charset};
57    
58     $doc->document_uri ($input->{uri});
59     $doc->manakai_entity_base_uri ($input->{base_uri});
60    
61     $out->end_tag ('dl');
62     $out->end_section;
63     } # generate_syntax_error_section
64    
65     sub source_charset ($) {
66     my $self = shift;
67     return $self->input->{charset} || ($self->{structure}->owner_document || $self->{structure})->input_encoding;
68     ## TODO: Can we always use input_encoding?
69     } # source_charset
70    
71     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24