From 170ec08234e29050c5d78d52e4100207625897d2 Mon Sep 17 00:00:00 2001 From: Israel Madueme Date: Fri, 15 Jun 2018 14:42:19 -0700 Subject: Bug 1456877 - Add a wrapper around libcmark_gfm to Bugzilla --- t/markdown.t | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 t/markdown.t (limited to 't') 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'), + "

header

\n", + 'Simple header' +); + +is( + $parser->render_html('`code snippet`'), + "

code snippet

\n", + 'Simple code snippet' +); + +is( + $parser->render_html('http://bmo-web.vm'), + "

http://bmo-web.vm

\n", + 'Autolink extension' +); + +is( + $parser->render_html(''), + "<script>hijack()</script>\n", + 'Tagfilter extension' +); + +is( + $parser->render_html('~~strikethrough~~'), + "

strikethrough

\n", + 'Strikethrough extension' +); + +my $table_markdown = <<'MARKDOWN'; +| Col1 | Col2 | +| ---- |:----:| +| val1 | val2 | +MARKDOWN + +my $table_html = <<'HTML'; + + + + + + + + + + + +
Col1Col2
val1val2
+HTML + +is( + $parser->render_html($table_markdown), + $table_html, + 'Table extension' +); + +done_testing; -- cgit v1.2.3-24-g4f1b