-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathmarkdown.t
59 lines (34 loc) · 983 Bytes
/
markdown.t
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
use strict;
use warnings;
use lib 't/lib';
use Test::More;
use MetaCPAN::Web::RenderUtil qw( render_markdown );
my $html = render_markdown(<<'EOM');
# Heading
Some body text
## Heading
More stuff
## Heading
more stuff
## Heading **with** _markup_
Content
EOM
like $html, qr{<h1 id="heading">Heading</h1>}, 'first heading';
like $html, qr{<h2 id="heading-2">Heading</h2>}, 'second heading';
like $html, qr{<h2 id="heading-3">Heading</h2>}, 'third heading';
like $html, qr{<h2 id="heading-with-markup">Heading <}, 'heading with markup';
$html = render_markdown(<<'EOM');
# Heading
Some body text
<div>Raw HTML</div>
EOM
like $html, qr{Raw HTML}, 'raw html allowed';
$html = render_markdown( <<'EOM', unsafe => 0 );
# Heading
Some body text
<div>Raw HTML</div>
EOM
unlike $html, qr{Raw HTML}, 'raw html blocked';
eval { render_markdown( '# Heading', chorg => 1 ) };
like "$@", qr/^Unsupported options: chorg /, 'invalid options throw errors';
done_testing();