Mercurial > public > sg101
diff core/markup.py @ 792:7429c98c8ece
Issue #71: use relative URLs for smileys on the web and absolute for RSS.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 26 May 2014 14:59:55 -0500 |
parents | 216f06267e2d |
children | 32ebe22f0cad |
line wrap: on
line diff
--- a/core/markup.py Fri May 23 21:52:41 2014 -0500 +++ b/core/markup.py Mon May 26 14:59:55 2014 -0500 @@ -8,11 +8,8 @@ class Markdown(object): """ - This is a thin wrapper around the Markdown class which deals with the - differences in Markdown versions on the production and development server. - This code was inspired by the code in - django/contrib/markup/templatetags/markup.py. - Currently, we only have to worry about Markdown 1.6b and 2.0. + This is a thin wrapper around the Markdown class. + """ def __init__(self, safe_mode='escape'): self.md = _markdown.Markdown(safe_mode=safe_mode, @@ -34,18 +31,22 @@ """ This class provides site markup by combining markdown and our own smiley markup. + + The relative_urls parameter controls whether the smileys are generated with + relative or absolute URLs. + """ - def __init__(self): + def __init__(self, relative_urls=True): self.md = Markdown() - self.smiley = SmilifyMarkdown() + self.smiley = SmilifyMarkdown(relative_urls=relative_urls) def convert(self, s): return self.md.convert(self.smiley.convert(s)) -def site_markup(s): +def site_markup(s, relative_urls=True): """ Convenience function for one-off site markup jobs. """ - sm = SiteMarkup() + sm = SiteMarkup(relative_urls=relative_urls) return sm.convert(s)