Diff for /doc/loncapafiles/html_parser_check.piml between versions 1.1 and 1.2

version 1.1, 2004/12/06 20:27:38 version 1.2, 2004/12/06 20:34:57
Line 35  http://www.lon-capa.org/ Line 35  http://www.lon-capa.org/
 <file>  <file>
 <target dist="default">/home/httpd/lonUsers</target>  <target dist="default">/home/httpd/lonUsers</target>
 <perlscript mode="fg">  <perlscript mode="fg">
 #use the directory  
 use strict;  use strict;
 use HTML::Parser;  use HTML::Parser;
   
Line 45  my $version = $HTML::Parser::VERSION; Line 45  my $version = $HTML::Parser::VERSION;
 ## First test  ## First test
 ##  ##
 my $text='';  my $text='';
 my $p = HTML::Parser->new(api_version => 3);  my $p = HTML::Parser-&gt;new(api_version =&gt; 3);
 $p->handler(start =>  $p-&gt;handler(start =&gt;
     sub {      sub {
  my($tag, $attr) = @_;   my($tag, $attr) = @_;
  $text .= "S[$tag";   $text .= "S[$tag";
  for my $k (sort keys %$attr) {   for my $k (sort keys %$attr) {
      my $v =  $attr->{$k};       my $v =  $attr-&gt;{$k};
      $text .= " key $k= value $v";       $text .= " key $k= value $v";
  }   }
  $text .= "]";   $text .= "]";
      }, "tagname,attr");       }, "tagname,attr");
 $p->handler(text =>  $p-&gt;handler(text =&gt;
      sub {       sub {
  $text .= 'T{'.shift().'}';   $text .= 'T{'.shift().'}';
      }, "text");       }, "text");
 $text='';  $text='';
 $p->parse('<img a="b" "=\'"\' c=d />')->eof;  $p-&gt;parse('&lt;img a="b" "=\'"\' c=d /&gt;')-&gt;eof;
   
 my $first_test_result = $text;  my $first_test_result = $text;
 my $first_expected_result =   my $first_expected_result = 
Line 69  my $first_expected_result = Line 69  my $first_expected_result =
 if (! $first_test_result) {  if (! $first_test_result) {
     print "Unable to run first HTML::Parser test\n";      print "Unable to run first HTML::Parser test\n";
 } elsif ($first_test_result ne $first_expected_result) {  } elsif ($first_test_result ne $first_expected_result) {
     print <<"END";      print &lt;&lt;"END";
 **** WARNING: HTML::Parser is not working properly.  **** WARNING: HTML::Parser is not working properly.
               You are using version $version.  For test 1 it returned                You are using version $version.  For test 1 it returned
               "$first_test_result"                "$first_test_result"
 END  END
 } else {  
     print "First HTML::Parser test looks good.\n";  
 }  }
   
   
 ##  ##
 ## Second test  ## Second test
 ##  ##
 $p->xml_mode(1);  $p-&gt;xml_mode(1);
 $text='';  $text='';
 $p->parse('<img a="b" "=\'"\' c=d />')->eof;  $p-&gt;parse('&lt;img a="b" "=\'"\' c=d /&gt;')-&gt;eof;
 my $second_test_result = $text;  my $second_test_result = $text;
 my $second_expected_result =   my $second_expected_result = 
     q{S[img key "= value " key a= value b key c= value d]};      q{S[img key "= value " key a= value b key c= value d]};
 if (! $second_test_result) {  if (! $second_test_result) {
     print "Unable to run second HTML::Parser test\n";      print "Unable to run second HTML::Parser test\n";
 } elsif ($second_test_result ne $second_expected_result) {  } elsif ($second_test_result ne $second_expected_result) {
     print <<"END";      print &lt;&lt;"END";
 **** WARNING: HTML::Parser is not working properly.  **** WARNING: HTML::Parser is not working properly.
               You are using version $version.  For test 2 it returned                You are using version $version.  For test 2 it returned
               "$second_test_result"                "$second_test_result"
 END  END
 } else {  
     print "Second HTML::Parser test looks good.\n";  
 }  }
   
 </perlscript>  </perlscript>

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>