def smartquotes(self, text, escaped_entities=False): """Apply 'smart quotes' to the text; replaces quotes and dashes by nicer looking symbols""" if self.supports_smartquotes and self.do_smartquotes: quoted = smartypants(text) if escaped_entities: return quoted return unescape_entity(quoted) return text
def applyfilters(text): """Applies the following filters: smartypants, caps, amp, initial_quotes >>> typogrify('<h2>"Jayhawks" & KU fans act extremely obnoxiously</h2>') '<h2><span class="dquo">“</span>Jayhawks” <span class="amp">&</span> <span class="caps">KU</span> fans act extremely obnoxiously</h2>' """ text = amp(text) text = smartypants(text) text = caps(text) text = initial_quotes(text) return text
def typogrify(text): '''The super typography filter Applies the following filters: widont, smartypants, caps, amp, initial_quotes >>> typogrify('<h2>"Jayhawks" & KU fans act extremely obnoxiously</h2>') '<h2><span class="dquo">“</span>Jayhawks” <span class="amp">&</span> <span class="caps">KU</span> fans act extremely obnoxiously</h2>' ''' text = amp(text) text = widont(text) text = smartypants(text) text = caps(text) text = initial_quotes(text) return text
def typogrify(text): """The super typography filter Applies the following filters: widont, smartypants, caps, amp, initial_quotes >>> typogrify('<h2>"Jayhawks" & KU fans act extremely obnoxiously</h2>') u'<h2><span class="dquo">“</span>Jayhawks” <span class="amp">&</span> <span class="caps">KU</span> fans act extremely obnoxiously</h2>' Each filters properly handles autoescaping. >>> conditional_escape(typogrify('<h2>"Jayhawks" & KU fans act extremely obnoxiously</h2>')) u'<h2><span class="dquo">“</span>Jayhawks” <span class="amp">&</span> <span class="caps">KU</span> fans act extremely obnoxiously</h2>' """ text = amp(text) text = widont(text) text = smartypants(text) text = caps(text) text = initial_quotes(text) return text