diff options
-rw-r--r-- | htdocs/style/results.css | 8 | ||||
-rwxr-xr-x | httpd/cgi-bin/check | 66 | ||||
-rw-r--r-- | share/templates/en_US/opt_show_outline.tmpl | 3 |
3 files changed, 67 insertions, 10 deletions
diff --git a/htdocs/style/results.css b/htdocs/style/results.css index 557d95f..ac35169 100644 --- a/htdocs/style/results.css +++ b/htdocs/style/results.css @@ -1,5 +1,5 @@ /* style sheet for the validator's results page */ -/* $Id: results.css,v 1.8 2007-03-15 07:02:34 ot Exp $ */ +/* $Id: results.css,v 1.9 2007-03-23 03:52:21 ot Exp $ */ .input { color: black; @@ -318,4 +318,10 @@ p.backtop { p.backtop a:link, p.backtop a:hover, p.backtop a:visited { color: #bbc; text-deciration: none; +} + +/* document outline */ +pre.outline { + line-height: 160%; + padding-left: 1.5em; }
\ No newline at end of file diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check index 1eca97c..7f79b3d 100755 --- a/httpd/cgi-bin/check +++ b/httpd/cgi-bin/check @@ -14,7 +14,7 @@ # This source code is available under the license at: # http://www.w3.org/Consortium/Legal/copyright-software # -# $Id: check,v 1.486 2007-03-22 14:17:12 ot Exp $ +# $Id: check,v 1.487 2007-03-23 03:52:21 ot Exp $ # # Disable buffering on STDOUT! @@ -180,7 +180,7 @@ Directory not readable (permission denied): @_r # # Strings - $VERSION = q$Revision: 1.486 $; + $VERSION = q$Revision: 1.487 $; $VERSION =~ s/Revision: ([\d\.]+) /$1/; # @@ -613,7 +613,7 @@ $File->{Errors} = []; # preparse with XML parser if necessary # we should really be using a SAX ErrorHandler, but I can't find # a way to make it work with XML::LibXML::SAX::Parser... ** FIXME ** -# ditto, we should try using W3C::Validator::ErrorHandler, +# ditto, we should try using W3C::Validator::SAXHandler, # but it's badly linked to opensp at the moment if (&is_xml($File)) { @@ -737,7 +737,7 @@ sub parse (\$) { ], ); - my $h = W3C::Validator::ErrorHandler->new($opensp, $File); + my $h = W3C::Validator::SAXHandler->new($opensp, $File); $opensp->handler($h); $opensp->parse_string(join"\n",@{$File->{Content}}); @@ -873,7 +873,7 @@ $template->param(file_source => &source($File)) # if $File->{Opt}->{'Show Errors'}; #$template->param('file_raw_errors' => &show_errors($File)) # if $template->param('opt_show_raw_errors'); - $T->param(file_outline => &outline($File)) if $T->param('opt_show_outline'); +# $T->param(file_outline => &outline($File)) if $T->param('opt_show_outline'); print $template->output; @@ -1067,6 +1067,10 @@ sub report_valid { } elsif (defined $File->{Tentative}) { $T->param(is_tentative => TRUE); } + + if ($File->{Opt}->{'Outline'}) { + $T->param(file_outline => $File->{heading_outline}); + } my $thispage = self_url_file($File); $T->param(file_thispage => $thispage); @@ -2129,18 +2133,64 @@ sub self_url_file { ##### -sub W3C::Validator::ErrorHandler::new +sub W3C::Validator::SAXHandler::new { my $class = shift; my $parser = shift; my $File = shift; - my $self = { _file => $File, _parser => $parser }; + my $self = { _file => $File, _parser => $parser, + current_heading_level => 0, am_in_heading => 0 }; bless $self, $class; } -sub W3C::Validator::ErrorHandler::error +sub W3C::Validator::SAXHandler::characters +{ + my ($self, $chars) = @_; + if ($self->{am_in_heading} == 1) { + my $data = $chars->{Data}; + $data =~ s/[\r|\n]/ /g; + $self->{_file}->{heading_outline} = $self->{_file}->{heading_outline} . $data; + } + +} + +sub W3C::Validator::SAXHandler::data +{ + my ($self, $chars) = @_; + if ($self->{am_in_heading} == 1) { + my $data = $chars->{Data}; + $data =~ s/[\r|\n]/ /g; + $self->{_file}->{heading_outline} = $self->{_file}->{heading_outline} . $data; + } + +} + + +sub W3C::Validator::SAXHandler::start_element +{ + my ($self, $element) = @_; + if ($element->{Name} =~ /^h([1-6])$/) { + + $self->{_file}->{heading_outline} = $self->{_file}->{heading_outline} . " " x int($1) . "[". $element->{Name}."] "; + $self->{am_in_heading} = 1; + } + +} + + +sub W3C::Validator::SAXHandler::end_element +{ + my ($self, $element) = @_; + if ($element->{Name} =~ /^h[1-6]$/) { + $self->{_file}->{heading_outline} = $self->{_file}->{heading_outline} . "\n"; + $self->{am_in_heading} = 0; + } + +} + +sub W3C::Validator::SAXHandler::error { my $self = shift; my $error = shift; diff --git a/share/templates/en_US/opt_show_outline.tmpl b/share/templates/en_US/opt_show_outline.tmpl index a21fc29..be97280 100644 --- a/share/templates/en_US/opt_show_outline.tmpl +++ b/share/templates/en_US/opt_show_outline.tmpl @@ -5,8 +5,9 @@ heading tags (<code><h1></code> through <code><h6></code>.) </p> - +<pre class="outline"> <TMPL_VAR NAME="file_outline"> +</pre> <p> If this does not look like a real outline, it is likely that the heading tags are not being used properly. (Headings should reflect |