Mercurial > public > sg101
comparison gpp/core/markup.py @ 352:a321685505cc
Fixing #163; make plain links linkable in Markdown. Use an extension found here: https://github.com/r0wb0t/markdown-urlize.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 02 Mar 2011 03:16:19 +0000 |
parents | 3a626c48e9ae |
children | 6a686ffb6609 |
comparison
equal
deleted
inserted
replaced
351:b783a555cd87 | 352:a321685505cc |
---|---|
8 | 8 |
9 class Markdown(object): | 9 class Markdown(object): |
10 """ | 10 """ |
11 This is a thin wrapper around the Markdown class which deals with the | 11 This is a thin wrapper around the Markdown class which deals with the |
12 differences in Markdown versions on the production and development server. | 12 differences in Markdown versions on the production and development server. |
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 | 18 # Unicode support only in markdown v1.7 or above. Version_info |
19 # exists only in markdown v1.6.2rc-2 or above. | 19 # exists only in markdown v1.6.2rc-2 or above. |
20 self.unicode_support = getattr(_markdown, "version_info", None) >= (1, 7) | 20 self.unicode_support = getattr(_markdown, "version_info", None) >= (1, 7) |
21 self.md = _markdown.Markdown(safe_mode=safe_mode) | 21 self.md = _markdown.Markdown(safe_mode=safe_mode, extensions=['urlize']) |
22 | 22 |
23 def convert(self, s): | 23 def convert(self, s): |
24 if self.unicode_support: | 24 if self.unicode_support: |
25 return self.md.convert(force_unicode(s)) | 25 return self.md.convert(force_unicode(s)) |
26 else: | 26 else: |