use strict; use warnings; use Test::More tests => 21; use Test::Differences; use FindBin '$Bin'; use lib "$Bin/../lib"; use_ok 'Text::Markdown'; my $m = Text::Markdown->new(); my ($html, $test); #------------------------------------------------------------------------------- $test = "sanity check: markown in block elements doesn't get interpreted"; $html = $m->markdown(<<"EOF");

Literal *asterisks* and _underscores_

EOF eq_or_diff $html, <<'EOF', $test;

Literal *asterisks* and _underscores_

EOF #------------------------------------------------------------------------------- $test = 'markdown on in div - generate

tags'; $html = $m->markdown(<<"EOF"); some text here

Interpreted *asterisks* and _underscores_
EOF eq_or_diff $html, <<'EOF', $test;

some text here

Interpreted asterisks and underscores

EOF #------------------------------------------------------------------------------- $test = 'markdown on in h2 - no

tags in h2'; $html = $m->markdown(<<"EOF"); some text here

Interpreted *asterisks* and _underscores_

EOF eq_or_diff $html, <<'EOF', $test;

some text here

Interpreted asterisks and underscores

EOF #------------------------------------------------------------------------------- # "block-level HTML elements — e.g.
, ,
, 

, etc. — must be separated # from surrounding content by blank lines, and the start and end tags of the block # should not be indented with tabs or spaces." -- http://daringfireball.net/projects/markdown/syntax#html $test = 'some characters before an

make the h2 an ignored element'; $html = $m->markdown(<<"EOF"); stuff

Interpreted *asterisks* and _underscores_ because HTML block elements must be separated from surrounding content by blank lines

EOF eq_or_diff $html, <<'EOF', $test;

stuff

Interpreted asterisks and underscores because HTML block elements must be separated from surrounding content by blank lines

EOF #------------------------------------------------------------------------------- $test = "adding markdown='on' if there were some characters before the h2, doesn't change anything. markdown='on' won't be removed."; $html = $m->markdown(<<"EOF"); stuff

Interpreted *asterisks* and _underscores_, and markdown="on" left alone because this wasn't a block HTML element in the first place

EOF eq_or_diff $html, <<'EOF', $test;

stuff

Interpreted asterisks and underscores, and markdown="on" left alone because this wasn't a block HTML element in the first place

EOF #------------------------------------------------------------------------------- $test = '
in span-level HTML'; $html = $m->markdown(<<"EOF"); Interpreted *asterisks*.
Interpreted _underscores_.
EOF eq_or_diff $html, <<'EOF', $test;

Interpreted asterisks.


Interpreted underscores.

EOF #------------------------------------------------------------------------------- $test = '
in block-level HTML with markdown="on"'; $html = $m->markdown(<<"EOF");
Interpreted *asterisks*.
Interpreted _underscores_.
EOF eq_or_diff $html, <<'EOF', $test;

Interpreted asterisks.


Interpreted underscores.

EOF #------------------------------------------------------------------------------- $test = "don't mess with the markdown attribute if part of code span or block"; $html = $m->markdown(<<"EOF"); A `
` will interpret Markdown, unless in a code block.
The *above* is a '
' tag in a code block
EOF eq_or_diff $html, <<'EOF', $test;

A <div markdown="1"> will interpret Markdown, unless in a code block.

<div markdown="1">
The *above* is a '<div>' tag
in a code block</div>
EOF #------------------------------------------------------------------------------- $test = "leave [div] alone, it's not
"; $html = $m->markdown(<<"EOF"); [div markdown="1"] The above is NOT a
!
EOF eq_or_diff $html, <<'EOF', $test;

[div markdown="1"] The above is NOT a

!

EOF #------------------------------------------------------------------------------- $test = "leave !div! alone, it's not
, and it's in code too"; $html = $m->markdown(<<"EOF"); !div markdown="1"! The above is NOT a
!
EOF eq_or_diff $html, <<'EOF', $test;
!div markdown="1"!
The above is NOT a <div>!
</div>
EOF #------------------------------------------------------------------------------- $test = 'start interpreting Markdown without blank line sandwiching'; $html = $m->markdown(<<"EOF"); *outside of the div*
*start interpreting Markdown without blank line sandwiching*
EOF eq_or_diff $html, <<'EOF', $test;

outside of the div

start interpreting Markdown without blank line sandwiching

EOF #------------------------------------------------------------------------------- $test = '
with inner list'; $html = $m->markdown(<<"EOF");
1. this 2. is a list
EOF eq_or_diff $html, <<'EOF', $test;
  1. this
  2. is a list
EOF #------------------------------------------------------------------------------- $test = '
with inner code block'; $html = $m->markdown(<<"EOF");
code line 1 code line 2
EOF eq_or_diff $html, <<'EOF', $test;
code line 1
code line 2
EOF #------------------------------------------------------------------------------- $test = '
with inner blockquote'; $html = $m->markdown(<<"EOF");
> Thus spoke Lincoln
EOF eq_or_diff $html, <<'EOF', $test;

Thus spoke Lincoln

EOF #------------------------------------------------------------------------------- $test = '
with inner block HTML'; $html = $m->markdown(<<"EOF");
*interpreted*
EOF eq_or_diff $html, <<'EOF', $test;

interpreted

EOF #------------------------------------------------------------------------------- $test = '
with inner
, which ends with exactly one line'; $html = $m->markdown(<<"EOF");
EOF eq_or_diff $html, <<'EOF', $test;
EOF #------------------------------------------------------------------------------- $test = '
comprehensive'; $html = $m->markdown(<<"EOF"); *marked down text*
* this * is a list
*no markdown interpretation here*
*no markdown interpretation here*
*no markdown interpretation here*
EOF eq_or_diff $html, <<'EOF', $test;

marked down text

  • this
  • is a list
*no markdown interpretation here*
*no markdown interpretation here*
*no markdown interpretation here*
EOF #------------------------------------------------------------------------------- $test = '
with multiple lines of attributes'; $html = $m->markdown(<<"EOF"); EOF eq_or_diff $html, <<'EOF', $test; EOF #------------------------------------------------------------------------------- $test = '
- can put the markdown="1" attribute anywhere'; $html = $m->markdown(<<"EOF"); EOF eq_or_diff $html, <<'EOF', $test; EOF #------------------------------------------------------------------------------- $test = "sanity check: just code"; $html = $m->markdown(<<"EOF"); Below is code code Above was code EOF eq_or_diff $html, <<'EOF', $test;

Below is code

code

Above was code

EOF