def shorten_text(txt, before, after, placeholder='...'):
    """Shorten a text to max before+len(placeholder)+after chars.

    The new text will keep the before first characters and after last characters
    """
    if len(txt) <= before + len(placeholder) + after:
        return txt
    else:
        return txt[:before] + placeholder + txt[-after:]
