summaryrefslogtreecommitdiffstats
path: root/t/markdown.t
blob: 0344706c9de1ddae0e178dd5ab70fd894d87594c (plain)
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
use 5.10.1;
use strict;
use warnings;
use lib qw( . lib local/lib/perl5 );
use Bugzilla;
use Test::More;

my $parser = Bugzilla->markdown_parser;

is(
    $parser->render_html('# header'),
    "<h1>header</h1>\n",
    'Simple header'
);

is(
    $parser->render_html('`code snippet`'),
    "<p><code>code snippet</code></p>\n",
    'Simple code snippet'
);

is(
    $parser->render_html('http://bmo-web.vm'),
    "<p><a href=\"http://bmo-web.vm\">http://bmo-web.vm</a></p>\n",
    'Autolink extension'
);

is(
    $parser->render_html('<script>hijack()</script>'),
    "&lt;script>hijack()&lt;/script>\n",
    'Tagfilter extension'
);

is(
    $parser->render_html('~~strikethrough~~'),
    "<p><del>strikethrough</del></p>\n",
    'Strikethrough extension'
);

my $table_markdown = <<'MARKDOWN';
| Col1 | Col2 |
| ---- |:----:|
| val1 | val2 |
MARKDOWN

my $table_html = <<'HTML';
<table>
<thead>
<tr>
<th>Col1</th>
<th align="center">Col2</th>
</tr>
</thead>
<tbody>
<tr>
<td>val1</td>
<td align="center">val2</td>
</tr></tbody></table>
HTML

is(
    $parser->render_html($table_markdown),
    $table_html,
    'Table extension'
);

done_testing;