| 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(":::\ncontent\n:::"), "<div>\n<p>content</p>\n</div>\n", 'naked block'); |
| 13 |
is(run("::: block\ncontent\n:::"), "<div class=\"block\">\n<p>content</p>\n</div>\n", 'block with name'); |
| 14 |
is(run("::: {#block}\ncontent\n:::"), "<div id=\"block\">\n<p>content</p>\n</div>\n", 'block with id'); |
| 15 |
is(run("::: {.Block}\ncontent\n:::"), "<div class=\"Block\">\n<p>content</p>\n</div>\n", 'block with class'); |
| 16 |
is(run("::: {.block .other}\ncontent\n:::"), "<div class=\"block other\">\n<p>content</p>\n</div>\n", 'block with classes'); |
| 17 |
is(run("::: {key=value}\ncontent\n:::"), "<div data-key=\"value\">\n<p>content</p>\n</div>\n", 'block with data'); |
| 18 |
is(run("::: name {.block #id .other}\ncontent\n:::"), "<div id=\"id\" class=\"name block other\">\n<p>content</p>\n</div>\n", 'block with name, id, and classes'); |
| 19 |
|
| 20 |
is(run(":::: B1\n::: B2\ncontent\n:::\nrest\n::::\nend\n"), "<div class=\"b1\">\n<div class=\"b2\">\n<p>content</p>\n</div>\n<p>rest</p>\n</div>\n<p>end</p>\n", 'nested blocks'); |
| 21 |
|
| 22 |
like(warning { run("::: {#junk=junk}\n:::") }, qr/Unused attribute content/, 'warn for junk attribute'); |
| 23 |
like(warning { run("::: [content]\n:::") }, qr/Unused inline content/, 'warn for inline content'); |
| 24 |
|
| 25 |
is(run(":::\ncontent\n:::", use_directive_blocks => 0), "<p>:::\ncontent\n:::</p>\n", 'disable block directives'); |
| 26 |
|
| 27 |
is(run(":::::::: SPOILERS ::::::::\ncontent\n::::::::::::::::::::::::::"), "<div class=\"spoilers\">\n<p>content</p>\n</div>\n", 'fancy block'); |
| 28 |
|
| 29 |
done_testing; |