Mercurial > public > sg101
annotate core/markup.py @ 693:ad69236e8501
For issue #52, update many 3rd party Javascript libraries.
Updated to jquery 1.10.2, jquery ui 1.10.3.
This broke a lot of stuff.
- Found a newer version of the jquery cycle all plugin (3.0.3).
- Updated JPlayer to 2.4.0.
- Updated to MarkItUp 1.1.14. This also required me to add multiline attributes
set to true on various buttons in the markdown set.
- As per a stackoverflow post, added some code to get multiline titles in
a jQuery UI dialog. They removed that functionality but allow you to put it
back.
Tweaked the MarkItUp preview CSS to show blockquotes in italic.
Did not update TinyMCE at this time. I'm not using the JQuery version and this
version appears to work ok for now.
What I should do is make a repo for MarkItUp and do a vendor branch thing so
I don't have to futz around diffing directories to figure out if I'll lose
changes when I update.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 04 Sep 2013 19:55:20 -0500 |
parents | 216f06267e2d |
children | 7429c98c8ece |
rev | line source |
---|---|
bgneal@124 | 1 """ |
bgneal@128 | 2 Markup related utitlities useful for the entire project. |
bgneal@124 | 3 """ |
bgneal@124 | 4 import markdown as _markdown |
bgneal@124 | 5 from django.utils.encoding import force_unicode |
bgneal@124 | 6 |
bgneal@211 | 7 from smiley import SmilifyMarkdown |
bgneal@124 | 8 |
bgneal@124 | 9 class Markdown(object): |
bgneal@128 | 10 """ |
bgneal@128 | 11 This is a thin wrapper around the Markdown class which deals with the |
bgneal@128 | 12 differences in Markdown versions on the production and development server. |
bgneal@352 | 13 This code was inspired by the code in |
bgneal@128 | 14 django/contrib/markup/templatetags/markup.py. |
bgneal@128 | 15 Currently, we only have to worry about Markdown 1.6b and 2.0. |
bgneal@128 | 16 """ |
bgneal@124 | 17 def __init__(self, safe_mode='escape'): |
bgneal@353 | 18 self.md = _markdown.Markdown(safe_mode=safe_mode, |
bgneal@356 | 19 extensions=['urlize', 'nl2br', 'del']) |
bgneal@124 | 20 |
bgneal@124 | 21 def convert(self, s): |
bgneal@686 | 22 return self.md.convert(force_unicode(s)) |
bgneal@124 | 23 |
bgneal@124 | 24 |
bgneal@124 | 25 def markdown(s): |
bgneal@128 | 26 """ |
bgneal@128 | 27 A convenience function for one-off markdown jobs. |
bgneal@128 | 28 """ |
bgneal@124 | 29 md = Markdown() |
bgneal@124 | 30 return md.convert(s) |
bgneal@128 | 31 |
bgneal@128 | 32 |
bgneal@128 | 33 class SiteMarkup(object): |
bgneal@128 | 34 """ |
bgneal@128 | 35 This class provides site markup by combining markdown and |
bgneal@128 | 36 our own smiley markup. |
bgneal@128 | 37 """ |
bgneal@128 | 38 def __init__(self): |
bgneal@128 | 39 self.md = Markdown() |
bgneal@211 | 40 self.smiley = SmilifyMarkdown() |
bgneal@128 | 41 |
bgneal@128 | 42 def convert(self, s): |
bgneal@211 | 43 return self.md.convert(self.smiley.convert(s)) |
bgneal@128 | 44 |
bgneal@128 | 45 |
bgneal@128 | 46 def site_markup(s): |
bgneal@128 | 47 """ |
bgneal@128 | 48 Convenience function for one-off site markup jobs. |
bgneal@128 | 49 """ |
bgneal@128 | 50 sm = SiteMarkup() |
bgneal@128 | 51 return sm.convert(s) |