finalise.py 546 B

1234567891011121314151617181920212223
  1. import re
  2. from django.utils.translation import ugettext as _
  3. HEADER_RE = re.compile(
  4. r'''
  5. <div class="quote-heading">(?P<title>.*?)</div>
  6. '''.strip(), re.IGNORECASE | re.MULTILINE | re.DOTALL
  7. )
  8. def finalise_markup(post):
  9. return HEADER_RE.sub(replace_headers, post)
  10. def replace_headers(matchobj):
  11. title = matchobj.group('title')
  12. if title:
  13. quote_title = _("%(title)s has written:") % {'title': title}
  14. else:
  15. quote_title = _("Quoted message:")
  16. return '<div class="quote-heading">%s</div>' % quote_title