File: opt-00.t

package info (click to toggle)
libhtml-tidy-perl 1.60-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 472 kB
  • sloc: perl: 1,289; sh: 23; makefile: 7
file content (68 lines) | stat: -rw-r--r-- 1,407 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!perl -T

use warnings;
use strict;

use Test::More tests => 1;

use HTML::Tidy;

my $tidy = HTML::Tidy->new({
    tidy_mark           => 0,
    add_xml_decl        => 1,
    output_xhtml        => 1,
    doctype             => 'strict',
    clean               => 1,
    css_prefix          => 'myprefix',
    drop_empty_paras    => 0,
    enclose_block_text  => 1,
    escape_cdata        => 1,
    hide_comments       => 1,
    replace_color       => 1,
    repeated_attributes => 'keep-first',
    break_before_br     => 1,
    vertical_space      => 1,
    newline             => 'cr',
});

my $input=<<'EOD';
<h1>example</h1>
Here's some <B>ed and <BR/>eakfest MarkUp: <!-- ... -->
<font color="#0000FF" color="RED">...</font>
<p></P>
EOD

my $expected =<<'EOD';
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
</title>
<style type="text/css">
/*<![CDATA[*/
 span.myprefix1 {color: blue}
/*]]>*/
</style>
</head>
<body>
<h1>example</h1>

<p>Here's some <b>ed and
<br />
eakfest MarkUp: <span class="myprefix1">...</span></b></p>

<p>
</p>
</body>
</html>
EOD

my @expected = split(/\n/, $expected);

my $result = $tidy->clean( $input );
my @result = split(/\r/, $result);

is_deeply( \@result, \@expected, 'Cleaned stuff looks like what we expected');