/[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.4 - (show annotations) (download)
Mon Jul 21 09:15:55 2008 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +1 -2 lines
++ ChangeLog	21 Jul 2008 09:13:35 -0000
	* cc.cgi: Old commented out code for additional
	information sections are removed.  They are now
	implemented as part of |generate_add_info_sections| method.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/Language/ChangeLog	21 Jul 2008 09:15:45 -0000
	* DOM.pm (generate_additional_sections): Support
	for the other additional information sections are reintroduced.
	(generate_listing_section, generate_rdf_section): Reimplemented.

	* XML.pm: Typo fixed.

	* HTML.pm: Load DOMImplementation as late as possible, to
	save possiblity that another DOM implementation can be used
	where possible.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24