File: 31htmltxt.t

package info (click to toggle)
libmail-box-perl 2.095-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,792 kB
  • ctags: 1,544
  • sloc: perl: 22,917; makefile: 2
file content (85 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download
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
#!/usr/bin/env perl -T
#
# Test conversions from HTML/XHTML to plain text with HTML::FormatText
#

use strict;
use warnings;

use lib qw(. .. tests);
use Tools;

use Test::More;

use Mail::Message::Body::Lines;

BEGIN {
   
   eval 'require HTML::FormatText';

   if($@)
   {   plan skip_all => "requires HTML::FormatText.\n";
       exit 0;
   }

   require Mail::Message::Convert::HtmlFormatText;
   plan tests => 7;
}

my $html  = Mail::Message::Convert::HtmlFormatText->new;

my $body = Mail::Message::Body::Lines->new
  ( type => 'text/html'
  , data => $raw_html_data
  );

my $f = $html->format($body);
ok(defined $f);
ok(ref $f);
isa_ok($f, 'Mail::Message::Body');
is($f->mimeType, 'text/plain');
is($f->charset, 'iso-8859-1');
is($f->transferEncoding, 'none');

is($f->string, <<'EXPECTED');
   Life according to Brian
   =======================

   This is normal text, but not in a paragraph.

   New paragraph in a bad way. And this is just a continuation. When
   texts get long, they must be auto-wrapped; and even that is working
   already.


   Silly subsection at once



   and another chapter
   ===================


   again a section
   ---------------

   Normal paragraph, which contains an [IMAGE], some italics with
   linebreak and code

   And now for the preformatted stuff
      it should stay as it was
         even   with   strange blanks
     and indentations

   And back to normal text...

     * list item 1

         1. list item 1.1

         2. list item 1.2

     * list item 2
EXPECTED

exit 0;