def detect_html(text):
    """Detect if text is HTML.
    """
    pattern = re.compile('\\s*<(!doctype|html)', re.IGNORECASE)
    return bool(pattern.match(text))
def detect_html ( text ) : pattern = re . compile ( '\\s*<(!doctype|html)' , re . IGNORECASE ) return bool ( pattern . match ( text ) )
Detect if text is HTML.