File: 06disable_encode_entities.t

package info (click to toggle)
libtext-textile-perl 2.12-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 208 kB
  • ctags: 51
  • sloc: perl: 2,140; makefile: 2
file content (92 lines) | stat: -rw-r--r-- 1,753 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
86
87
88
89
90
91
92
#!/usr/bin/perl -Tw

use warnings;
use strict;
use Test::More tests => 2;
use Text::Textile;

{
    my $tt = Text::Textile->new( disable_encode_entities => 1 );

    my $source = <<'SOURCE';
start paragraph

another paragraph

* list of things with "urls":http://www.jerakeen.org in
* more things in the list

a http://bare.url.here. and an email@address.com

>>> No encode_entities here
<<< and there
&&& and here too

SOURCE

    my $dest = $tt->process($source);
    $dest =~ s/(^\s+|\s+$)//g;

    my $expected = <<'EXPECTED';
<p>start paragraph</p>

<p>another paragraph</p>

<ul>
<li>list of things with <a href="http://www.jerakeen.org">urls</a> in</li>
<li>more things in the list</li>
</ul>

<p>a http://bare.url.here. and an email@address.com</p>

<p>>>> No encode_entities here<br />
<<< and there<br />
&&& and here too</p>
EXPECTED
    $expected =~ s/(^\s+|\s+$)//g;

    is( $dest, $expected );
}

{
    my $tt = Text::Textile->new( disable_encode_entities => 0 );

    my $source = <<'SOURCE';
start paragraph

another paragraph

* list of things with "urls":http://www.jerakeen.org in
* more things in the list

a http://bare.url.here. and an email@address.com

>>> encode_entities here
<<< and there
&&& and here too

SOURCE

    my $dest = $tt->process($source);
    $dest =~ s/(^\s+|\s+$)//g;

    my $expected = <<'EXPECTED';
<p>start paragraph</p>

<p>another paragraph</p>

<ul>
<li>list of things with <a href="http://www.jerakeen.org">urls</a> in</li>
<li>more things in the list</li>
</ul>

<p>a http://bare.url.here. and an email@address.com</p>

<p>&gt;&gt;&gt; encode_entities here<br />
&lt;&lt;&lt; and there<br />
&amp;&amp;&amp; and here too</p>
EXPECTED
    $expected =~ s/(^\s+|\s+$)//g;

    is( $dest, $expected );
}