Mercurial > public > sg101
view tools/mdx_nl2br.py @ 394:2cb0cc334c50
Fixing #186; after upgrading to Django 1.3, can remove the kludge on the cycle tag in the forums topic.html template.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 24 Mar 2011 00:49:21 +0000 |
parents | f54bf3b3bece |
children |
line wrap: on
line source
""" A python-markdown extension to treat newlines as hard breaks; like StackOverflow and GitHub flavored Markdown do. """ import markdown BR_RE = r'\n' class Nl2BrExtension(markdown.Extension): def extendMarkdown(self, md, md_globals): br_tag = markdown.inlinepatterns.SubstituteTagPattern(BR_RE, 'br') md.inlinePatterns.add('nl', br_tag, '_end') def makeExtension(configs=None): return Nl2BrExtension(configs)