def add_new_line_after_period()

in security-policies/dev/common.py [0:0]


def add_new_line_after_period(text):
    # Split the text into lines
    lines = text.split("\n")

    # Find the lines that start with a number and a period
    numbered_lines = [line for line in lines if re.match(r"^\d+\.", line)]

    # Iterate through the lines and add a new line after a period, unless the line is a numbered line
    for i, line in enumerate(lines):
        if line not in numbered_lines:
            lines[i] = line.replace(". ", ".\n")

    # Join the lines back into a single string and return the result
    return "\n".join(lines)