Ticket #7010: wikimarkup.patch

File wikimarkup.patch, 1.3 KB (added by Joshua "jag" Ginsberg <jag@…>, 17 years ago)
  • django/contrib/markup/templatetags/markup.py

     
    1010
    1111    * ReStructuredText, which requires docutils from http://docutils.sf.net/
    1212
     13    * MediaWiki markup, which requires wikimarkup from http://code.google.com/p/wikimarkup/
     14
    1315In each case, if the required library is not installed, the filter will
    1416silently fail and return the un-marked-up text.
    1517"""
     
    8385        return mark_safe(force_unicode(parts["fragment"]))
    8486restructuredtext.is_safe = True
    8587
     88def wikimarkup(value):
     89    try:
     90        import wikimarkup
     91    except ImportError:
     92        if settings.DEBUG:
     93            raise template.TemplateSyntaxError, ("Error in {% wikimarkup %} "
     94                                                 "filter: The wikimarkup "
     95                                                 "library isn't installed.")
     96        return force_unicode(value)
     97    else:
     98        return mark_safe(force_unicode(wikimarkup.parse(smart_str(value))))
     99wikimarkup.is_safe = True
     100
    86101register.filter(textile)
    87102register.filter(markdown)
    88103register.filter(restructuredtext)
     104register.filter(wikimarkup)
Back to Top