def format_value(text):
    """
    Format text. Replaces newlines and carriage returns with spaces so that
    each line of the output is one document.
    """
    return text.encode('utf8').replace('\n', ' ').replace('\r', ' ')