MojoMojo
view release on metacpan or search on metacpan
t/formatter_markdown.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 15;
use MojoMojo::Formatter::Markdown;
use Test::Differences;
my ( $content, $got, $expected, $test );
#----------------------------------------------------------------------------
$test = 'extra EOL at EOF';
$content = 'foo';
$expected = "<p>foo</p>\n";
is( MojoMojo::Formatter::Markdown->main_format_content( \$content ), $expected, $test );
$test = 'consecutive EOL at EOF collapsed into one';
$content = "foo\n\n";
$expected = "<p>foo</p>\n";
is( MojoMojo::Formatter::Markdown->main_format_content( \$content ), $expected, $test );
#----------------------------------------------------------------------------
$content = 'Here is an  image.';
$expected =
'<p>Here is an <img src="/image.jpg" alt="Image alt text" title="Image title" /> image.</p>'
. "\n"; # Markdown makes sure there's a final "\n"
is( MojoMojo::Formatter::Markdown->main_format_content( \$content ),
$expected, 'basic image' );
#----------------------------------------------------------------------------
$test = '<div with="attributes"> in a code span';
$content = <<'MARKDOWN';
This is the code: `<div markdown="1">`.
MARKDOWN
eq_or_diff( MojoMojo::Formatter::Markdown->main_format_content( \$content ),
<<'HTML', $test );
<p>This is the code: <code><div markdown="1"></code>.</p>
HTML
#----------------------------------------------------------------------------
$test = 'blockquotes';
$content = <<'MARKDOWN';
Below is a blockquote:
> quoted text
A quote is above.
MARKDOWN
eq_or_diff( MojoMojo::Formatter::Markdown->main_format_content( \$content ),
<<'HTML', $test );
<p>Below is a blockquote:</p>
<blockquote>
<p>quoted text</p>
</blockquote>
<p>A quote is above.</p>
HTML
#----------------------------------------------------------------------------
$test = 'direct <http://url.com> hyperlinks';
$content = <<'MARKDOWN';
This should be linked: <http://mojomojo.org>.
MARKDOWN
eq_or_diff( MojoMojo::Formatter::Markdown->main_format_content( \$content ),
<<'HTML', $test );
( run in 0.908 second using v1.01-cache-2.11-cpan-437f7b0c052 )