from bs4 import BeautifulSoup


def prettify(text, newline=False, carriage=False, translate_table=None):
    """
    Prettify a string.

    Parameters
    ----------
    text : str
        text to be prettified.
    newline : bool, optional
        replace newline. The default is False.
    carriage : bool, optional
        replace carriage return. The default is False.
    translate_table : bool, optional
        use a translator. The default is None.

    Returns
    -------
    string
        prettified string.

    """
    text = BeautifulSoup(text, 'html.parser').get_text()
    if carriage:
        text = text.replace('\r', '')
    if newline:
        text = text.replace('\n', '')
    if translate_table:
        text = text.translate(translate_table)
    return str(text)