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)

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
<strong>html markup works</strong>
## H2 heading

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

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

        expected = """<h1>H1 heading</h1>
<p><strong>Paragraph</strong> text
<strong>html markup works</strong></p>
<h2>H2 heading</h2>
<pre><code class="python">if True:
  print(&quot;Some &lt;b&gt;Python&lt;/b&gt; 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)

Test HTML handling in markdown
Test HTML handling in markdown

  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
- 
+ <strong>html markup works</strong>
  ## H2 heading
  
  ~~~~{.python}
  if True:
-   print("Some Python code in markdown")
+   print("Some <b>Python</b> code in markdown")
  ~~~~
  
  1 First
  2. Second
    * sub
  3. Last"""
  
          expected = """<h1>H1 heading</h1>
- <p><strong>Paragraph</strong> text</p>
+ <p><strong>Paragraph</strong> text
+ <strong>html markup works</strong></p>
  <h2>H2 heading</h2>
  <pre><code class="python">if True:
-   print(&quot;Some Python code in markdown&quot;)
+   print(&quot;Some &lt;b&gt;Python&lt;/b&gt; 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)
  
Test HTML handling in markdown
## Code Before:
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)

## Instruction:
Test HTML handling in markdown
## Code After:
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
<strong>html markup works</strong>
## H2 heading

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

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

        expected = """<h1>H1 heading</h1>
<p><strong>Paragraph</strong> text
<strong>html markup works</strong></p>
<h2>H2 heading</h2>
<pre><code class="python">if True:
  print(&quot;Some &lt;b&gt;Python&lt;/b&gt; 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)
