@classmethod
def escape(cls, text, quotes=True):
    """Create a Markup instance from a string and escape special characters
        it may contain (<, >, & and ").
        
        >>> escape('"1 < 2"')
        <Markup '&#34;1 &lt; 2&#34;'>
        
        If the `quotes` parameter is set to `False`, the " character is left
        as is. Escaping quotes is generally only required for strings that are
        to be used in attribute values.
        
        >>> escape('"1 < 2"', quotes=False)
        <Markup '"1 &lt; 2"'>
        
        :param text: the text to escape
        :param quotes: if ``True``, double quote characters are escaped in
                       addition to the other special characters
        :return: the escaped `Markup` string
        :rtype: `Markup`
        """
    if not text:
        return cls()
    if type(text) is cls:
        return text
    if hasattr(text, '__html__'):
        return cls(text.__html__())
    text = text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
    if quotes:
        text = text.replace('"', '&#34;')
    return cls(text)
