def wrap(indent_int, unwrap_str):
    """Wrap a single line to one or more lines that start at indent_int and end at the
    last word that will fit before WRAP_MARGIN_INT.

    If there are no word breaks (spaces) before WRAP_MARGIN_INT, force a break at
    WRAP_MARGIN_INT.

    """
    with io.StringIO() as str_buf:
        is_rest_block = unwrap_str.startswith(("- ", "* "))

        while unwrap_str:
            cut_pos = (unwrap_str + " ").rfind(" ", 0, WRAP_MARGIN_INT - indent_int)

            if cut_pos == -1:
                cut_pos = WRAP_MARGIN_INT

            this_str, unwrap_str = unwrap_str[:cut_pos], unwrap_str[cut_pos + 1 :]
            str_buf.write("{}{}\n".format(" " * indent_int, this_str))

            if is_rest_block:
                is_rest_block = False
                indent_int += 2

        return str_buf.getvalue()
Wrap a single line to one or more lines that start at indent_int and end at the
    last word that will fit before WRAP_MARGIN_INT.

    If there are no word breaks (spaces) before WRAP_MARGIN_INT, force a break at
    WRAP_MARGIN_INT.