How do I get python-markdown to additionally "urlify" links when formatting plain text?
django, markdown, python
Solution
I couldn't get superjoe30's regular expression to compile, so I adapted his solution to convert plain URLs (within Markdown text) to be Markdown compatible.
The modified filter:
urlfinder = re.compile('^(http:\/\/\S+)')
urlfinder2 = re.compile('\s(http:\/\/\S+)')
@register.filter('urlify_markdown')
def urlify_markdown(value):
value = urlfinder.sub(r'<\1>', value)
return urlfinder2.sub(r' <\1>', value)
Within the template:
<div>
{{ content|urlify_markdown|markdown}}
</div>
Problem
Markdown is a great tool for formatting plain text into pretty html, but it doesn't turn plain-text links into URLs automatically. Like this one: http://www.google.com/ How do I get markdown to add tags to URLs when I format a block of text?