| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use utf8; |
| 4 |
|
| 5 |
use Markdown::Perl; |
| 6 |
use Test2::V0; |
| 7 |
|
| 8 |
sub run { |
| 9 |
&Markdown::Perl::convert; |
| 10 |
} |
| 11 |
|
| 12 |
is(run('***'), "<hr />\n", 'break1'); |
| 13 |
is(run(' - - -'), "<hr />\n", 'break2'); |
| 14 |
is(run(' ___ __ '), "<hr />\n", 'break3'); |
| 15 |
|
| 16 |
is(run('# test'), "<h1>test</h1>\n", 'atx_heading1'); |
| 17 |
is(run('#'), "<h1></h1>\n", 'atx_heading2'); |
| 18 |
is(run('## '), "<h2></h2>\n", 'atx_heading3'); |
| 19 |
is(run('#### ###'), "<h4></h4>\n", 'atx_heading4'); |
| 20 |
is(run('## other '), "<h2>other</h2>\n", 'atx_heading5'); |
| 21 |
|
| 22 |
is(run("abc\n===\n", use_setext_headings => 1), "<h1>abc</h1>\n", 'setext_heading1'); |
| 23 |
is(run("abc\ndef\n===\n", use_setext_headings => 1), "<h1>abc\ndef</h1>\n", 'setext_heading2'); |
| 24 |
is(run("abc\n---\n", use_setext_headings => 1), "<h2>abc</h2>\n", 'setext_heading3'); |
| 25 |
is(run(" abc\n===\n", use_setext_headings => 1), "<h1>abc</h1>\n", 'setext_heading4'); |
| 26 |
is(run("abc\n =\n", use_setext_headings => 1), "<h1>abc</h1>\n", 'setext_heading5'); |
| 27 |
|
| 28 |
is(run(' test'), "<pre><code>test</code></pre>\n", 'indented_code1'); |
| 29 |
is(run(" test\n next\n"), "<pre><code>test\n next\n</code></pre>\n", 'indented_code2'); |
| 30 |
is(run("\t test\n\t next\n"), "<pre><code> test\n next\n</code></pre>\n", 'indented_code3'); |
| 31 |
|
| 32 |
is(run("```\ntest\n```"), "<pre><code>test\n</code></pre>\n", 'fenced_code1'); |
| 33 |
is(run(" ```\ntest\n other\n```"), "<pre><code>test\n other\n</code></pre>\n", 'fenced_code2'); |
| 34 |
is(run("~~~~\ntest\n~~~~"), "<pre><code>test\n</code></pre>\n", 'fenced_code3'); |
| 35 |
is(run("~~~~\ntest\n~~~\n~~~~"), "<pre><code>test\n~~~\n</code></pre>\n", 'fenced_code4'); |
| 36 |
is(run("```abc\ntest\n```"), "<pre><code class=\"language-abc\">test\n</code></pre>\n", 'fenced_code5'); |
| 37 |
is(run("```abc def\ntest\n```"), "<pre><code class=\"language-abc\">test\n</code></pre>\n", 'fenced_code6'); |
| 38 |
|
| 39 |
is(run("abc"), "<p>abc</p>\n", 'paragraph1'); |
| 40 |
is(run("abc\ndef"), "<p>abc\ndef</p>\n", 'paragraph2'); |
| 41 |
is(run("abc\n\ndef"), "<p>abc</p>\n<p>def</p>\n", 'paragraph3'); |
| 42 |
is(run("foo\r\nbar"), "<p>foo\nbar</p>\n", 'paragraph4'); |
| 43 |
|
| 44 |
is(run("<pre>\nabc\n</pre>\n"), "<pre>\nabc\n</pre>\n", 'html1'); |
| 45 |
is(run("<pre>\nabc\n"), "<pre>\nabc\n", 'html2'); |
| 46 |
is(run("<h1>\nabc\n"), "<h1>\nabc\n", 'html3'); |
| 47 |
is(run("<h1>\nabc\n\ndef"), "<h1>\nabc\n<p>def</p>\n", 'html4'); |
| 48 |
is(run("<SomeTag value = 'abc'>\n*abc*\n\ndef"), "<SomeTag value = 'abc'>\n*abc*\n<p>def</p>\n", 'html5'); |
| 49 |
|
| 50 |
done_testing; |