(text)
return new_text
Removes redundant blank lines

    After multiple passes of the text reformatting there could be redundant blank lines between sections.
    This pass is intended for removal of consecutive blank lines and keeping just one blank line between sections

    :param text: Original text
    :return: Text with removed redundant blank lines
Removes redundant blank lines
Removes redundant blank lines
def reformat_remove_multiple_blank_lines(text):
    """
    Removes redundant blank lines

    After multiple passes of the text reformatting there could be redundant blank lines between sections.
    This pass is intended for removal of consecutive blank lines and keeping just one blank line between sections

    :param text: Original text
    :return: Text with removed redundant blank lines
    """

    len_changed = True

    while len_changed:
        new_text = text.replace('\n\n\n', '\n\n')
        len_changed = len(new_text) < len(text)
        text = new_text

    return new_text
def reformat_remove_multiple_blank_lines ( text ) : len_changed = True while len_changed : new_text = text . replace ( '\n\n\n' , '\n\n' ) len_changed = len ( new_text ) < len ( text ) text = new_text return new_text