diff options
Diffstat (limited to 't')
-rw-r--r-- | t/008filter.t | 3 | ||||
-rw-r--r-- | t/markdown.t | 73 |
2 files changed, 76 insertions, 0 deletions
diff --git a/t/008filter.t b/t/008filter.t index cae1e6880..443fb2b4f 100644 --- a/t/008filter.t +++ b/t/008filter.t @@ -147,6 +147,9 @@ sub directive_ok { $directive =~ s/^\s*//; $directive =~ s/\s*$//; + # Ignore blocks explicitly marked as ok + return 1 if $directive =~ /\b## no-008filter\b/; + # Empty directives are ok; they are usually line break helpers return 1 if $directive eq ''; diff --git a/t/markdown.t b/t/markdown.t new file mode 100644 index 000000000..0344706c9 --- /dev/null +++ b/t/markdown.t @@ -0,0 +1,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>'), + "<script>hijack()</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; |