[LON-CAPA-cvs] cvs: doc /loncapafiles html_parser_check.piml
matthew
lon-capa-cvs@mail.lon-capa.org
Mon, 06 Dec 2004 20:34:57 -0000
matthew Mon Dec 6 15:34:57 2004 EDT
Modified files:
/doc/loncapafiles html_parser_check.piml
Log:
Real Perl can't survive in XML so we have to disguise it.
Index: doc/loncapafiles/html_parser_check.piml
diff -u doc/loncapafiles/html_parser_check.piml:1.1 doc/loncapafiles/html_parser_check.piml:1.2
--- doc/loncapafiles/html_parser_check.piml:1.1 Mon Dec 6 15:27:38 2004
+++ doc/loncapafiles/html_parser_check.piml Mon Dec 6 15:34:57 2004
@@ -3,7 +3,7 @@
<!-- ntpcheck.piml -->
<!-- Matthew Hall -->
-<!-- $Id: html_parser_check.piml,v 1.1 2004/12/06 20:27:38 matthew Exp $ -->
+<!-- $Id: html_parser_check.piml,v 1.2 2004/12/06 20:34:57 matthew Exp $ -->
<!--
@@ -35,7 +35,7 @@
<file>
<target dist="default">/home/httpd/lonUsers</target>
<perlscript mode="fg">
-#use the directory
+
use strict;
use HTML::Parser;
@@ -45,23 +45,23 @@
## First test
##
my $text='';
-my $p = HTML::Parser->new(api_version => 3);
-$p->handler(start =>
+my $p = HTML::Parser->new(api_version => 3);
+$p->handler(start =>
sub {
my($tag, $attr) = @_;
$text .= "S[$tag";
for my $k (sort keys %$attr) {
- my $v = $attr->{$k};
+ my $v = $attr->{$k};
$text .= " key $k= value $v";
}
$text .= "]";
}, "tagname,attr");
-$p->handler(text =>
+$p->handler(text =>
sub {
$text .= 'T{'.shift().'}';
}, "text");
$text='';
-$p->parse('<img a="b" "=\'"\' c=d />')->eof;
+$p->parse('<img a="b" "=\'"\' c=d />')->eof;
my $first_test_result = $text;
my $first_expected_result =
@@ -69,35 +69,31 @@
if (! $first_test_result) {
print "Unable to run first HTML::Parser test\n";
} elsif ($first_test_result ne $first_expected_result) {
- print <<"END";
+ print <<"END";
**** WARNING: HTML::Parser is not working properly.
You are using version $version. For test 1 it returned
"$first_test_result"
END
-} else {
- print "First HTML::Parser test looks good.\n";
}
##
## Second test
##
-$p->xml_mode(1);
+$p->xml_mode(1);
$text='';
-$p->parse('<img a="b" "=\'"\' c=d />')->eof;
+$p->parse('<img a="b" "=\'"\' c=d />')->eof;
my $second_test_result = $text;
my $second_expected_result =
q{S[img key "= value " key a= value b key c= value d]};
if (! $second_test_result) {
print "Unable to run second HTML::Parser test\n";
} elsif ($second_test_result ne $second_expected_result) {
- print <<"END";
+ print <<"END";
**** WARNING: HTML::Parser is not working properly.
You are using version $version. For test 2 it returned
"$second_test_result"
END
-} else {
- print "Second HTML::Parser test looks good.\n";
}
</perlscript>