def remove_single_lines(text):
    """
    Replaces single line breaks with spaces. Double line breaks
    are kept as they are. If the text param is None, it is substituted with
    an empty string.
    """
    # To make line sizes a bit easier to handle, we remove single line breaks
    # and replace them with a space, similar to what markdown does. To put a
    # single line break in explicitly, add "\r".
    if text is None:
        text = ''

    d = '\n\n'.join(line.replace('\n', ' ') for line in text.split('\n\n'))
    d = d.replace('\r\n', '\n')
    return d