Transplanted from the Python Markdown.