File: 04fragments.t

package info (click to toggle)
libhtml-html5-parser-perl 0.992-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,444 kB
  • sloc: perl: 16,129; makefile: 2; sh: 1
file content (48 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## skip Test::Tabs
use Test::More tests => 5;
use HTML::HTML5::Parser;

my $parser = HTML::HTML5::Parser->new;
my $input  = "<b>Hello</b></td></tr> <i>World</i>";
my $NS     = 'xmlns="http://www.w3.org/1999/xhtml"';

can_ok $parser => 'parse_balanced_chunk';

is(
	$parser->parse_balanced_chunk($input, {within=>'div'})->toString,
	"<b $NS>Hello</b> <i $NS>World</i>",
	'within div',
	);

is(
	$parser->parse_balanced_chunk($input, {within=>'td'})->toString,
	"<i $NS>World</i><b $NS>Hello</b> ",
	'within td',
	);

is(
	$parser->parse_balanced_chunk($input, {force_within=>'td'})->toString,
	"<b $NS>Hello</b>",
	'force within td',
	);

my $list = $parser->parse_balanced_chunk($input, {mark_outliers=>1, within=>'td', as=>'list'});
ok(
	$list->get_node(1)->hasAttribute('data-perl-html-html5-parser-outlier'),
	'mark outliers',
	);

=head1 PURPOSE

Test C<parse_balanced_chunk> method.

=head1 AUTHOR

Toby Inkster, E<lt>tobyink@cpan.orgE<gt>

=head1 COPYRIGHT AND LICENCE

Copyright (C) 2012 by Toby Inkster

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.