from django.test import TestCase
from django.template import Context, Template


class BlogTemplatetagsTestCase(TestCase):
    def test_md_as_html5(self):

        body = """# H1 heading

**Paragraph** text

## H2 heading

~~~~{.python}
if True:
  print("Some Python code in markdown")
~~~~

1 First
2. Second
  * sub
3. Last"""

        expected = """<h1>H1 heading</h1>
<p><strong>Paragraph</strong> text</p>
<h2>H2 heading</h2>
<pre><code class="python">if True:
  print(&quot;Some Python code in markdown&quot;)
</code></pre>

<p>1 First
2. Second
  * sub
3. Last</p>"""

        out = Template(
            "{% load markdown %}"
            "{{ body|md_as_html5 }}"
        ).render(Context({'body': body}))

        self.assertEqual(out, expected)

@@ -200,17 +200,51 @@
 ** text%0A
+%3Cstrong%3Ehtml markup works%3C/strong%3E
 %0A
-
 ## H2 he
@@ -283,30 +283,37 @@
 print(%22Some 
+%3Cb%3E
 Python
+%3C/b%3E
  code in mar
@@ -440,16 +440,51 @@
 ng%3E text
+%0A%3Cstrong%3Ehtml markup works%3C/strong%3E
 %3C/p%3E%0A%3Ch2
@@ -554,22 +554,41 @@
 ot;Some 
-Python
+&lt;b&gt;Python&lt;/b&gt;
  code in

Test HTML handling in markdown