@register.filter('linebreaks', is_safe=True, needs_autoescape=True)
@stringfilter
def linebreaks_filter(value, autoescape=None):
 autoescape = (autoescape and (not isinstance(value, SafeData)))
 return mark_safe(linebreaks(value, autoescape))

@ register . filter ( 'linebreaks' , is_safe = True , needs_autoescape = True ) @ stringfilter def linebreaks_filter ( value , autoescape = None ) : autoescape = ( autoescape and ( not isinstance ( value , SafeData ) ) ) return mark_safe ( linebreaks ( value , autoescape ) )
replaces line breaks in plain text with appropriate html; a single newline becomes an html line break and a new line followed by a blank line becomes a paragraph break .