File: custom_format.t

package info (click to toggle)
libhtml-formattext-withlinks-perl 0.14-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 188 kB
  • ctags: 20
  • sloc: perl: 246; makefile: 2
file content (85 lines) | stat: -rw-r--r-- 1,632 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# $Id$

use Test::More tests => 9;
use HTML::FormatText::WithLinks;

my $html = new_html();
my $f = HTML::FormatText::WithLinks->new( leftmargin => 0, 
            before_link => "[%n] ",
            footnote => "[%n] %l");

ok($f, 'object created');

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

my $correct_text = qq!This is a mail of some sort with a [1] link.



[1] http://example.com/


!;

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

$f = HTML::FormatText::WithLinks->new( leftmargin => 0, 
            before_link => "[%n] ",
            footnote    =>  '');

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

$correct_text = qq!This is a mail of some sort with a [1] link.

!;

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

$correct_text = qq!This is a mail of some sort with a link[1].



1. http://example.com/


!;

$f = HTML::FormatText::WithLinks->new( leftmargin => 0, 
            before_link => "",
            after_link => "[%n]");

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

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

$correct_text = qq!This is a mail of some sort with a [0]link.



0. http://example.com/


!;

$f = HTML::FormatText::WithLinks->new( leftmargin => 0, 
            link_num_generator => sub { shift(); } );

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

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

sub new_html {
return <<'HTML';
<html>
<body>
<p>
This is a mail of some sort with a <a href="http://example.com/">link</a>.
</p>
</body>
</html>
HTML
}