import html


def str_reduce_length(s: str, max_: int, *, escape_html=False, suffix: str = "...") -> str:
    """
    Reduce the length of ``s`` to ``max_`` including the length of ``suffix``.

    HTML escape performed after the length reduction.

    :param s: string to be reduced the length
    :param max_: max length of the string including the length of `suffix`
    :param escape_html: if the HTML characters should be escaped
    :param suffix: suffix of the string to be attached
    :return: truncated string
    :raises ValueError: suffix length > max content length
    """
    if len(suffix) > max_:
        raise ValueError("Suffix length > max content length is invalid.")

    if len(s) > max_:
        s = s[:max_ - len(suffix)] + suffix

    if escape_html:
        s = html.escape(s)

    return s