import re


def repeating_chars(text: str, *, chars: str, maxn: int = 1) -> str:
    """Normalize repeating characters in `text`.

    Truncating their number of consecutive repetitions to `maxn`.
    Duplicates Textacy's `utils.normalize_repeating_chars`.

    Args:
        text (str): The text to normalize.
        chars: One or more characters whose consecutive repetitions are to be
            normalized, e.g. "." or "?!".
        maxn: Maximum number of consecutive repetitions of `chars` to which
            longer repetitions will be truncated.

    Returns:
        str
    """
    return re.sub(r"({}){{{},}}".format(re.escape(chars), maxn + 1), chars * maxn, text)