def text_summary(text, length=40):
    """
    Make a summary of `text`, at most `length` chars long.

    The middle will be elided if needed.
    """
    if len(text) <= length:
        return text
    else:
        start = (length - 3) // 2
        end = (length - 3 - start)
        return text[:start] + "..." + text[-end:]