# -*- coding: utf-8 -*- import re from genshi import HTML def linebreaks(value): """Converts newlines in strings into
and
s."""
if not value:
return ''
value = re.sub(r'\r\n|\r|\n', '\n', value) # normalize newlines
paras = re.split('\n{2,}', value)
paras = ['
%s
' % p.strip().replace('\n', '