Mercurial > public > sg101
annotate tools/mdx_nl2br.py @ 552:9e42e6618168
For bitbucket issue #2, tweak the admin settings for the Post model to
reduce slow queries. Define our own queryset() method so we can control the
select_related(), and not have it cascade from post to topics to forums to
categories. Removed 'topic' from list_display because MySQL still sucked with
2 inner joins. Now it seems to be tolerable with only one join to User.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 25 Jan 2012 20:07:03 -0600 |
parents | f54bf3b3bece |
children |
rev | line source |
---|---|
bgneal@356 | 1 """ |
bgneal@356 | 2 A python-markdown extension to treat newlines as hard breaks; like |
bgneal@356 | 3 StackOverflow and GitHub flavored Markdown do. |
bgneal@356 | 4 |
bgneal@356 | 5 """ |
bgneal@356 | 6 import markdown |
bgneal@356 | 7 |
bgneal@356 | 8 |
bgneal@356 | 9 BR_RE = r'\n' |
bgneal@356 | 10 |
bgneal@356 | 11 class Nl2BrExtension(markdown.Extension): |
bgneal@356 | 12 |
bgneal@356 | 13 def extendMarkdown(self, md, md_globals): |
bgneal@356 | 14 br_tag = markdown.inlinepatterns.SubstituteTagPattern(BR_RE, 'br') |
bgneal@356 | 15 md.inlinePatterns.add('nl', br_tag, '_end') |
bgneal@356 | 16 |
bgneal@356 | 17 |
bgneal@356 | 18 def makeExtension(configs=None): |
bgneal@356 | 19 return Nl2BrExtension(configs) |