'This cleans up after Markdown\'s well-intended placing of image tags
inside <p> elements. The problem is that Markdown should put
<p> tags around images as they are inline elements. However, because
we wrap them in <figure>, we don\'t actually want it and have to
remove it again after.'

def run(self, text):

    text = text.replace(u'<p><figure', u'<figure')
    text = text.replace(u'</figure>\n</p>', u'</figure>')
    return text
