Changeset 109

Show
Ignore:
Timestamp:
01/13/08 02:39:43 (12 months ago)
Author:
steadicat
Message:

Fixed to work with the latest Django.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • django/trunk/contrib/versedown/templatetags/versedown.py

    r86 r109  
    22from django import template 
    33from django.template.defaultfilters import striptags 
    4 #from smartypants import smartyPants as smartypants 
     4from django.utils.safestring import mark_safe 
     5from typogrify import typogrify 
    56from markdown import markdownWithFootnotes, markdown as basicMarkdown 
    67 
     
    1920@register.filter 
    2021def versedown(text): 
    21     return reformatFootnotes(markdownWithFootnotes(reformatNewlines(text))) 
     22    return mark_safe(typogrify(reformatFootnotes(markdownWithFootnotes(reformatNewlines(text))))) 
    2223 
    2324@register.filter 
    2425def markdownfn(text): 
    25     return reformatFootnotes(markdownWithFootnotes(text)) 
     26    return mark_safe(typogrify(reformatFootnotes(markdownWithFootnotes(text)))) 
    2627 
    2728@register.filter 
    2829def markdown(text): 
    29     return basicMarkdown(text) 
     30    return mark_safe(typogrify(basicMarkdown(text))) 
    3031 
    3132@register.filter 
    3233def linedown(text): 
    3334    """Markdown for titles. Removes extra <p></p>.""" 
    34     return markdown(text)[len(" <p>"):-len("\n </p> ")] 
     35    return mark_safe(markdown(text)[len(" <p>"):-len(" \n</p>")]) 
     36 
     37@register.filter 
     38def linedownfn(text): 
     39    return mark_safe(markdownfn(text)) # todo: strip extra <p>s 
    3540 
    3641@register.filter 
    3742def stripdown(text): 
    3843    """Remove markdown formatting and return plain text. For feed titles and stuff.""" 
    39     return striptags(markdown(text)) 
     44    return mark_safe(striptags(basicMarkdown(text))) 
    4045 
    4146@register.filter 
     
    5863    """ 
    5964    text = nn.sub(r"\n\n<p>&nbsp;</p>\n\n", text) 
    60     text = markdown(text) 
     65    text = basicMarkdown(text) 
    6166    text = br.sub("<br />", text) 
    6267    text = n.sub("", text) 
    63     return text 
     68    return mark_safe(text) 
    6469 
    6570if __name__ == "__main__": 
    6671    import doctest 
    6772    doctest.testmod() 
     73 
     74@register.filter 
     75def truncatelines(text, lines): 
     76    return '\n'.join(text.splitlines()[:lines])