W3C home > Mailing lists > Public > www-validator-cvs@w3.org > June 2009

validator/httpd/cgi-bin check,1.671,1.672

From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 30 Jun 2009 17:26:47 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MLh6V-0007WJ-LK@lionel-hutz.w3.org>
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv28893/httpd/cgi-bin

Modified Files:
	check 
Log Message:
Improve outline layout, simplify creation.

Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.671
retrieving revision 1.672
diff -u -d -r1.671 -r1.672
--- check	30 Jun 2009 15:20:52 -0000	1.671
+++ check	30 Jun 2009 17:26:45 -0000	1.672
@@ -3301,19 +3301,15 @@
   my $File = shift;
   my $CFG = shift;
   my $self = $class->SUPER::new($parser, $File, $CFG);
-  $self->{current_heading_level}= 0;
   $self->{am_in_heading} = 0;
+  $self->{heading_text} = [];
   bless $self, $class;
 }
 
 sub data
 {
   my ($self, $chars) = @_;
-  if ($self->{am_in_heading} == 1) {
-    my $data = $chars->{Data};
-    $data =~  s/[\r|\n]/ /g;
-    $self->{_file}->{heading_outline} .= $data;
-  }
+  push(@{$self->{heading_text}}, $chars->{Data}) if $self->{am_in_heading};
 }
 
 sub start_element
@@ -3333,8 +3329,13 @@
 {
   my ($self, $element) = @_;
   if ($element->{Name} =~ /^h[1-6]$/i) {
-    $self->{_file}->{heading_outline} .= "\n";
+    my $text = join("", @{$self->{heading_text}});
+    $text =~ s/^\s+//g;
+    $text =~ s/\s+/ /g;
+    $text =~ s/\s+$//g;
+    $self->{_file}->{heading_outline} .= "$text\n";
     $self->{am_in_heading} = 0;
+    $self->{heading_text} = [];
   }
 }
 
Received on Tuesday, 30 June 2009 17:26:56 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:36 UTC