title: Convert hyperlink
body: <p>I am trying to write a python function and convert markdown format link like: [text] (link), into &lt; a href > tags in HTML. For example:</p>
  
  <p>link(line)</p>
  
  <pre><code>link("Here is the link [Social Science Illustrated](https://en.wikipedia.org/wiki/Social_Science_Illustrated) I gave you yesterday.")
  
  "Here is the link &lt;a href="https://en.wikipedia.org/wiki/Social_Science_Illustrated"&gt;Social Science Illustrated&lt;/a&gt; I gave you yesterday."
  </code></pre>
  
  <p>And my code for now is:</p>
  
  <pre><code>def link(line):
    import re
    urls = re.compile(r"((https?):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&amp;]*)")
    line = urls.sub(r'&lt;a href="\1"&gt;&lt;/a&gt;', line)
    return line
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>=&gt; 'Here is the link [Social Science Illustrated] ( &lt;a href="https://en.wikipedia.org/wiki/Social_Science_Illustrated"&gt;&lt;/a&gt; ) I gave you yesterday.'
  </code></pre>
  
  <p>So I was wondering how to convert [text] part into correct position?</p>