Returns the given HTML with ampersands,
    quotes and angle brackets encoded.

def escape(html, force=False):
    """Returns the given HTML with ampersands,
    quotes and angle brackets encoded."""
    if hasattr(html, '__html__') and not force:
        return html
    if html in NOTHING:
        return ''
    else:
        return to_string(html).replace('&', '&amp;').replace(
            '<', '&lt;').replace('>', '&gt;').replace("'", '&#39;').replace(
            '"', '&quot;')