def quote_escape(value, lf='&mjf-lf;', quot='&mjf-quot;'):
    """
    Escape a string so that it can safely be quoted. You should use this if the
    value to be quoted *may* contain line-feeds or both single quotes and double
    quotes.

    If the value contains ``\n`` then it will be escaped using ``lf``. By
    default this is ``&mjf-lf;``.

    If the value contains single quotes *and* double quotes, then all double
    quotes will be escaped using ``quot``. By default this is ``&mjf-quot;``.

    >>> quote_escape('hello')
    'hello'
    >>> quote_escape('hello\\n')
    'hello&mjf-lf;'
    >>> quote_escape('hello"')
    'hello"'
    >>> quote_escape('hello"\\'')
    "hello&mjf-quot;'"
    >>> quote_escape('hello"\\'\\n', '&fish;', '&wobble;')
    "hello&wobble;'&fish;"
    """
    if '\n' in value:
        value = value.replace('\n', lf)
    if '\'' in value and '\"' in value:
        value = value.replace('"', quot)
    return value