def newline_to_br(eval_ctx, value):
    '''Replaces newline characters with <br> tags

    Adapted from http://flask.pocoo.org/snippets/28/
    '''
    result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n') for p in PARAGRAPH.split(value))
    if eval_ctx and eval_ctx.autoescape:
        result = Markup(result)
    return result.lstrip()
Exemple #2
0
def newline_to_br(eval_ctx, value):
    """Replaces newline characters with <br> tags

    Adapted from http://flask.pocoo.org/snippets/28/
    """
    result = u"\n\n".join(u"<p>%s</p>" % p.replace("\n", Markup("<br>\n")) for p in PARAGRAPH.split(escape(value)))
    if eval_ctx and eval_ctx.autoescape:
        result = Markup(result)
    return result.lstrip()
Exemple #3
0
def newline_to_br(eval_ctx, value):
    '''Replaces newline characters with <br> tags

    Adapted from http://flask.pocoo.org/snippets/28/
    '''
    result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n')
                          for p in PARAGRAPH.split(value))
    if eval_ctx and eval_ctx.autoescape:
        result = Markup(result)
    return result.lstrip()