title: markdown not working for additional spaces?
body: <p>In a attempt to convert <code>md</code> to <code>html</code> file I am using this regex to replace all matching code's ending with <code>\n</code> to <code>\n\t</code>. The problem is its matching when using <code>search()</code> but not when using <code>sub()</code>. Need help.</p>
  
  <pre><code>import markdown2
  import re
  
  code_text = """* But why did the `is` operator evaluated to `False`? Let's see with this snippet.
    ```py
    class WTF(object):
      def __init__(self): print("I ")
      def __del__(self): print("D ")
    ```
  
    **Output:**"""
  
  print("PROBLEM :: \n", markdown2.markdown(code_text))
  
  pattern = re.compile(r"```py(?P&lt;code&gt;.*?)```", re.DOTALL)
  
  code_only = pattern.search(code_text).group("code")
  
  code_only = code_only.replace("\n", "\n\t")
  
  print("SOLUTION 1:: \n", markdown2.markdown(code_only))
  
  ###################################################
  # Replacing all code occurrences in the given string
  
  code_only = pattern.sub(lambda m: (m.group("code")).replace("\n", "\n\t"), code_text)
  
  print("SOLUTION 2:: \n", markdown2.markdown(code_only))
  </code></pre>
  
  <p><strong>OUTPUT :</strong></p>
  
  <pre><code>PROBLEM :: 
   &lt;ul&gt;
  &lt;li&gt;&lt;p&gt;But why did the &lt;code&gt;is&lt;/code&gt; operator evaluated to &lt;code&gt;False&lt;/code&gt;? Let's see with this snippet.
  &lt;code&gt;py
  class WTF(object):
  def __init__(self): print("I ")
  def __del__(self): print("D ")
  &lt;/code&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  SOLUTION 1:: 
   &lt;pre&gt;&lt;code&gt;  class WTF(object):
      def __init__(self): print("I ")
      def __del__(self): print("D ")
  &lt;/code&gt;&lt;/pre&gt;
  
  SOLUTION 2:: 
   &lt;ul&gt;
  &lt;li&gt;&lt;p&gt;But why did the &lt;code&gt;is&lt;/code&gt; operator evaluated to &lt;code&gt;False&lt;/code&gt;? Let's see with this snippet.&lt;/p&gt;
  
  &lt;p&gt;class WTF(object):
      def &lt;strong&gt;init&lt;/strong&gt;(self): print("I ")
      def &lt;strong&gt;del&lt;/strong&gt;(self): print("D ")&lt;/p&gt;
  
  &lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Try changing <code>code_text</code> to </p>
  
  <pre><code>```py
  &gt;&gt;&gt; a = "some_string"
  &gt;&gt;&gt; id(a)
  140420665652016
  &gt;&gt;&gt; id("some" + "_" + "string") # Notice that both the ids are same.
  140420665652016
  ```
  ### This is a heading
  ```py
  print("Hello World")
  ```
  </code></pre>
  
  <p>it works perfectly.</p>
  
  <p><strong>OUTPUT :</strong> </p>
  
  <pre><code>PROBLEM :: 
  
   &lt;p&gt;```py&lt;/p&gt;
  
  &lt;blockquote&gt;
    &lt;blockquote&gt;
      &lt;blockquote&gt;
        &lt;p&gt;a = "some&lt;em&gt;string"
        id(a)
        140420665652016
        id("some" + "&lt;/em&gt;" + "string") # Notice that both the ids are same.
        140420665652016
        ```&lt;/p&gt;
  
        &lt;h3&gt;This is a heading&lt;/h3&gt;
      &lt;/blockquote&gt;
    &lt;/blockquote&gt;
  &lt;/blockquote&gt;
  
  &lt;p&gt;&lt;code&gt;py
  print("Hello World")
  &lt;/code&gt;&lt;/p&gt;
  
  SOLUTION 1:: 
   &lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = "some_string"
  &amp;gt;&amp;gt;&amp;gt; id(a)
  140420665652016
  &amp;gt;&amp;gt;&amp;gt; id("some" + "_" + "string") # Notice that both the ids are same.
  140420665652016
  &lt;/code&gt;&lt;/pre&gt;
  
  SOLUTION 2:: 
   &lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = "some_string"
  &amp;gt;&amp;gt;&amp;gt; id(a)
  140420665652016
  &amp;gt;&amp;gt;&amp;gt; id("some" + "_" + "string") # Notice that both the ids are same.
  140420665652016
  &lt;/code&gt;&lt;/pre&gt;
  
  &lt;h3&gt;This is a heading&lt;/h3&gt;
  
  &lt;pre&gt;&lt;code&gt;print("Hello World")
  &lt;/code&gt;&lt;/pre&gt;
  </code></pre>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>Tried using Pypi markdown</p>
  
  <p><strong>OUTPUT :</strong></p>
  
  <pre><code>PROBLEM :: 
   &lt;ul&gt;
  &lt;li&gt;&lt;p&gt;But why did the &lt;code&gt;is&lt;/code&gt; operator evaluated to &lt;code&gt;False&lt;/code&gt;? Let's see with this snippet.
  &lt;code&gt;py
  class WTF(object):
  def __init__(self): print("I ")
  def __del__(self): print("D ")
  &lt;/code&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  SOLUTION 1:: 
   &lt;pre&gt;&lt;code&gt;  class WTF(object):
      def __init__(self): print("I ")
      def __del__(self): print("D ")
  &lt;/code&gt;&lt;/pre&gt;
  
  SOLUTION 2:: 
   &lt;ul&gt;
  &lt;li&gt;
  &lt;p&gt;But why did the &lt;code&gt;is&lt;/code&gt; operator evaluated to &lt;code&gt;False&lt;/code&gt;? Let's see with this snippet.&lt;/p&gt;
  &lt;p&gt;class WTF(object):
      def &lt;strong&gt;init&lt;/strong&gt;(self): print("I ")
      def &lt;strong&gt;del&lt;/strong&gt;(self): print("D ")&lt;/p&gt;
  &lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;
  </code></pre>
  
  <p><strong>EDIT 2 :</strong></p>
  
  <p>The <code>sub()</code> works fine. I just confirmed it, but since the code already had <code>\n\t</code> at the end of each line so after running it it became <code>\n\t\t</code> and now the <code>markdown()</code> doesn't work.</p>