File: skip_linked_urls.t

package info (click to toggle)
libhtml-formattext-withlinks-perl 0.15-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 246; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download | duplicates (4)
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
use Test::More 'no_plan';
use HTML::FormatText::WithLinks;

my $html = simple_example();
my $f = HTML::FormatText::WithLinks->new(
    leftmargin          => 0,
    skip_linked_urls    => 1,
    before_link         => '',
    after_link          => ' (%l)',
    footnote            => ''
);

ok($f, 'object created');

my $text = $f->parse($html);

my $correct_text = qq!This is a mail of some sort with a bunch of linked URLs.

http://example.com/

and another https://example.com/

ftp now ftp://example.com

not the same but not this (http://example.com/)

or this http://example.com (http://example.com/foo)

!;

ok($text, 'html formatted');
is($text, $correct_text, 'html correctly formatted');


sub simple_example {
return <<'HTML';
<html>
<body>
<p>This is a mail of some sort with a bunch of linked URLs.</p>
<p><a href="http://example.com/">http://example.com/</a></p>
<p>and another <a href="https://example.com/">https://example.com/</a></p>
<p>ftp now <a href="ftp://example.com">ftp://example.com</a></p>
<p>not the same <a href="http://example.com/">but not this</a></p>
<p>or this <a href="http://example.com/foo">http://example.com</a></p>
</body>
</html>
HTML
}