def esc_format(text):
    """Return text with formatting escaped

    Markdown requires a backslash before literal underscores or asterisk, to
    avoid formatting to bold or italics.
    """
    for symbol in ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!']:
        text = str(text).replace(symbol, '\\' + symbol)

    return text