Mercurial > public > sg101
comparison core/markup.py @ 686:216f06267e2d
For Django 1.5: Remove all references to django.contrib.markup.
This amounted to deleting some old templates, removing the app from
INSTALLED_APPS, and doing some cleanup in core.markup.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 24 Aug 2013 20:08:12 -0500 |
parents | ee87ea74d46b |
children | 7429c98c8ece |
comparison
equal
deleted
inserted
replaced
685:a75554eb6bae | 686:216f06267e2d |
---|---|
13 This code was inspired by the code in | 13 This code was inspired by the code in |
14 django/contrib/markup/templatetags/markup.py. | 14 django/contrib/markup/templatetags/markup.py. |
15 Currently, we only have to worry about Markdown 1.6b and 2.0. | 15 Currently, we only have to worry about Markdown 1.6b and 2.0. |
16 """ | 16 """ |
17 def __init__(self, safe_mode='escape'): | 17 def __init__(self, safe_mode='escape'): |
18 # Unicode support only in markdown v1.7 or above. Version_info | |
19 # exists only in markdown v1.6.2rc-2 or above. | |
20 self.unicode_support = getattr(_markdown, "version_info", None) >= (1, 7) | |
21 self.md = _markdown.Markdown(safe_mode=safe_mode, | 18 self.md = _markdown.Markdown(safe_mode=safe_mode, |
22 extensions=['urlize', 'nl2br', 'del']) | 19 extensions=['urlize', 'nl2br', 'del']) |
23 | 20 |
24 def convert(self, s): | 21 def convert(self, s): |
25 if self.unicode_support: | 22 return self.md.convert(force_unicode(s)) |
26 return self.md.convert(force_unicode(s)) | |
27 else: | |
28 return force_unicode(self.md.convert(s)) | |
29 | 23 |
30 | 24 |
31 def markdown(s): | 25 def markdown(s): |
32 """ | 26 """ |
33 A convenience function for one-off markdown jobs. | 27 A convenience function for one-off markdown jobs. |