def entity(reference):
    """Return a numeric (&#reference;) or symbolic: (&reference;) entity,
    depending on the reference's type
    """
    try:
        return '&#{0:d};'.format(reference)
    except ValueError:
        return '&{0};'.format(reference)
    #