File: 10use_metadata.t

package info (click to toggle)
libtext-multimarkdown-perl 1.000035-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 1,772 kB
  • ctags: 148
  • sloc: perl: 2,186; makefile: 8
file content (51 lines) | stat: -rw-r--r-- 1,701 bytes parent folder | download | duplicates (6)
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
use strict;
use warnings;
use Test::More tests => 7;

#1
use_ok( 'Text::MultiMarkdown');

my $instr = qq{use wikilinks: on\nbase url: http://www.test.com/\n\nA trivial block of text with a WikiWord};

my $m = Text::MultiMarkdown->new(
    use_metadata => 1,
);
my $expstr = qq{base url: http://www.test.com/<br />\nuse wikilinks: on<br />\n
<p>A trivial block of text with a <a href="http://www.test.com/WikiWord">WikiWord</a></p>\n};
is( #2
    $m->markdown($instr) => $expstr, 
    'Markdown with wiki links, and base url, metadata switched on in instance'
);

$m = Text::MultiMarkdown->new(
    use_metadata => 0,
);
my $expstr2 = qq{<p>use wikilinks: on\nbase url: http://www.test.com/</p>\n\n<p>A trivial block of text with a WikiWord</p>\n};
is( #3
    $m->markdown($instr) => $expstr2, 
    'Markdown with wiki links, with base url in instance (no metadata)'
);
is( #4
    $m->markdown($instr, { use_metadata => 1 }) => $expstr, 
    'Markdown with wiki links, and base url, metadata switched on in options'
);
is( #5
    $m->markdown($instr) => $expstr2, 
    'Markdown with wiki links, with base url in instance (no metadata) - try 2 to ensure option to markdown does not frob setting'
);

$m = Text::MultiMarkdown->new(
    use_metadata   => 0,
    strip_metadata => 1,  
);
$expstr = qq{<p>A trivial block of text with a WikiWord</p>\n};
is( #6
    $m->markdown($instr) => $expstr, 
    'Markdown with wiki links, with metadata off and stripped'
);

$expstr = qq{<p>A trivial block of text with a <a href="http://www.test.com/WikiWord">WikiWord</a></p>\n};
is( #7
    $m->markdown($instr, { use_metadata => 1 }) => $expstr, 
    'Markdown with wiki links, with metadata on but stripped'
);