Take the 2-minute tour ×

I'm not new to Python but a complete newbie with regular expressions (on my to do list)

I am trying to use python re to convert a string such as

[Hollywood Holt](http://www.hollywoodholt.com)


<a href="http://www.hollywoodholt.com">Hollywood Holt</a>

and a string like

*Hello world*


<strong>Hello world</strong>
share|improve this question

1 Answer 1

up vote 12 down vote accepted

Why are you bothering to use a regex? Your content is Markdown, why not simply take the string and run it through the markdown module?

First, make sure Markdown is installed. It has a dependancy on ElementTree so easy_install the two of them as follows. If you're running Windows, you can use the Windows installer instead.

easy_install ElementTree
easy_install Markdown

To use the Markdown module and convert your string to html simply do the following (tripple quotes are used for literal strings):

import markdown
markdown_text = """[Hollywood Holt](http://www.hollywoodholt.com)"""
html = markdown.markdown(markdown_text)
share|improve this answer
+1 I'll give it to ya. ;) –  Paolo Bergantino Jun 1 '09 at 7:25
great, thanks a lot! –  Quinn Jun 1 '09 at 7:25

Your Answer

