8 my $p = HTML::Parser->new(start_h => [sub { $tag = shift }, "tagname"],
9 text_h => [sub { $text .= shift }, "dtext"],
13 use Test::More tests => 14;
17 $p->marked_sections(1);
21 $p->parse("<![[foo]]>");
24 $p->parse("<![TEMP INCLUDE[bar]]>");
27 $p->parse("<![ INCLUDE -- IGNORE -- [foo<![IGNORE[bar]]>]]>\n<br>");
28 is($text, "foobarfoo\n");
31 $p->parse("<![ CDATA [<foo");
32 $p->parse("<![IGNORE[bar]]>,bar>]]><br>");
33 is($text, "<foo<![IGNORE[bar,bar>]]>");
36 $p->parse("<![ RCDATA [å<a>]]><![CDATA[å<a>]]>å<a><br>");
37 is($text, "å<a>å<a>å");
41 $p->parse("<![INCLUDE RCDATA CDATA IGNORE [fooå<a>]]><br>");
45 $p->parse("<![INCLUDE RCDATA CDATA [fooå<a>]]><br>");
46 is($text, "fooå<a>");
49 $p->parse("<![INCLUDE RCDATA [fooå<a>]]><br>");
53 $p->parse("<![INCLUDE [fooå<a>]]><br>");
57 $p->parse("<![[fooå<a>]]><br>");
60 # offsets/line/column numbers
61 $p = HTML::Parser->new(default_h => [\&x, "line,column,offset,event,text"],
64 $p->parse(<<'EOT')->eof;
78 my($line, $col, $offset, $event, $text) = @_;
81 push(@x, "$line.$col:$offset $event \"$text\"\n");
85 is(join("", @x), <<'EOT');
86 1.0:0 start_document ""
89 1.11:11 end "</title>"
91 3.3:32 text "fooå<a>\n"
93 5.4:54 text "\nINCLUDE\nSTUFF\n"
99 10.0:89 end_document ""
102 my $doc = "<Tag><![CDATA[This is cdata]]></Tag>";
104 $p = HTML::Parser->new(
105 marked_sections => 1,
107 default => [ sub { $result .= join("",@_); }, "skipped_text,text" ]
113 $p = HTML::Parser->new(
114 text_h => [sub { $text .= shift }, "dtext"],
115 marked_sections => 1,
118 $p->parse("<![CDATA[foo [1]]]>");
119 is($text, "foo [1]", "CDATA text ending in square bracket");