Annotation of doc/loncapafiles/html_parser_check.piml, revision 1.2
1.1 matthew 1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN"
2: "http://lpml.sourceforge.net/DTD/piml.dtd">
3: <!-- ntpcheck.piml -->
4: <!-- Matthew Hall -->
5:
1.2 ! matthew 6: <!-- $Id: html_parser_check.piml,v 1.1 2004/12/06 20:27:38 matthew Exp $ -->
1.1 matthew 7:
8: <!--
9:
10: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
11:
12: LON-CAPA is free software; you can redistribute it and/or modify
13: it under the terms of the GNU General Public License as published by
14: the Free Software Foundation; either version 2 of the License, or
15: (at your option) any later version.
16:
17: LON-CAPA is distributed in the hope that it will be useful,
18: but WITHOUT ANY WARRANTY; without even the implied warranty of
19: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: GNU General Public License for more details.
21:
22: You should have received a copy of the GNU General Public License
23: along with LON-CAPA; if not, write to the Free Software
24: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25:
26: /home/httpd/html/adm/gpl.txt
27:
28: http://www.lon-capa.org/
29:
30: -->
31:
32: <piml>
33: <targetroot>/</targetroot>
34: <files>
35: <file>
36: <target dist="default">/home/httpd/lonUsers</target>
37: <perlscript mode="fg">
1.2 ! matthew 38:
1.1 matthew 39: use strict;
40: use HTML::Parser;
41:
42: my $version = $HTML::Parser::VERSION;
43:
44: ##
45: ## First test
46: ##
47: my $text='';
1.2 ! matthew 48: my $p = HTML::Parser->new(api_version => 3);
! 49: $p->handler(start =>
1.1 matthew 50: sub {
51: my($tag, $attr) = @_;
52: $text .= "S[$tag";
53: for my $k (sort keys %$attr) {
1.2 ! matthew 54: my $v = $attr->{$k};
1.1 matthew 55: $text .= " key $k= value $v";
56: }
57: $text .= "]";
58: }, "tagname,attr");
1.2 ! matthew 59: $p->handler(text =>
1.1 matthew 60: sub {
61: $text .= 'T{'.shift().'}';
62: }, "text");
63: $text='';
1.2 ! matthew 64: $p->parse('<img a="b" "=\'"\' c=d />')->eof;
1.1 matthew 65:
66: my $first_test_result = $text;
67: my $first_expected_result =
68: q{S[img key "= value " key /= value / key a= value b key c= value d]};
69: if (! $first_test_result) {
70: print "Unable to run first HTML::Parser test\n";
71: } elsif ($first_test_result ne $first_expected_result) {
1.2 ! matthew 72: print <<"END";
1.1 matthew 73: **** WARNING: HTML::Parser is not working properly.
74: You are using version $version. For test 1 it returned
75: "$first_test_result"
76: END
77: }
78:
79:
80: ##
81: ## Second test
82: ##
1.2 ! matthew 83: $p->xml_mode(1);
1.1 matthew 84: $text='';
1.2 ! matthew 85: $p->parse('<img a="b" "=\'"\' c=d />')->eof;
1.1 matthew 86: my $second_test_result = $text;
87: my $second_expected_result =
88: q{S[img key "= value " key a= value b key c= value d]};
89: if (! $second_test_result) {
90: print "Unable to run second HTML::Parser test\n";
91: } elsif ($second_test_result ne $second_expected_result) {
1.2 ! matthew 92: print <<"END";
1.1 matthew 93: **** WARNING: HTML::Parser is not working properly.
94: You are using version $version. For test 2 it returned
95: "$second_test_result"
96: END
97: }
98:
99: </perlscript>
100: </file>
101: </files>
102: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>