def format_multiline_html(text):
    """
    Turns a string like 'a\nb\nc' into 'a<br>b<br>c' and marks as Markup

    Note: Will remove all \r characters from output (if present)
    """
    if text is None:
        return None

    if '\n' not in text:
        return text.replace('\r', '')

    parts = text.replace('\r', '').split('\n')
    out = flask.Markup()
    for part in parts:
        if out:
            out += flask.Markup('<br>')
        out += flask.escape(part)
    return out
Turns a string like 'a\nb\nc' into 'a<br>b<br>c' and marks as Markup

    Note: Will remove all \r characters from output (if present)